]> granicus.if.org Git - clang/commitdiff
clang-format: [JS] Support annotated classes.
authorDaniel Jasper <djasper@google.com>
Tue, 14 Jun 2016 11:28:02 +0000 (11:28 +0000)
committerDaniel Jasper <djasper@google.com>
Tue, 14 Jun 2016 11:28:02 +0000 (11:28 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@272654 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/TokenAnnotator.cpp
unittests/Format/FormatTestJS.cpp

index cd8f28b081bfeb816014f2fc07a0ab476012a31a..7df3bdd7816eaf07719f7ec535ce69741fea792c 100644 (file)
@@ -1461,7 +1461,8 @@ private:
         return Current->getPrecedence();
       if (Current->isOneOf(tok::period, tok::arrow))
         return PrecedenceArrowAndPeriod;
-      if (Style.Language == FormatStyle::LK_Java &&
+      if ((Style.Language == FormatStyle::LK_Java ||
+           Style.Language == FormatStyle::LK_JavaScript) &&
           Current->isOneOf(Keywords.kw_extends, Keywords.kw_implements,
                            Keywords.kw_throws))
         return 0;
index 75b53a578798b61f562b0fc9e963592e555a3e75..8410a0c9967ca8ec8d3d946bdad60cf4fe67c480 100644 (file)
@@ -948,6 +948,11 @@ TEST_F(FormatTestJS, ClassDeclarations) {
                "    },\n"
                "  };\n"
                "}");
+  verifyFormat("@Component({\n"
+               "  moduleId: module.id,\n"
+               "})\n"
+               "class SessionListComponent implements OnDestroy, OnInit {\n"
+               "}");
 }
 
 TEST_F(FormatTestJS, InterfaceDeclarations) {