clang-format: [Java] Understand string literal concatenation.

Before:
  String someString = "abc" + "cde";

After:
  String someString = "abc"
                      + "cde";

llvm-svn: 220287
This commit is contained in:
Daniel Jasper 2014-10-21 11:34:53 +00:00
parent d78c422378
commit c0126864a0
2 changed files with 8 additions and 0 deletions

View File

@ -1805,6 +1805,9 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line,
if (Left.Type == TT_JavaAnnotation && Right.isNot(tok::l_paren) && if (Left.Type == TT_JavaAnnotation && Right.isNot(tok::l_paren) &&
Line.Last->is(tok::l_brace)) Line.Last->is(tok::l_brace))
return true; return true;
if (Right.is(tok::plus) && Left.is(tok::string_literal) && Right.Next &&
Right.Next->is(tok::string_literal))
return true;
} }
return false; return false;

View File

@ -97,5 +97,10 @@ TEST_F(FormatTestJava, Generics) {
verifyFormat("A.<B>doSomething();"); verifyFormat("A.<B>doSomething();");
} }
TEST_F(FormatTestJava, StringConcatenation) {
verifyFormat("String someString = \"abc\"\n"
" + \"cde\";");
}
} // end namespace tooling } // end namespace tooling
} // end namespace clang } // end namespace clang