case tok::kw_struct:
case tok::kw_union:
case tok::kw_class:
+ // parseRecord falls through and does not yet add an unwrapped line as a
+ // record declaration or definition can start a structural element.
parseRecord();
- // A record declaration or definition is always the start of a structural
- // element.
+ // This does not apply for Java and JavaScript.
+ if (Style.Language == FormatStyle::LK_Java ||
+ Style.Language == FormatStyle::LK_JavaScript) {
+ addUnwrappedLine();
+ return;
+ }
break;
case tok::period:
nextToken();
// We fall through to parsing a structural element afterwards, so
// class A {} n, m;
// will end up in one unwrapped line.
- // This does not apply for Java and JavaScript.
- if (Style.Language == FormatStyle::LK_Java ||
- Style.Language == FormatStyle::LK_JavaScript)
- addUnwrappedLine();
}
void UnwrappedLineParser::parseObjCProtocolList() {
verifyFormat("export default class X { y: number }");
verifyFormat("export default function() {\n return 1;\n}");
verifyFormat("export var x = 12;");
+ verifyFormat("class C {}\n"
+ "export function f() {}\n"
+ "var v;");
verifyFormat("export var x: number = 12;");
verifyFormat("export const y = {\n"
" a: 1,\n"