]> granicus.if.org Git - clang/commitdiff
clang-format: [JS] Allow periods and commata in class declarations.
authorDaniel Jasper <djasper@google.com>
Mon, 13 Apr 2015 14:56:54 +0000 (14:56 +0000)
committerDaniel Jasper <djasper@google.com>
Mon, 13 Apr 2015 14:56:54 +0000 (14:56 +0000)
Patch by Martin Probst. Thank you.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@234752 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 826356f474afabb32ac6b09ab87765689c1a4c12..905f9c1ba5fdf792c4a8df97ae357fedba4f5734 100644 (file)
@@ -1541,7 +1541,8 @@ void UnwrappedLineParser::parseRecord() {
     // it is often token-pasted.
     while (FormatTok->is(tok::identifier) || FormatTok->is(tok::coloncolon) ||
            FormatTok->is(tok::hashhash) ||
-           (Style.Language == FormatStyle::LK_Java &&
+           ((Style.Language == FormatStyle::LK_Java ||
+             Style.Language == FormatStyle::LK_JavaScript) &&
             FormatTok->isOneOf(tok::period, tok::comma)))
       nextToken();
 
index 76c2730960ed03e310f8d3486d5c2ca2c1bae828..bfe62ecb956a7f9b75162405034de94f2efdaf5e 100644 (file)
@@ -544,6 +544,7 @@ TEST_F(FormatTestJS, ClassDeclarations) {
   verifyFormat("class C {\n  private static x: string = 12;\n}");
   verifyFormat("class C {\n  static x(): string { return 'asd'; }\n}");
   verifyFormat("class C extends P implements I {}");
+  verifyFormat("class C extends p.P implements i.I {}");
 }
 
 TEST_F(FormatTestJS, MetadataAnnotations) {