Modifies the input data, and replaces comments with whitespace when the line contains other data too. */
| 160 | Modifies the input data, and replaces comments with whitespace when the line contains other data too. |
| 161 | */ |
| 162 | void DefaultCommentParser::removeComment(QString &line) |
| 163 | { |
| 164 | if(isSkipable() || lastComment.startOffset == lastComment.endOffset) return; |
| 165 | |
| 166 | for(const CommentRange &range : comments) |
| 167 | { |
| 168 | /* |
| 169 | assert isn't useful during auto testing as it causes the QTest not to show the actual line that |
| 170 | the test failed on. |
| 171 | */ |
| 172 | #ifndef AUTOTEST |
| 173 | assert(range.endOffset <= line.length() && range.startOffset <= line.length()); |
| 174 | assert(range.endOffset >= range.startOffset); |
| 175 | #else |
| 176 | if(range.endOffset > line.length() && range.startOffset > line.length()) return; |
| 177 | if(range.endOffset < range.startOffset) return; |
| 178 | #endif |
| 179 | qsizetype size = range.endOffset - range.startOffset; |
| 180 | line.replace(range.startOffset, size, QString(" ").repeated(size)); |
| 181 | } |
| 182 | } |