forked from OSchip/llvm-project
clang-format: [JS] Properly format dict literals that skip labels.
llvm-svn: 288121
This commit is contained in:
parent
22ed262c23
commit
e98e58111b
|
@ -442,6 +442,9 @@ private:
|
||||||
Style.Language == FormatStyle::LK_JavaScript)
|
Style.Language == FormatStyle::LK_JavaScript)
|
||||||
Left->Type = TT_DictLiteral;
|
Left->Type = TT_DictLiteral;
|
||||||
}
|
}
|
||||||
|
if (CurrentToken->is(tok::comma) &&
|
||||||
|
Style.Language == FormatStyle::LK_JavaScript)
|
||||||
|
Left->Type = TT_DictLiteral;
|
||||||
if (!consumeToken())
|
if (!consumeToken())
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -259,6 +259,13 @@ TEST_F(FormatTestJS, ContainerLiterals) {
|
||||||
" b: b,\n"
|
" b: b,\n"
|
||||||
" 'c': c,\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) {
|
TEST_F(FormatTestJS, MethodsInObjectLiterals) {
|
||||||
|
|
Loading…
Reference in New Issue