r238671 - clang-format: [JS] Fix line breaks in computed property names.
Daniel Jasper
djasper at google.com
Sun May 31 01:40:38 PDT 2015
Author: djasper
Date: Sun May 31 03:40:37 2015
New Revision: 238671
URL: http://llvm.org/viewvc/llvm-project?rev=238671&view=rev
Log:
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
};
Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp
Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=238671&r1=238670&r2=238671&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Sun May 31 03:40:37 2015
@@ -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;
Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=238671&r1=238670&r2=238671&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Sun May 31 03:40:37 2015
@@ -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"
"};");
}
More information about the cfe-commits
mailing list