clang-format: [JS] Array literal detection fix #4.
authorDaniel Jasper <djasper@google.com>
Tue, 2 Jun 2015 21:57:51 +0000 (21:57 +0000)
committerDaniel Jasper <djasper@google.com>
Tue, 2 Jun 2015 21:57:51 +0000 (21:57 +0000)
llvm-svn: 238873

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

index 19b47ba..0ee5a7c 100644 (file)
@@ -281,7 +281,8 @@ private:
         Left->Type = TT_JsComputedPropertyName;
       } else if (Parent &&
                  Parent->isOneOf(tok::at, tok::equal, tok::comma, tok::l_paren,
-                                 tok::l_square, tok::question, tok::colon)) {
+                                 tok::l_square, tok::question, tok::colon,
+                                 tok::kw_return)) {
         Left->Type = TT_ArrayInitializerLSquare;
       } else {
         BindingIncrease = 10;
index 6550863..1dcce6f 100644 (file)
@@ -252,6 +252,11 @@ TEST_F(FormatTestJS, ArrayLiterals) {
                "  new SomeThingAAAAAAAAAAAA(),\n"
                "  new SomeThingBBBBBBBBB()\n"
                "];");
+  verifyFormat("return [\n"
+               "  aaaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
+               "  bbbbbbbbbbbbbbbbbbbbbbbbbbb,\n"
+               "  ccccccccccccccccccccccccccc\n"
+               "];");
   verifyFormat("var someVariable = SomeFuntion([\n"
                "  aaaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
                "  bbbbbbbbbbbbbbbbbbbbbbbbbbb,\n"