clang-format: [JS] Array literal detection fix #3.

llvm-svn: 238839
This commit is contained in:
Daniel Jasper 2015-06-02 15:04:29 +00:00
parent 531063b274
commit 40432cee93
2 changed files with 5 additions and 2 deletions

View 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;

View 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"