if (Left->is(TT_Unknown)) {
if (StartsObjCMethodExpr) {
Left->Type = TT_ObjCMethodExpr;
+ } else if (Style.Language == FormatStyle::LK_JavaScript && Parent &&
+ Parent->isOneOf(tok::l_brace, tok::comma)) {
+ Left->Type = TT_JsComputedPropertyName;
} else if (Parent && Parent->isOneOf(tok::at, tok::equal, tok::comma)) {
Left->Type = TT_ArrayInitializerLSquare;
} else {
// Arrow functions in object literals.
verifyFormat("var x = {y: (a) => { return a; }};");
verifyFormat("var x = {y: (a) => a};");
+
+ // Computed keys.
+ verifyFormat("var x = {\n"
+ " [a]: 1,\n"
+ "};");
}
TEST_F(FormatTestJS, MethodsInObjectLiterals) {