clang-format: [JS] Fix line breaks in computed property names.

Before:
  let foo = {
    [someLongKeyHere]: 1,
    someOtherLongKeyHere: 2, [keyLongEnoughToWrap]: 3,
    lastLongKey: 4
  };

After:
  let foo = {
    [someLongKeyHere]: 1,
    someOtherLongKeyHere: 2,
    [keyLongEnoughToWrap]: 3,
    lastLongKey: 4
  };

llvm-svn: 238671
This commit is contained in:
Daniel Jasper 2015-05-31 08:40:37 +00:00
parent aa47cf9dae
commit cd8d4ff985
2 changed files with 4 additions and 1 deletions

View File

@ -1321,7 +1321,7 @@ private:
else if (Current->is(TT_LambdaArrow))
return prec::Comma;
else if (Current->isOneOf(tok::semi, TT_InlineASMColon,
TT_SelectorName) ||
TT_SelectorName, TT_JsComputedPropertyName) ||
(Current->is(tok::comment) && NextNonComment &&
NextNonComment->is(TT_SelectorName)))
return 0;

View File

@ -153,8 +153,11 @@ TEST_F(FormatTestJS, ContainerLiterals) {
verifyFormat("var x = {y: (a) => a};");
// Computed keys.
verifyFormat("var x = {[a]: 1, b: 2, [c]: 3};");
verifyFormat("var x = {\n"
" [a]: 1,\n"
" b: 2,\n"
" [c]: 3,\n"
"};");
}