Don't break string literals in Java and JavaScript.

The proper way to break string literals in these languages is by inserting a "+"
between parts which we don't support yet. So we disable string literal breaking
until then.

llvm-svn: 224120
This commit is contained in:
Alexander Kornienko 2014-12-12 13:03:22 +00:00
parent 384095e65c
commit ff2437fe84
2 changed files with 13 additions and 0 deletions

View File

@ -923,6 +923,12 @@ static bool getRawStringLiteralPrefixPostfix(StringRef Text, StringRef &Prefix,
unsigned ContinuationIndenter::breakProtrudingToken(const FormatToken &Current,
LineState &State,
bool DryRun) {
// FIXME: String literal breaking is currently disabled for Java and JS, as
// it requires strings to be merged using "+" which we don't support.
if (Style.Language == FormatStyle::LK_Java ||
Style.Language == FormatStyle::LK_JavaScript)
return 0;
// Don't break multi-line tokens other than block comments. Instead, just
// update the state.
if (Current.isNot(TT_BlockComment) && Current.IsMultiline)

View File

@ -418,5 +418,12 @@ TEST_F(FormatTestJava, FormatsLambdas) {
getStyleWithColumns(40));
}
TEST_F(FormatTestJava, BreaksStringLiterals) {
// FIXME: String literal breaking is currently disabled for Java and JS, as it
// requires strings to be merged using "+" which we don't support.
EXPECT_EQ("\"some text other\";",
format("\"some text other\";", getStyleWithColumns(14)));
}
} // end namespace tooling
} // end namespace clang