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

Commit

Permalink
clang-format: [JS] Array literal detection fix #3.
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@238839 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
djasper-gh committed Jun 2, 2015
1 parent d6d2cf1 commit 9969cae
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/Format/TokenAnnotator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,8 @@ class AnnotatingParser {
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;
Expand Down
3 changes: 3 additions & 0 deletions unittests/Format/FormatTestJS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 9969cae

Please sign in to comment.