Skip to content
Snippets Groups Projects
Commit 318abdbd authored by Daniel Jasper's avatar Daniel Jasper
Browse files

clang-format: [JS] Support exporting abstract classes.

Before:
  export abstract class X {y: number;}
(and all sorts of other havoc in more complicated cases).

After:
  export abstract class X { y: number; }

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@257451 91177308-0d34-0410-b5e6-96231b3b80d8
parent a791c7fd
No related branches found
No related tags found
No related merge requests found
...@@ -1809,6 +1809,10 @@ void UnwrappedLineParser::parseJavaScriptEs6ImportExport() { ...@@ -1809,6 +1809,10 @@ void UnwrappedLineParser::parseJavaScriptEs6ImportExport() {
return; return;
} }
// Consume the "abstract" in "export abstract class".
if (FormatTok->is(Keywords.kw_abstract))
nextToken();
if (FormatTok->isOneOf(tok::kw_const, tok::kw_class, tok::kw_enum, if (FormatTok->isOneOf(tok::kw_const, tok::kw_class, tok::kw_enum,
Keywords.kw_interface, Keywords.kw_let, Keywords.kw_interface, Keywords.kw_let,
Keywords.kw_var)) Keywords.kw_var))
......
...@@ -878,6 +878,7 @@ TEST_F(FormatTestJS, Modules) { ...@@ -878,6 +878,7 @@ TEST_F(FormatTestJS, Modules) {
" y: string;\n" " y: string;\n"
"}"); "}");
verifyFormat("export class X { y: number; }"); verifyFormat("export class X { y: number; }");
verifyFormat("export abstract class X { y: number; }");
verifyFormat("export default class X { y: number }"); verifyFormat("export default class X { y: number }");
verifyFormat("export default function() {\n return 1;\n}"); verifyFormat("export default function() {\n return 1;\n}");
verifyFormat("export var x = 12;"); verifyFormat("export var x = 12;");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment