forked from OSchip/llvm-project
Improve formatting of builder-type calls.
Before: aaaaaaa->aaaaaaa->aaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)->aaaaaaaa(aaaaaaaaaaaaaaa); After: aaaaaaa->aaaaaaa ->aaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) ->aaaaaaaa(aaaaaaaaaaaaaaa); llvm-svn: 175441
This commit is contained in:
parent
55d7ba6b66
commit
9ed9ade0ef
|
@ -874,7 +874,7 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line,
|
|||
return 5;
|
||||
|
||||
if (Right.is(tok::arrow) || Right.is(tok::period)) {
|
||||
if (Left.is(tok::r_paren) && Line.Type == LT_BuilderTypeCall)
|
||||
if (Line.Type == LT_BuilderTypeCall)
|
||||
return 5; // Should be smaller than breaking at a nested comma.
|
||||
if ((Left.is(tok::r_paren) || Left.is(tok::r_square)) &&
|
||||
Left.MatchingParen && Left.MatchingParen->ParameterCount > 0)
|
||||
|
|
|
@ -1255,6 +1255,10 @@ TEST_F(FormatTest, FormatsBuilderPattern) {
|
|||
|
||||
verifyFormat("return aaaaaaaaaaaaaaaaa->aaaaa().aaaaaaaaaaaaa().aaaaaa() <\n"
|
||||
" aaaaaaaaaaaaaaaaaaa->aaaaa().aaaaaaaaaaaaa().aaaaaa();");
|
||||
verifyFormat(
|
||||
"aaaaaaa->aaaaaaa\n"
|
||||
" ->aaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)\n"
|
||||
" ->aaaaaaaa(aaaaaaaaaaaaaaa);");
|
||||
}
|
||||
|
||||
TEST_F(FormatTest, DoesNotBreakTrailingAnnotation) {
|
||||
|
|
Loading…
Reference in New Issue