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] Fix another regression when detecting array literals.
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@238835 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
djasper-gh committed Jun 2, 2015
1 parent 885f5fc commit d6d2cf1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/Format/TokenAnnotator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,12 @@ class AnnotatingParser {
if (StartsObjCMethodExpr) {
Left->Type = TT_ObjCMethodExpr;
} else if (Style.Language == FormatStyle::LK_JavaScript && Parent &&
Contexts.back().ContextKind == tok::l_brace &&
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::l_paren, tok::question, tok::colon)) {
Left->Type = TT_ArrayInitializerLSquare;
} else {
BindingIncrease = 10;
Expand Down
5 changes: 5 additions & 0 deletions unittests/Format/FormatTestJS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,11 @@ TEST_F(FormatTestJS, ArrayLiterals) {
" bbbbbbbbbbbbbbbbbbbbbbbbbbb,\n"
" ccccccccccccccccccccccccccc\n"
"]);");
verifyFormat("var someVariable = SomeFuntion(aaaa, [\n"
" aaaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
" bbbbbbbbbbbbbbbbbbbbbbbbbbb,\n"
" ccccccccccccccccccccccccccc\n"
"]);");
}

TEST_F(FormatTestJS, FunctionLiterals) {
Expand Down

0 comments on commit d6d2cf1

Please sign in to comment.