Find comments if any and set its pure comment flag if it has nothing but whitespace and comments. */
| 128 | Find comments if any and set its pure comment flag if it has nothing but whitespace and comments. |
| 129 | */ |
| 130 | void DefaultCommentParser::processLine(const QString &line) |
| 131 | { |
| 132 | static const QRegularExpression nonWhiteRegexp = QRegularExpression("[\\S]", QRegularExpression::UseUnicodePropertiesOption); |
| 133 | static const QRegularExpression tailRegexp = QRegularExpression("\\s+$", QRegularExpression::UseUnicodePropertiesOption); |
| 134 | offset = line.indexOf(nonWhiteRegexp); |
| 135 | const qsizetype trailIndex = line.lastIndexOf(tailRegexp); |
| 136 | |
| 137 | lastComment.startOffset = lastComment.endOffset = 0; //reset these for each line |
| 138 | comments.clear(); |
| 139 | |
| 140 | //remove trailing and ending spaces. |
| 141 | const QString trimmedLine = line.trimmed(); |
| 142 | |
| 143 | for(const QChar &c : trimmedLine) |
| 144 | { |
| 145 | processChar(trimmedLine, c); |
| 146 | } |
| 147 | /* |
| 148 | Line has trailing space after multi-line comment ended. |
| 149 | */ |
| 150 | if(trailIndex != -1 && !inComment()) |
| 151 | { |
| 152 | mIsPureComment = false; |
| 153 | } |
| 154 | |
| 155 | //mIsPureComment = mIsPureComment && offset == 0; |
| 156 | processChar(trimmedLine, '\n'); |
| 157 | } |
| 158 | |
| 159 | /* |
| 160 | Modifies the input data, and replaces comments with whitespace when the line contains other data too. |
no test coverage detected