forked from OSchip/llvm-project
clang-format: [JS] Support ES6 exports of array literals.
Before: export default[aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb]; export default[]; After: export default [ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ]; export default []; llvm-svn: 256758
This commit is contained in:
parent
e705aadd67
commit
b14f6675da
|
@ -289,7 +289,9 @@ private:
|
|||
(Parent &&
|
||||
Parent->isOneOf(TT_BinaryOperator, tok::at, tok::comma,
|
||||
tok::l_paren, tok::l_square, tok::question,
|
||||
tok::colon, tok::kw_return))) {
|
||||
tok::colon, tok::kw_return,
|
||||
// Should only be relevant to JavaScript:
|
||||
tok::kw_default))) {
|
||||
Left->Type = TT_ArrayInitializerLSquare;
|
||||
} else {
|
||||
BindingIncrease = 10;
|
||||
|
@ -1999,6 +2001,8 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
|
|||
if (Left.isOneOf(Keywords.kw_let, Keywords.kw_var, TT_JsFatArrow,
|
||||
Keywords.kw_in))
|
||||
return true;
|
||||
if (Left.is(tok::kw_default) && Right.is(TT_ArrayInitializerLSquare))
|
||||
return true; // For "export default [];".
|
||||
if (Left.is(Keywords.kw_is) && Right.is(tok::l_brace))
|
||||
return true;
|
||||
if (Right.isOneOf(TT_JsTypeColon, TT_JsTypeOptionalQuestion))
|
||||
|
|
|
@ -865,6 +865,11 @@ TEST_F(FormatTestJS, Modules) {
|
|||
" // adsdasd\n"
|
||||
" BAZ\n"
|
||||
"}");
|
||||
verifyFormat("export default [\n"
|
||||
" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
|
||||
" bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\n"
|
||||
"];");
|
||||
verifyFormat("export default [];");
|
||||
}
|
||||
|
||||
TEST_F(FormatTestJS, TemplateStrings) {
|
||||
|
|
Loading…
Reference in New Issue