Attach colon to constructor header and break line before member initializers
This commit is contained in:
parent
1bad21fe6b
commit
91bff90bf2
@ -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 == '?')
|
||||
|
Loading…
x
Reference in New Issue
Block a user