r272654 - clang-format: [JS] Support annotated classes.

Daniel Jasper via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 14 04:28:02 PDT 2016


Author: djasper
Date: Tue Jun 14 06:28:02 2016
New Revision: 272654

URL: http://llvm.org/viewvc/llvm-project?rev=272654&view=rev
Log:
clang-format: [JS] Support annotated classes.

Modified:
    cfe/trunk/lib/Format/TokenAnnotator.cpp
    cfe/trunk/unittests/Format/FormatTestJS.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=272654&r1=272653&r2=272654&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Tue Jun 14 06:28:02 2016
@@ -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;

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=272654&r1=272653&r2=272654&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Tue Jun 14 06:28:02 2016
@@ -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) {




More information about the cfe-commits mailing list