r238873 - clang-format: [JS] Array literal detection fix #4.
Daniel Jasper
djasper at google.com
Tue Jun 2 14:57:51 PDT 2015
Author: djasper
Date: Tue Jun 2 16:57:51 2015
New Revision: 238873
URL: http://llvm.org/viewvc/llvm-project?rev=238873&view=rev
Log:
clang-format: [JS] Array literal detection fix #4.
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=238873&r1=238872&r2=238873&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Tue Jun 2 16:57:51 2015
@@ -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;
Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=238873&r1=238872&r2=238873&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Tue Jun 2 16:57:51 2015
@@ -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"
More information about the cfe-commits
mailing list