MCPcopy Create free account
hub / github.com/KDE/kdiff3 / processLine

Method processLine

src/CommentParser.cpp:130–157  ·  view source on GitHub ↗

Find comments if any and set its pure comment flag if it has nothing but whitespace and comments. */

Source from the content-addressed store, hash-verified

128 Find comments if any and set its pure comment flag if it has nothing but whitespace and comments.
129*/
130void 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.

Callers 7

preprocessMethod · 0.80
singleLineCommentMethod · 0.80
multiLineCommentMethod · 0.80
stringTestMethod · 0.80
quotedCharacterMethod · 0.80
nonCommentMethod · 0.80
removeCommentMethod · 0.80

Calls 1

clearMethod · 0.45

Tested by

no test coverage detected