]> granicus.if.org Git - clang/commitdiff
clang-format: [JS] Support exporting abstract classes.
authorDaniel Jasper <djasper@google.com>
Tue, 12 Jan 2016 06:24:38 +0000 (06:24 +0000)
committerDaniel Jasper <djasper@google.com>
Tue, 12 Jan 2016 06:24:38 +0000 (06:24 +0000)
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

lib/Format/UnwrappedLineParser.cpp
unittests/Format/FormatTestJS.cpp

index d35d8a6053d3826c3299698b7d813cfd1fc504d8..7b8f6e652416c3395a2f64e692d647b504eac134 100644 (file)
@@ -1809,6 +1809,10 @@ void UnwrappedLineParser::parseJavaScriptEs6ImportExport() {
     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,
                          Keywords.kw_interface, Keywords.kw_let,
                          Keywords.kw_var))
index 5e9a1b533cadb43d051b44b44e1a6f11e075183c..992331cecb4c30230bddcd6706983e84f4112e40 100644 (file)
@@ -878,6 +878,7 @@ TEST_F(FormatTestJS, Modules) {
                "  y: string;\n"
                "}");
   verifyFormat("export class X { y: number; }");
+  verifyFormat("export abstract class X { y: number; }");
   verifyFormat("export default class X { y: number }");
   verifyFormat("export default function() {\n  return 1;\n}");
   verifyFormat("export var x = 12;");