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

Method formatArrayBrackets

astyle/src/ASFormatter.cpp:4123–4288  ·  view source on GitHub ↗

* format array brackets as attached or broken * determine if the brackets can have an inStatement indent * currentChar contains the bracket * the brackets will be appended to the current formattedLine or a new formattedLine as necessary * the calling function should have a continue statement after calling this method * * @param bracketType the type of bracket to be formatted, must

Source from the content-addressed store, hash-verified

4121 * @param isOpeningArrayBracket indicates if this is the opening bracket for the array block.
4122 */
4123void ASFormatter::formatArrayBrackets(BracketType bracketType, bool isOpeningArrayBracket)
4124{
4125 assert(isBracketType(bracketType, ARRAY_TYPE));
4126 assert(currentChar == '{' || currentChar == '}');
4127
4128 if (currentChar == '{')
4129 {
4130 // is this the first opening bracket in the array?
4131 if (isOpeningArrayBracket)
4132 {
4133 if (bracketFormatMode == ATTACH_MODE
4134 || bracketFormatMode == LINUX_MODE
4135 || bracketFormatMode == STROUSTRUP_MODE)
4136 {
4137 // don't attach to a preprocessor directive or '\' line
4138 if ((isImmediatelyPostPreprocessor
4139 || (formattedLine.length() > 0
4140 && formattedLine[formattedLine.length() - 1] == '\\'))
4141 && currentLineBeginsWithBracket)
4142 {
4143 isInLineBreak = true;
4144 appendCurrentChar(); // don't attach
4145 }
4146 else if (isCharImmediatelyPostComment)
4147 {
4148 // TODO: attach bracket to line-end comment
4149 appendCurrentChar(); // don't attach
4150 }
4151 else if (isCharImmediatelyPostLineComment && !isBracketType(bracketType, SINGLE_LINE_TYPE))
4152 {
4153 appendCharInsideComments();
4154 }
4155 else
4156 {
4157 // if a blank line precedes this don't attach
4158 if (isEmptyLine(formattedLine))
4159 appendCurrentChar(); // don't attach
4160 else
4161 {
4162 // if bracket is broken or not an assignment
4163 if (currentLineBeginsWithBracket
4164 && !isBracketType(bracketType, SINGLE_LINE_TYPE))
4165 {
4166 appendSpacePad();
4167 appendCurrentChar(false); // OK to attach
4168 // TODO: debug the following line
4169 testForTimeToSplitFormattedLine(); // line length will have changed
4170
4171 if (currentLineBeginsWithBracket
4172 && (int)currentLineFirstBracketNum == charNum)
4173 shouldBreakLineAtNextChar = true;
4174 }
4175 else
4176 {
4177 if (previousNonWSChar != '(')
4178 appendSpacePad();
4179 appendCurrentChar();
4180 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected