Before:
var literal = 'hello ' + 'world';
After:
var literal = 'hello ' +
'world';
There is no reason to concatenated two string literals with a '+' unless
the line break is intended.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209413
91177308-0d34-0410-b5e6-
96231b3b80d8
BeforeClosingBrace->isOneOf(tok::comma, tok::comment))
return true;
+ if (Style.Language == FormatStyle::LK_JavaScript) {
+ // FIXME: This might apply to other languages and token kinds.
+ if (Right.is(tok::char_constant) && Left.is(tok::plus) && Left.Previous &&
+ Left.Previous->is(tok::char_constant))
+ return true;
+ }
+
return false;
}
"}");
}
+TEST_F(FormatTestJS, StringLiteralConcatenation) {
+ verifyFormat("var literal = 'hello ' +\n"
+ " 'world';");
+}
+
TEST_F(FormatTestJS, RegexLiteralClassification) {
// Regex literals.
verifyFormat("var regex = /abc/;");