MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / highlightBlock

Method highlightBlock

gui/codeeditor.cpp:218–248  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

216}
217
218void Highlighter::highlightBlock(const QString &text)
219{
220 for (const HighlightingRule &rule : utils::as_const(mHighlightingRulesWithSymbols)) {
221 QRegularExpressionMatchIterator matchIterator = rule.pattern.globalMatch(text);
222 while (matchIterator.hasNext()) {
223 QRegularExpressionMatch match = matchIterator.next();
224 setFormat(match.capturedStart(), match.capturedLength(), rule.format);
225 }
226 }
227
228 setCurrentBlockState(0);
229
230 int startIndex = 0;
231 if (previousBlockState() != 1)
232 startIndex = text.indexOf(mCommentStartExpression);
233
234 while (startIndex >= 0) {
235 QRegularExpressionMatch match = mCommentEndExpression.match(text, startIndex);
236 const int endIndex = match.capturedStart();
237 int commentLength = 0;
238 if (endIndex == -1) {
239 setCurrentBlockState(1);
240 commentLength = text.length() - startIndex;
241 } else {
242 commentLength = endIndex - startIndex
243 + match.capturedLength();
244 }
245 setFormat(startIndex, commentLength, mMultiLineCommentFormat);
246 startIndex = text.indexOf(mCommentStartExpression, startIndex + commentLength);
247 }
248}
249
250void Highlighter::applyFormat(HighlightingRule &rule) const
251{

Callers

nothing calls this directly

Calls 2

nextMethod · 0.80
matchMethod · 0.45

Tested by

no test coverage detected