clang-format: [JS] Properly format dict literals that skip labels.

llvm-svn: 288121
This commit is contained in:
Daniel Jasper 2016-11-29 09:40:36 +00:00
parent 22ed262c23
commit e98e58111b
2 changed files with 10 additions and 0 deletions

View File

@ -442,6 +442,9 @@ private:
Style.Language == FormatStyle::LK_JavaScript)
Left->Type = TT_DictLiteral;
}
if (CurrentToken->is(tok::comma) &&
Style.Language == FormatStyle::LK_JavaScript)
Left->Type = TT_DictLiteral;
if (!consumeToken())
return false;
}

View File

@ -259,6 +259,13 @@ TEST_F(FormatTestJS, ContainerLiterals) {
" b: b,\n"
" 'c': c,\n"
"};");
// Dict literals can skip the label names.
verifyFormat("var x = {\n"
" aaa,\n"
" aaa,\n"
" aaa,\n"
"};");
}
TEST_F(FormatTestJS, MethodsInObjectLiterals) {