if (Right.is(tok::plus) && Left.is(tok::string_literal) && Right.Next &&
Right.Next->is(tok::string_literal))
return true;
+ } else if (Style.Language == FormatStyle::LK_Cpp ||
+ Style.Language == FormatStyle::LK_ObjC) {
+ if (Left.isStringLiteral() &&
+ (Right.isStringLiteral() || Right.is(TT_ObjCStringLiteral)))
+ return true;
}
// If the last token before a '}' is a comma or a trailing comment, the
(Right.NewlinesBefore > 0 && Right.HasUnescapedNewline);
if (Left.isTrailingComment())
return true;
- if (Left.isStringLiteral() &&
- (Right.isStringLiteral() || Right.is(TT_ObjCStringLiteral)))
- return true;
if (Right.Previous->IsUnterminatedLiteral)
return true;
if (Right.is(tok::lessless) && Right.Next &&
"var y;");
// Escaped dollar.
verifyFormat("var x = ` \\${foo}`;\n");
+
+ // The token stream can contain two string_literals in sequence, but that
+ // doesn't mean that they are implicitly concatenated in JavaScript.
+ verifyFormat("var f = `aaaa ${a ? 'a' : 'b'}`;");
}
TEST_F(FormatTestJS, TemplateStringASI) {