* Look ahead in the file to see if a struct has access modifiers. * * @param line a reference to the line to indent. * @param index the current line index. * @return true if the struct has access modifiers. */
| 5476 | * @return true if the struct has access modifiers. |
| 5477 | */ |
| 5478 | bool ASFormatter::isStructAccessModified(string &firstLine, size_t index) const |
| 5479 | { |
| 5480 | assert(firstLine[index] == '{'); |
| 5481 | assert(isCStyle()); |
| 5482 | |
| 5483 | bool isFirstLine = true; |
| 5484 | bool needReset = false; |
| 5485 | size_t bracketCount = 1; |
| 5486 | string nextLine_ = firstLine.substr(index + 1); |
| 5487 | |
| 5488 | // find the first non-blank text, bypassing all comments and quotes. |
| 5489 | bool isInComment_ = false; |
| 5490 | bool isInQuote_ = false; |
| 5491 | char quoteChar_ = ' '; |
| 5492 | while (sourceIterator->hasMoreLines() || isFirstLine) |
| 5493 | { |
| 5494 | if (isFirstLine) |
| 5495 | isFirstLine = false; |
| 5496 | else |
| 5497 | { |
| 5498 | nextLine_ = sourceIterator->peekNextLine(); |
| 5499 | needReset = true; |
| 5500 | } |
| 5501 | // parse the line |
| 5502 | for (size_t i = 0; i < nextLine_.length(); i++) |
| 5503 | { |
| 5504 | if (isWhiteSpace(nextLine_[i])) |
| 5505 | continue; |
| 5506 | if (nextLine_.compare(i, 2, "/*") == 0) |
| 5507 | isInComment_ = true; |
| 5508 | if (isInComment_) |
| 5509 | { |
| 5510 | if (nextLine_.compare(i, 2, "*/") == 0) |
| 5511 | { |
| 5512 | isInComment_ = false; |
| 5513 | ++i; |
| 5514 | } |
| 5515 | continue; |
| 5516 | } |
| 5517 | if (nextLine_[i] == '\\') |
| 5518 | { |
| 5519 | ++i; |
| 5520 | continue; |
| 5521 | } |
| 5522 | |
| 5523 | if (isInQuote_) |
| 5524 | { |
| 5525 | if (nextLine_[i] == quoteChar_) |
| 5526 | isInQuote_ = false; |
| 5527 | continue; |
| 5528 | } |
| 5529 | |
| 5530 | if (nextLine_[i] == '"' || nextLine_[i] == '\'') |
| 5531 | { |
| 5532 | isInQuote_ = true; |
| 5533 | quoteChar_ = nextLine_[i]; |
| 5534 | continue; |
| 5535 | } |
nothing calls this directly
no test coverage detected