]> granicus.if.org Git - clang/commitdiff
clang-format: [JS] Array literal detection fix #3.
authorDaniel Jasper <djasper@google.com>
Tue, 2 Jun 2015 15:04:29 +0000 (15:04 +0000)
committerDaniel Jasper <djasper@google.com>
Tue, 2 Jun 2015 15:04:29 +0000 (15:04 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@238839 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 0cfcd8921dd4148d5a653837272d709664bfce87..19b47baeb40f7933946c3cfdab1612003c5883f4 100644 (file)
@@ -280,8 +280,8 @@ private:
                  Parent->isOneOf(tok::l_brace, tok::comma)) {
         Left->Type = TT_JsComputedPropertyName;
       } else if (Parent &&
-                 Parent->isOneOf(tok::at, tok::equal, tok::comma,
-                                 tok::l_paren, tok::question, tok::colon)) {
+                 Parent->isOneOf(tok::at, tok::equal, tok::comma, tok::l_paren,
+                                 tok::l_square, tok::question, tok::colon)) {
         Left->Type = TT_ArrayInitializerLSquare;
       } else {
         BindingIncrease = 10;
index 583188d3ebc1d8b7561470793f5a513498ac6cb3..25113ab75896dbdb22d9636b2b1b4f68152ed277 100644 (file)
@@ -257,6 +257,9 @@ TEST_F(FormatTestJS, ArrayLiterals) {
                "  bbbbbbbbbbbbbbbbbbbbbbbbbbb,\n"
                "  ccccccccccccccccccccccccccc\n"
                "]);");
+  verifyFormat("var someVariable = SomeFuntion([\n"
+               "  [aaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbbbbbbbbbbb],\n"
+               "]);");
   verifyFormat("var someVariable = SomeFuntion(aaaa, [\n"
                "  aaaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
                "  bbbbbbbbbbbbbbbbbbbbbbbbbbb,\n"