* determine if the next line starts a comment * and a header follows the comment or comments. */
| 5618 | * and a header follows the comment or comments. |
| 5619 | */ |
| 5620 | bool ASFormatter::commentAndHeaderFollows() |
| 5621 | { |
| 5622 | // called ONLY IF shouldDeleteEmptyLines and shouldBreakBlocks are TRUE. |
| 5623 | assert(shouldDeleteEmptyLines && shouldBreakBlocks); |
| 5624 | |
| 5625 | // is the next line a comment |
| 5626 | auto stream = make_shared<ASPeekStream>(sourceIterator); |
| 5627 | if (!stream->hasMoreLines()) |
| 5628 | return false; |
| 5629 | string nextLine_ = stream->peekNextLine(); |
| 5630 | size_t firstChar = nextLine_.find_first_not_of(" \t"); |
| 5631 | if (firstChar == string::npos |
| 5632 | || !(nextLine_.compare(firstChar, 2, "//") == 0 |
| 5633 | || nextLine_.compare(firstChar, 2, "/*") == 0)) |
| 5634 | return false; |
| 5635 | |
| 5636 | // find the next non-comment text, and reset |
| 5637 | string nextText = peekNextText(nextLine_, false, stream); |
| 5638 | if (nextText.length() == 0 || !isCharPotentialHeader(nextText, 0)) |
| 5639 | return false; |
| 5640 | |
| 5641 | const string* newHeader = ASBase::findHeader(nextText, 0, headers); |
| 5642 | |
| 5643 | if (newHeader == nullptr) |
| 5644 | return false; |
| 5645 | |
| 5646 | // if a closing header, reset break unless break is requested |
| 5647 | if (isClosingHeader(newHeader) && !shouldBreakClosingHeaderBlocks) |
| 5648 | { |
| 5649 | isAppendPostBlockEmptyLineRequested = false; |
| 5650 | return false; |
| 5651 | } |
| 5652 | |
| 5653 | return true; |
| 5654 | } |
| 5655 | |
| 5656 | /** |
| 5657 | * determine if a brace should be attached or broken |
nothing calls this directly
no test coverage detected