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

Method formatClosingBracket

astyle/src/ASFormatter.cpp:4043–4111  ·  view source on GitHub ↗

* format closing bracket * currentChar contains the bracket * the calling function should have a continue statement after calling this method * * @param bracketType the type of the opening bracket for this closing bracket. */

Source from the content-addressed store, hash-verified

4041 * @param bracketType the type of the opening bracket for this closing bracket.
4042 */
4043void ASFormatter::formatClosingBracket(BracketType bracketType)
4044{
4045 assert(!isBracketType(bracketType, ARRAY_TYPE));
4046 assert(currentChar == '}');
4047
4048 // parenStack must contain one entry
4049 if (parenStack->size() > 1)
4050 parenStack->pop_back();
4051
4052 // mark state of immediately after empty block
4053 // this state will be used for locating brackets that appear immediately AFTER an empty block (e.g. '{} \n}').
4054 if (previousCommandChar == '{')
4055 isImmediatelyPostEmptyBlock = true;
4056
4057 if (shouldAttachClosingBracket)
4058 {
4059 // for now, namespaces and classes will be attached. Uncomment the lines below to break.
4060 if ((isEmptyLine(formattedLine) // if a blank line precedes this
4061 || isCharImmediatelyPostLineComment
4062 || isCharImmediatelyPostComment
4063 || (isImmediatelyPostPreprocessor && (int) currentLine.find_first_not_of(" \t") == charNum)
4064// || (isBracketType(bracketType, CLASS_TYPE) && isOkToBreakBlock(bracketType) && previousNonWSChar != '{')
4065// || (isBracketType(bracketType, NAMESPACE_TYPE) && isOkToBreakBlock(bracketType) && previousNonWSChar != '{')
4066 )
4067 && (!isBracketType(bracketType, SINGLE_LINE_TYPE) || isOkToBreakBlock(bracketType)))
4068 {
4069 breakLine();
4070 appendCurrentChar(); // don't attach
4071 }
4072 else
4073 {
4074 if (previousNonWSChar != '{'
4075 && (!isBracketType(bracketType, SINGLE_LINE_TYPE) || isOkToBreakBlock(bracketType)))
4076 appendSpacePad();
4077 appendCurrentChar(false); // attach
4078 }
4079 }
4080 else if ((!(previousCommandChar == '{' && isPreviousBracketBlockRelated)) // this '}' does not close an empty block
4081 && isOkToBreakBlock(bracketType)) // astyle is allowed to break one line blocks
4082 {
4083 breakLine();
4084 appendCurrentChar();
4085 }
4086 else
4087 {
4088 appendCurrentChar();
4089 }
4090
4091 // if a declaration follows a definition, space pad
4092 if (isLegalNameChar(peekNextChar()))
4093 appendSpaceAfter();
4094
4095 if (shouldBreakBlocks
4096 && currentHeader != NULL
4097 && !isHeaderInMultiStatementLine
4098 && parenStack->back() == 0)
4099 {
4100 if (currentHeader == &AS_CASE || currentHeader == &AS_DEFAULT)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected