VCS: Refactor annotationChanges() in VcsBaseEditor

Devirtualize the function, and use QRegularExpression with globalMatch.

Change-Id: I18c92cb37b535c616f03f45dff8b18249c961d5d
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Orgad Shaneh
2020-02-19 23:23:36 +02:00
committed by Orgad Shaneh
parent 3cdbd8683d
commit 3c0b89f697
17 changed files with 54 additions and 160 deletions

View File

@@ -59,30 +59,7 @@ SubversionEditorWidget::SubversionEditorWidget() :
setDiffFilePattern(QRegExp(QLatin1String("^[-+]{3} ([^\\t]+)|^Index: .*|^=+$")));
setLogEntryPattern(QRegExp(QLatin1String("^(r\\d+) \\|")));
setAnnotateRevisionTextFormat(tr("Annotate revision \"%1\""));
}
QSet<QString> SubversionEditorWidget::annotationChanges() const
{
QSet<QString> changes;
const QString txt = toPlainText();
if (txt.isEmpty())
return changes;
// Hunt for first change number in annotation: "<change>:"
QRegExp r(QLatin1String("^(\\d+):"));
QTC_ASSERT(r.isValid(), return changes);
if (r.indexIn(txt) != -1) {
changes.insert(r.cap(1));
r.setPattern(QLatin1String("\n(\\d+):"));
QTC_ASSERT(r.isValid(), return changes);
int pos = 0;
while ((pos = r.indexIn(txt, pos)) != -1) {
pos += r.matchedLength();
changes.insert(r.cap(1));
}
}
if (Subversion::Constants::debug)
qDebug() << "SubversionEditor::annotationChanges() returns #" << changes.size();
return changes;
setAnnotationEntryPattern("^(\\d+):");
}
QString SubversionEditorWidget::changeUnderCursor(const QTextCursor &c) const