* format pointer or reference with align to type */
| 3351 | * format pointer or reference with align to type |
| 3352 | */ |
| 3353 | void ASFormatter::formatPointerOrReferenceToType() |
| 3354 | { |
| 3355 | assert(currentChar == '*' || currentChar == '&' || currentChar == '^'); |
| 3356 | assert(!isJavaStyle()); |
| 3357 | |
| 3358 | // do this before bumping charNum |
| 3359 | bool isOldPRCentered = isPointerOrReferenceCentered(); |
| 3360 | |
| 3361 | size_t prevCh = formattedLine.find_last_not_of(" \t"); |
| 3362 | if (prevCh == string::npos) |
| 3363 | prevCh = 0; |
| 3364 | if (formattedLine.length() == 0 || prevCh == formattedLine.length() - 1) |
| 3365 | formattedLine.append(1, currentChar); |
| 3366 | else |
| 3367 | { |
| 3368 | // exchange * or & with character following the type |
| 3369 | // this may not work every time with a tab character |
| 3370 | string charSave = formattedLine.substr(prevCh + 1, 1); |
| 3371 | formattedLine[prevCh + 1] = currentChar; |
| 3372 | formattedLine.append(charSave); |
| 3373 | } |
| 3374 | if (isSequenceReached("**") || isSequenceReached("&&")) |
| 3375 | { |
| 3376 | if (formattedLine.length() == 1) |
| 3377 | formattedLine.append(1, currentChar); |
| 3378 | else |
| 3379 | formattedLine.insert(prevCh + 2, 1, currentChar); |
| 3380 | goForward(1); |
| 3381 | } |
| 3382 | // if no space after then add one |
| 3383 | if (charNum < (int) currentLine.length() - 1 |
| 3384 | && !isWhiteSpace(currentLine[charNum + 1]) |
| 3385 | && currentLine[charNum + 1] != ')') |
| 3386 | appendSpacePad(); |
| 3387 | // if old pointer or reference is centered, remove a space |
| 3388 | if (isOldPRCentered |
| 3389 | && isWhiteSpace(formattedLine[formattedLine.length() - 1])) |
| 3390 | { |
| 3391 | formattedLine.erase(formattedLine.length() - 1, 1); |
| 3392 | spacePadNum--; |
| 3393 | } |
| 3394 | // update the formattedLine split point |
| 3395 | if (maxCodeLength != string::npos) |
| 3396 | { |
| 3397 | size_t index = formattedLine.length() - 1; |
| 3398 | if (isWhiteSpace(formattedLine[index])) |
| 3399 | { |
| 3400 | updateFormattedLineSplitPointsPointerOrReference(index); |
| 3401 | testForTimeToSplitFormattedLine(); |
| 3402 | } |
| 3403 | } |
| 3404 | } |
| 3405 | |
| 3406 | /** |
| 3407 | * format pointer or reference with align in the middle |
nothing calls this directly
no outgoing calls
no test coverage detected