forked from OSchip/llvm-project
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:
parent
d78c422378
commit
c0126864a0
|
@ -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;
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue