MCPcopy Create free account
hub / github.com/dirkvranckaert/AndroidDecompiler / isLineBreakBeforeClosingHeader

Method isLineBreakBeforeClosingHeader

astyle/src/ASFormatter.cpp:5203–5260  ·  view source on GitHub ↗

* check if a line break is needed when a closing bracket * is followed by a closing header. * the break depends on the bracketFormatMode and other factors. */

Source from the content-addressed store, hash-verified

5201 * the break depends on the bracketFormatMode and other factors.
5202 */
5203void ASFormatter::isLineBreakBeforeClosingHeader()
5204{
5205 assert(foundClosingHeader && previousNonWSChar == '}');
5206 if (bracketFormatMode == BREAK_MODE
5207 || bracketFormatMode == RUN_IN_MODE
5208 || shouldAttachClosingBracket)
5209 {
5210 isInLineBreak = true;
5211 }
5212 else if (bracketFormatMode == NONE_MODE)
5213 {
5214 if (shouldBreakClosingHeaderBrackets
5215 || getBracketIndent() || getBlockIndent())
5216 {
5217 isInLineBreak = true;
5218 }
5219 else
5220 {
5221 appendSpacePad();
5222 // is closing bracket broken?
5223 size_t i = currentLine.find_first_not_of(" \t");
5224 if (i != string::npos && currentLine[i] == '}')
5225 isInLineBreak = false;
5226
5227 if (shouldBreakBlocks)
5228 isAppendPostBlockEmptyLineRequested = false;
5229 }
5230 }
5231 // bracketFormatMode == ATTACH_MODE, LINUX_MODE, STROUSTRUP_MODE
5232 else
5233 {
5234 if (shouldBreakClosingHeaderBrackets
5235 || getBracketIndent() || getBlockIndent())
5236 {
5237 isInLineBreak = true;
5238 }
5239 else
5240 {
5241 // if a blank line does not precede this
5242 // or last line is not a one line block, attach header
5243 bool previousLineIsEmpty = isEmptyLine(formattedLine);
5244 int previousLineIsOneLineBlock = 0;
5245 size_t firstBracket = findNextChar(formattedLine, '{');
5246 if (firstBracket != string::npos)
5247 previousLineIsOneLineBlock = isOneLineBlockReached(formattedLine, firstBracket);
5248 if (!previousLineIsEmpty
5249 && previousLineIsOneLineBlock == 0)
5250 {
5251 isInLineBreak = false;
5252 appendSpacePad();
5253 spacePadNum = 0; // don't count as comment padding
5254 }
5255
5256 if (shouldBreakBlocks)
5257 isAppendPostBlockEmptyLineRequested = false;
5258 }
5259 }
5260}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected