* determine if the next line starts a comment * and a header follows the comment or comments. */
| 4597 | * and a header follows the comment or comments. |
| 4598 | */ |
| 4599 | bool ASFormatter::commentAndHeaderFollows() |
| 4600 | { |
| 4601 | // called ONLY IF shouldDeleteEmptyLines and shouldBreakBlocks are TRUE. |
| 4602 | assert(shouldDeleteEmptyLines && shouldBreakBlocks); |
| 4603 | |
| 4604 | // is the next line a comment |
| 4605 | if (!sourceIterator->hasMoreLines()) |
| 4606 | return false; |
| 4607 | string nextLine_ = sourceIterator->peekNextLine(); |
| 4608 | size_t firstChar = nextLine_.find_first_not_of(" \t"); |
| 4609 | if (firstChar == string::npos |
| 4610 | || !(nextLine_.compare(firstChar, 2, "//") == 0 |
| 4611 | || nextLine_.compare(firstChar, 2, "/*") == 0)) |
| 4612 | { |
| 4613 | sourceIterator->peekReset(); |
| 4614 | return false; |
| 4615 | } |
| 4616 | |
| 4617 | // find the next non-comment text, and reset |
| 4618 | string nextText = peekNextText(nextLine_, false, true); |
| 4619 | if (nextText.length() == 0 || !isCharPotentialHeader(nextText, 0)) |
| 4620 | return false; |
| 4621 | |
| 4622 | const string* newHeader = ASBeautifier::findHeader(nextText, 0, headers); |
| 4623 | |
| 4624 | if (newHeader == NULL) |
| 4625 | return false; |
| 4626 | |
| 4627 | // if a closing header, reset break unless break is requested |
| 4628 | if (isClosingHeader(newHeader) && !shouldBreakClosingHeaderBlocks) |
| 4629 | { |
| 4630 | isAppendPostBlockEmptyLineRequested = false; |
| 4631 | return false; |
| 4632 | } |
| 4633 | |
| 4634 | return true; |
| 4635 | } |
| 4636 | |
| 4637 | /** |
| 4638 | * determine if a bracket should be attached or broken |
nothing calls this directly
no test coverage detected