Attach colon to constructor header and break line before member initializers

This commit is contained in:
Peter Vingelmann 2016-09-14 03:46:07 +02:00
parent 1bad21fe6b
commit 91bff90bf2

View File

@ -1209,52 +1209,6 @@ string ASFormatter::nextLine()
}
} // (isPotentialHeader && !isInTemplate)
if (isInLineBreak) // OK to break line here
{
breakLine();
if (isInVirginLine) // adjust for the first line
{
lineCommentNoBeautify = lineCommentNoIndent;
lineCommentNoIndent = false;
if (isImmediatelyPostPreprocessor)
{
isInIndentablePreproc = isIndentableProprocessor;
isIndentableProprocessor = false;
}
}
}
if (previousNonWSChar == '}' || currentChar == ';')
{
if (currentChar == ';')
{
squareBracketCount = 0;
if (((shouldBreakOneLineStatements
|| isBracketType(bracketTypeStack->back(), SINGLE_LINE_TYPE))
&& isOkToBreakBlock(bracketTypeStack->back()))
&& !(attachClosingBracketMode && peekNextChar() == '}'))
{
passedSemicolon = true;
}
// append post block empty line for unbracketed header
if (shouldBreakBlocks
&& currentHeader != NULL
&& currentHeader != &AS_CASE
&& currentHeader != &AS_DEFAULT
&& !isHeaderInMultiStatementLine
&& parenStack->back() == 0)
{
isAppendPostBlockEmptyLineRequested = true;
}
}
if (currentChar != ';'
|| (needHeaderOpeningBracket && parenStack->back() == 0))
currentHeader = NULL;
resetEndOfStatement();
}
if (currentChar == ':'
&& previousChar != ':' // not part of '::'
&& peekNextChar() != ':') // not part of '::'
@ -1299,7 +1253,64 @@ string ASFormatter::nextLine()
}
if (isClassInitializer())
{
isInClassInitializer = true;
if (!isCharImmediatelyPostComment && !isCharImmediatelyPostLineComment)
{
// Attach colon to the constructor header and force a
// new line before the member initializer list
appendSpacePad();
appendCurrentChar(false);
shouldBreakLineAtNextChar = true;
continue;
}
}
}
if (isInLineBreak) // OK to break line here
{
breakLine();
if (isInVirginLine) // adjust for the first line
{
lineCommentNoBeautify = lineCommentNoIndent;
lineCommentNoIndent = false;
if (isImmediatelyPostPreprocessor)
{
isInIndentablePreproc = isIndentableProprocessor;
isIndentableProprocessor = false;
}
}
}
if (previousNonWSChar == '}' || currentChar == ';')
{
if (currentChar == ';')
{
squareBracketCount = 0;
if (((shouldBreakOneLineStatements
|| isBracketType(bracketTypeStack->back(), SINGLE_LINE_TYPE))
&& isOkToBreakBlock(bracketTypeStack->back()))
&& !(attachClosingBracketMode && peekNextChar() == '}'))
{
passedSemicolon = true;
}
// append post block empty line for unbracketed header
if (shouldBreakBlocks
&& currentHeader != NULL
&& currentHeader != &AS_CASE
&& currentHeader != &AS_DEFAULT
&& !isHeaderInMultiStatementLine
&& parenStack->back() == 0)
{
isAppendPostBlockEmptyLineRequested = true;
}
}
if (currentChar != ';'
|| (needHeaderOpeningBracket && parenStack->back() == 0))
currentHeader = NULL;
resetEndOfStatement();
}
if (currentChar == '?')