MCPcopy Create free account
hub / github.com/dirkvranckaert/AndroidDecompiler / peekNextText

Method peekNextText

astyle/src/ASFormatter.cpp:3043–3102  ·  view source on GitHub ↗

* get the next non-whitespace substring on following lines, bypassing all comments. * * @param the first line to check * @return the next non-whitespace substring. */

Source from the content-addressed store, hash-verified

3041 * @return the next non-whitespace substring.
3042 */
3043string ASFormatter::peekNextText(const string &firstLine, bool endOnEmptyLine /*false*/, bool shouldReset /*false*/) const
3044{
3045 bool isFirstLine = true;
3046 bool needReset = shouldReset;
3047 string nextLine_ = firstLine;
3048 size_t firstChar = string::npos;
3049
3050 // find the first non-blank text, bypassing all comments.
3051 bool isInComment_ = false;
3052 while (sourceIterator->hasMoreLines() || isFirstLine)
3053 {
3054 if (isFirstLine)
3055 isFirstLine = false;
3056 else
3057 {
3058 nextLine_ = sourceIterator->peekNextLine();
3059 needReset = true;
3060 }
3061
3062 firstChar = nextLine_.find_first_not_of(" \t");
3063 if (firstChar == string::npos)
3064 {
3065 if (endOnEmptyLine && !isInComment_)
3066 break;
3067 continue;
3068 }
3069
3070 if (nextLine_.compare(firstChar, 2, "/*") == 0)
3071 {
3072 firstChar += 2;
3073 isInComment_ = true;
3074 }
3075
3076 if (isInComment_)
3077 {
3078 firstChar = nextLine_.find("*/", firstChar);
3079 if (firstChar == string::npos)
3080 continue;
3081 firstChar += 2;
3082 isInComment_ = false;
3083 firstChar = nextLine_.find_first_not_of(" \t", firstChar);
3084 if (firstChar == string::npos)
3085 continue;
3086 }
3087
3088 if (nextLine_.compare(firstChar, 2, "//") == 0)
3089 continue;
3090
3091 // found the next text
3092 break;
3093 }
3094
3095 if (firstChar == string::npos)
3096 nextLine_ = "";
3097 else
3098 nextLine_ = nextLine_.substr(firstChar);
3099 if (needReset)
3100 sourceIterator->peekReset();

Callers

nothing calls this directly

Calls 3

peekNextLineMethod · 0.80
peekResetMethod · 0.80
hasMoreLinesMethod · 0.45

Tested by

no test coverage detected