r238832 - clang-format: [JS] Fix regression of detecting array literals.

Daniel Jasper djasper at google.com
Tue Jun 2 06:56:43 PDT 2015


Author: djasper
Date: Tue Jun  2 08:56:43 2015
New Revision: 238832

URL: http://llvm.org/viewvc/llvm-project?rev=238832&view=rev
Log:
clang-format: [JS] Fix regression of detecting array literals.

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=238832&r1=238831&r2=238832&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Tue Jun  2 08:56:43 2015
@@ -278,7 +278,9 @@ private:
       } else if (Style.Language == FormatStyle::LK_JavaScript && Parent &&
                  Parent->isOneOf(tok::l_brace, tok::comma)) {
         Left->Type = TT_JsComputedPropertyName;
-      } else if (Parent && Parent->isOneOf(tok::at, tok::equal, tok::comma)) {
+      } else if (Parent &&
+                 Parent->isOneOf(tok::at, tok::equal, tok::comma,
+                                 tok::l_paren)) {
         Left->Type = TT_ArrayInitializerLSquare;
       } else {
         BindingIncrease = 10;

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=238832&r1=238831&r2=238832&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Tue Jun  2 08:56:43 2015
@@ -252,6 +252,11 @@ TEST_F(FormatTestJS, ArrayLiterals) {
                "  new SomeThingAAAAAAAAAAAA(),\n"
                "  new SomeThingBBBBBBBBB()\n"
                "];");
+  verifyFormat("var someVariable = SomeFuntion([\n"
+               "  aaaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
+               "  bbbbbbbbbbbbbbbbbbbbbbbbbbb,\n"
+               "  ccccccccccccccccccccccccccc\n"
+               "]);");
 }
 
 TEST_F(FormatTestJS, FunctionLiterals) {





More information about the cfe-commits mailing list