Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit 885f5fc

Browse files
committed
clang-format: [JS] Fix regression of detecting array literals.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@238832 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 792a51f commit 885f5fc

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/Format/TokenAnnotator.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,9 @@ class AnnotatingParser {
278278
} else if (Style.Language == FormatStyle::LK_JavaScript && Parent &&
279279
Parent->isOneOf(tok::l_brace, tok::comma)) {
280280
Left->Type = TT_JsComputedPropertyName;
281-
} else if (Parent && Parent->isOneOf(tok::at, tok::equal, tok::comma)) {
281+
} else if (Parent &&
282+
Parent->isOneOf(tok::at, tok::equal, tok::comma,
283+
tok::l_paren)) {
282284
Left->Type = TT_ArrayInitializerLSquare;
283285
} else {
284286
BindingIncrease = 10;

unittests/Format/FormatTestJS.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,11 @@ TEST_F(FormatTestJS, ArrayLiterals) {
252252
" new SomeThingAAAAAAAAAAAA(),\n"
253253
" new SomeThingBBBBBBBBB()\n"
254254
"];");
255+
verifyFormat("var someVariable = SomeFuntion([\n"
256+
" aaaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
257+
" bbbbbbbbbbbbbbbbbbbbbbbbbbb,\n"
258+
" ccccccccccccccccccccccccccc\n"
259+
"]);");
255260
}
256261

257262
TEST_F(FormatTestJS, FunctionLiterals) {

0 commit comments

Comments
 (0)