State.VariablePos = 0;
State.LineContainsContinuedForLoopSection = false;
State.ParenLevel = 0;
+ State.StartOfLineLevel = State.ParenLevel;
DEBUG({
DebugTokenState(*State.NextToken);
/// \brief The level of nesting inside (), [], <> and {}.
unsigned ParenLevel;
+ /// \brief The \c ParenLevel at the start of this line.
+ unsigned StartOfLineLevel;
+
/// \brief A stack keeping track of properties applying to parenthesis
/// levels.
std::vector<ParenState> Stack;
return LineContainsContinuedForLoopSection;
if (Other.ParenLevel != ParenLevel)
return Other.ParenLevel < ParenLevel;
+ if (Other.StartOfLineLevel < StartOfLineLevel)
+ return Other.StartOfLineLevel < StartOfLineLevel;
return Other.Stack < Stack;
}
};
}
State.Stack.back().LastSpace = State.Column;
+ State.StartOfLineLevel = State.ParenLevel;
if (Current.is(tok::colon) && Current.Type != TT_ConditionalExpr)
State.Stack.back().Indent += 2;
} else {
!(State.NextToken->is(tok::r_brace) &&
State.Stack.back().BreakBeforeClosingBrace))
return false;
+ // This prevents breaks like:
+ // ...
+ // SomeParameter, OtherParameter).DoSomething(
+ // ...
+ // As they hide "DoSomething" and generally bad for readability.
+ if (State.NextToken->Parent->is(tok::l_paren) &&
+ State.ParenLevel <= State.StartOfLineLevel)
+ return false;
// Trying to insert a parameter on a new line if there are already more than
// one parameter on the current line is bin packing.
if (State.Stack.back().HasMultiParameterLine &&
verifyFormat("SomeMap[std::pair(aaaaaaaaaaaa, bbbbbbbbbbbbbbb)]\n"
" .insert(ccccccccccccccccccccccc);");
+ verifyGoogleFormat(
+ "aaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaa)\n"
+ " .aaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaa)\n"
+ " .aaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaa,\n"
+ " aaaaaaaaaaaaaaaaaaa,\n"
+ " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);");
+
// Here, it is not necessary to wrap at "." or "->".
verifyFormat("if (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaa) ||\n"
" aaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {\n}");