MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / commentAndHeaderFollows

Method commentAndHeaderFollows

other_src/astyle/src/ASFormatter.cpp:3781–3817  ·  view source on GitHub ↗

* determine if the next line starts a comment * and a header follows the comment or comments. */

Source from the content-addressed store, hash-verified

3779 * and a header follows the comment or comments.
3780 */
3781bool ASFormatter::commentAndHeaderFollows()
3782{
3783 // called ONLY IF shouldDeleteEmptyLines and shouldBreakBlocks are TRUE.
3784 assert(shouldDeleteEmptyLines && shouldBreakBlocks);
3785
3786 // is the next line a comment
3787 if (!sourceIterator->hasMoreLines())
3788 return false;
3789 string nextLine_ = sourceIterator->peekNextLine();
3790 size_t firstChar = nextLine_.find_first_not_of(" \t");
3791 if (firstChar == string::npos
3792 || !(nextLine_.compare(firstChar, 2, "//") == 0
3793 || nextLine_.compare(firstChar, 2, "/*") == 0))
3794 {
3795 sourceIterator->peekReset();
3796 return false;
3797 }
3798
3799 // find the next non-comment text, and reset
3800 string nextText = peekNextText(nextLine_, false, true);
3801 if (nextText.length() == 0 || !isCharPotentialHeader(nextText, 0))
3802 return false;
3803
3804 const string* newHeader = ASBeautifier::findHeader(nextText, 0, headers);
3805
3806 if (newHeader == NULL)
3807 return false;
3808
3809 // if a closing header, reset break unless break is requested
3810 if (isClosingHeader(newHeader) && !shouldBreakClosingHeaderBlocks)
3811 {
3812 isAppendPostBlockEmptyLineRequested = false;
3813 return false;
3814 }
3815
3816 return true;
3817}
3818
3819/**
3820 * determine if a bracket should be attached or broken

Callers

nothing calls this directly

Calls 4

peekNextLineMethod · 0.80
peekResetMethod · 0.80
hasMoreLinesMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected