* add or remove space padding to operators * currentChar contains the paren * the operators and necessary padding will be appended to formattedLine * the calling function should have a continue statement after calling this method * * @param *newOperator the operator to be padded */
| 3198 | * @param *newOperator the operator to be padded |
| 3199 | */ |
| 3200 | void ASFormatter::padOperators(const string* newOperator) |
| 3201 | { |
| 3202 | assert(shouldPadOperators); |
| 3203 | assert(newOperator != NULL); |
| 3204 | |
| 3205 | bool shouldPad = (newOperator != &AS_SCOPE_RESOLUTION |
| 3206 | && newOperator != &AS_PLUS_PLUS |
| 3207 | && newOperator != &AS_MINUS_MINUS |
| 3208 | && newOperator != &AS_NOT |
| 3209 | && newOperator != &AS_BIT_NOT |
| 3210 | && newOperator != &AS_ARROW |
| 3211 | && !(newOperator == &AS_COLON && !foundQuestionMark // objC methods |
| 3212 | && (isInObjCMethodDefinition || isInObjCInterface |
| 3213 | || isInObjCSelector || squareBracketCount)) |
| 3214 | && !(newOperator == &AS_MINUS && isInExponent()) |
| 3215 | && !((newOperator == &AS_PLUS || newOperator == &AS_MINUS) // check for unary plus or minus |
| 3216 | && (previousNonWSChar == '(' |
| 3217 | || previousNonWSChar == '[' |
| 3218 | || previousNonWSChar == '=' |
| 3219 | || previousNonWSChar == ',')) |
| 3220 | && !(newOperator == &AS_PLUS && isInExponent()) |
| 3221 | && !isCharImmediatelyPostOperator |
| 3222 | && !((newOperator == &AS_MULT || newOperator == &AS_BIT_AND || newOperator == &AS_AND) |
| 3223 | && isPointerOrReference()) |
| 3224 | && !(newOperator == &AS_MULT |
| 3225 | && (previousNonWSChar == '.' |
| 3226 | || previousNonWSChar == '>')) // check for -> |
| 3227 | && !((isInTemplate || isImmediatelyPostTemplate) |
| 3228 | && (newOperator == &AS_LS || newOperator == &AS_GR)) |
| 3229 | && !(newOperator == &AS_GCC_MIN_ASSIGN |
| 3230 | && ASBase::peekNextChar(currentLine, charNum + 1) == '>') |
| 3231 | && !(newOperator == &AS_GR && previousNonWSChar == '?') |
| 3232 | && !(newOperator == &AS_QUESTION // check for Java wildcard |
| 3233 | && (previousNonWSChar == '<' |
| 3234 | || ASBase::peekNextChar(currentLine, charNum) == '>' |
| 3235 | || ASBase::peekNextChar(currentLine, charNum) == '.')) |
| 3236 | && !isInCase |
| 3237 | && !isInAsm |
| 3238 | && !isInAsmOneLine |
| 3239 | && !isInAsmBlock |
| 3240 | ); |
| 3241 | |
| 3242 | // pad before operator |
| 3243 | if (shouldPad |
| 3244 | && !(newOperator == &AS_COLON |
| 3245 | && (!foundQuestionMark && !isInEnum) && currentHeader != &AS_FOR) |
| 3246 | && !(newOperator == &AS_QUESTION && isSharpStyle() // check for C# nullable type (e.g. int?) |
| 3247 | && currentLine.find(':', charNum + 1) == string::npos) |
| 3248 | ) |
| 3249 | appendSpacePad(); |
| 3250 | appendOperator(*newOperator); |
| 3251 | goForward(newOperator->length() - 1); |
| 3252 | |
| 3253 | currentChar = (*newOperator)[newOperator->length() - 1]; |
| 3254 | // pad after operator |
| 3255 | // but do not pad after a '-' that is a unary-minus. |
| 3256 | if (shouldPad |
| 3257 | && !isBeforeAnyComment() |
nothing calls this directly
no outgoing calls
no test coverage detected