aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/plugins/bazaar/bazaareditor.cpp5
-rw-r--r--src/plugins/clearcase/clearcaseeditor.cpp11
-rw-r--r--src/plugins/clearcase/clearcaseeditor.h4
-rw-r--r--src/plugins/cvs/cvseditor.cpp20
-rw-r--r--src/plugins/cvs/cvseditor.h6
-rw-r--r--src/plugins/git/giteditor.cpp4
-rw-r--r--src/plugins/git/gitplugin.cpp2
-rw-r--r--src/plugins/mercurial/mercurialeditor.cpp14
-rw-r--r--src/plugins/mercurial/mercurialeditor.h8
-rw-r--r--src/plugins/perforce/perforceeditor.cpp9
-rw-r--r--src/plugins/perforce/perforceeditor.h4
-rw-r--r--src/plugins/subversion/subversioneditor.cpp9
-rw-r--r--src/plugins/vcsbase/diffandloghighlighter.cpp18
-rw-r--r--src/plugins/vcsbase/diffandloghighlighter.h5
-rw-r--r--src/plugins/vcsbase/vcsbaseeditor.cpp71
-rw-r--r--src/plugins/vcsbase/vcsbaseeditor.h5
16 files changed, 102 insertions, 93 deletions
diff --git a/src/plugins/bazaar/bazaareditor.cpp b/src/plugins/bazaar/bazaareditor.cpp
index 671f396410..ac811b16aa 100644
--- a/src/plugins/bazaar/bazaareditor.cpp
+++ b/src/plugins/bazaar/bazaareditor.cpp
@@ -29,7 +29,6 @@
#include <utils/qtcassert.h>
-#include <QRegExp>
#include <QString>
#include <QTextCursor>
@@ -46,8 +45,8 @@ BazaarEditorWidget::BazaarEditorWidget() :
setAnnotatePreviousRevisionTextFormat(tr("Annotate &parent revision %1"));
// Diff format:
// === <change> <file|dir> 'mainwindow.cpp'
- setDiffFilePattern(QRegExp(QLatin1String("^=== [a-z]+ [a-z]+ '(.+)'\\s*")));
- setLogEntryPattern(QRegExp(QLatin1String("^revno: (\\d+)")));
+ setDiffFilePattern("^=== [a-z]+ [a-z]+ '(.+)'\\s*");
+ setLogEntryPattern("^revno: (\\d+)");
setAnnotationEntryPattern("^(" BZR_CHANGE_PATTERN ") ");
}
diff --git a/src/plugins/clearcase/clearcaseeditor.cpp b/src/plugins/clearcase/clearcaseeditor.cpp
index 341cc92ad8..3996d61617 100644
--- a/src/plugins/clearcase/clearcaseeditor.cpp
+++ b/src/plugins/clearcase/clearcaseeditor.cpp
@@ -47,10 +47,8 @@ ClearCaseEditorWidget::ClearCaseEditorWidget() :
// Diff formats:
// "+++ D:\depot\...\mainwindow.cpp@@\main\3" (versioned)
// "+++ D:\depot\...\mainwindow.cpp[TAB]Sun May 01 14:22:37 2011" (local)
- QRegExp diffFilePattern(QLatin1String("^[-+]{3} ([^\\t]+)(?:@@|\\t)"));
- diffFilePattern.setMinimal(true);
- setDiffFilePattern(diffFilePattern);
- setLogEntryPattern(QRegExp(QLatin1String("version \"([^\"]+)\"")));
+ setDiffFilePattern("^[-+]{3} ([^\\t]+?)(?:@@|\\t)");
+ setLogEntryPattern("version \"([^\"]+)\"");
setAnnotateRevisionTextFormat(tr("Annotate version \"%1\""));
setAnnotationEntryPattern("([^|]*)\\|[^\\n]*\\n");
setAnnotationSeparatorPattern("\\n-{30}");
@@ -66,8 +64,9 @@ QString ClearCaseEditorWidget::changeUnderCursor(const QTextCursor &c) const
QString change = cursor.selectedText();
// Annotation output has number, log output has revision numbers
// as r1, r2...
- if (m_versionNumberPattern.indexIn(change) != -1)
- return m_versionNumberPattern.cap();
+ const QRegularExpressionMatch match = m_versionNumberPattern.match(change);
+ if (match.hasMatch())
+ return match.captured();
return QString();
}
diff --git a/src/plugins/clearcase/clearcaseeditor.h b/src/plugins/clearcase/clearcaseeditor.h
index e97a6ecb22..3bab6b13a0 100644
--- a/src/plugins/clearcase/clearcaseeditor.h
+++ b/src/plugins/clearcase/clearcaseeditor.h
@@ -28,7 +28,7 @@
#include <vcsbase/vcsbaseeditor.h>
-#include <QRegExp>
+#include <QRegularExpression>
namespace ClearCase {
namespace Internal {
@@ -45,7 +45,7 @@ private:
VcsBase::BaseAnnotationHighlighter *createAnnotationHighlighter(
const QSet<QString> &changes) const override;
- QRegExp m_versionNumberPattern;
+ const QRegularExpression m_versionNumberPattern;
};
} // namespace Internal
diff --git a/src/plugins/cvs/cvseditor.cpp b/src/plugins/cvs/cvseditor.cpp
index 638945e4e3..8cdcd1e2f0 100644
--- a/src/plugins/cvs/cvseditor.cpp
+++ b/src/plugins/cvs/cvseditor.cpp
@@ -43,8 +43,8 @@ namespace Internal {
#define CVS_REVISION_AT_START_PATTERN "^(" CVS_REVISION_PATTERN ") "
CvsEditorWidget::CvsEditorWidget() :
- m_revisionAnnotationPattern(QLatin1String(CVS_REVISION_AT_START_PATTERN ".*$")),
- m_revisionLogPattern(QLatin1String("^revision *(" CVS_REVISION_PATTERN ")$"))
+ m_revisionAnnotationPattern(CVS_REVISION_AT_START_PATTERN),
+ m_revisionLogPattern("^revision *(" CVS_REVISION_PATTERN ")$")
{
QTC_ASSERT(m_revisionAnnotationPattern.isValid(), return);
QTC_ASSERT(m_revisionLogPattern.isValid(), return);
@@ -56,8 +56,8 @@ CvsEditorWidget::CvsEditorWidget() :
@@ -6,6 +6,5 @@
\endcode
*/
- setDiffFilePattern(QRegExp(QLatin1String("^[-+]{3} ([^\\t]+)")));
- setLogEntryPattern(QRegExp(QLatin1String("^revision (.+)$")));
+ setDiffFilePattern("^[-+]{3} ([^\\t]+)");
+ setLogEntryPattern("^revision (.+)$");
setAnnotateRevisionTextFormat(tr("Annotate revision \"%1\""));
setAnnotationEntryPattern("^(" CVS_REVISION_PATTERN ") ");
}
@@ -78,15 +78,19 @@ QString CvsEditorWidget::changeUnderCursor(const QTextCursor &c) const
const QTextBlock block = c.block();
if (c.atBlockStart() || (c.position() - block.position() < 3)) {
const QString line = block.text();
- if (m_revisionAnnotationPattern.exactMatch(line))
- return m_revisionAnnotationPattern.cap(1);
+ const QRegularExpressionMatch match = m_revisionAnnotationPattern.match(line);
+ if (match.hasMatch())
+ return match.captured(1);
}
}
break;
case VcsBase::LogOutput: {
const QTextBlock block = c.block();
- if (c.position() - block.position() > 8 && m_revisionLogPattern.exactMatch(block.text()))
- return m_revisionLogPattern.cap(1);
+ if (c.position() - block.position() > 8) {
+ const QRegularExpressionMatch match = m_revisionLogPattern.match(block.text());
+ if (match.hasMatch())
+ return match.captured(1);
+ }
}
break;
}
diff --git a/src/plugins/cvs/cvseditor.h b/src/plugins/cvs/cvseditor.h
index 83990d9bc3..b92ebeae32 100644
--- a/src/plugins/cvs/cvseditor.h
+++ b/src/plugins/cvs/cvseditor.h
@@ -27,7 +27,7 @@
#include <vcsbase/vcsbaseeditor.h>
-#include <QRegExp>
+#include <QRegularExpression>
namespace Cvs {
namespace Internal {
@@ -45,8 +45,8 @@ private:
const QSet<QString> &changes) const override;
QStringList annotationPreviousVersions(const QString &revision) const override;
- mutable QRegExp m_revisionAnnotationPattern;
- mutable QRegExp m_revisionLogPattern;
+ const QRegularExpression m_revisionAnnotationPattern;
+ const QRegularExpression m_revisionLogPattern;
QString m_diffBaseDir;
};
diff --git a/src/plugins/git/giteditor.cpp b/src/plugins/git/giteditor.cpp
index 4daa09aa62..2e2c3cb7c7 100644
--- a/src/plugins/git/giteditor.cpp
+++ b/src/plugins/git/giteditor.cpp
@@ -117,8 +117,8 @@ GitEditorWidget::GitEditorWidget() :
--- a/src/plugins/git/giteditor.cpp
+++ b/src/plugins/git/giteditor.cpp
*/
- setDiffFilePattern(QRegExp("^(?:diff --git a/|index |[+-]{3} (?:/dev/null|[ab]/(.+$)))"));
- setLogEntryPattern(QRegExp("^commit ([0-9a-f]{8})[0-9a-f]{32}"));
+ setDiffFilePattern("^(?:diff --git a/|index |[+-]{3} (?:/dev/null|[ab]/(.+$)))");
+ setLogEntryPattern("^commit ([0-9a-f]{8})[0-9a-f]{32}");
setAnnotateRevisionTextFormat(tr("&Blame %1"));
setAnnotatePreviousRevisionTextFormat(tr("Blame &Parent Revision %1"));
setAnnotationEntryPattern("^(" CHANGE_PATTERN ") ");
diff --git a/src/plugins/git/gitplugin.cpp b/src/plugins/git/gitplugin.cpp
index 3babb1e81d..54b8dbe999 100644
--- a/src/plugins/git/gitplugin.cpp
+++ b/src/plugins/git/gitplugin.cpp
@@ -132,7 +132,7 @@ class GitReflogEditorWidget : public GitEditorWidget
public:
GitReflogEditorWidget()
{
- setLogEntryPattern(QRegExp("^([0-9a-f]{8,}) [^}]*\\}: .*$"));
+ setLogEntryPattern("^([0-9a-f]{8,}) [^}]*\\}: .*$");
}
QString revisionSubject(const QTextBlock &inBlock) const override
diff --git a/src/plugins/mercurial/mercurialeditor.cpp b/src/plugins/mercurial/mercurialeditor.cpp
index 676f26ea8f..f5b6df2f1f 100644
--- a/src/plugins/mercurial/mercurialeditor.cpp
+++ b/src/plugins/mercurial/mercurialeditor.cpp
@@ -43,13 +43,13 @@ namespace Mercurial {
namespace Internal {
MercurialEditorWidget::MercurialEditorWidget(MercurialClient *client) :
- exactIdentifier12(QLatin1String(Constants::CHANGEIDEXACT12)),
- exactIdentifier40(QLatin1String(Constants::CHANGEIDEXACT40)),
- changesetIdentifier40(QLatin1String(Constants::CHANGESETID40)),
+ exactIdentifier12(QRegularExpression::anchoredPattern(Constants::CHANGEIDEXACT12)),
+ exactIdentifier40(QRegularExpression::anchoredPattern(Constants::CHANGEIDEXACT40)),
+ changesetIdentifier40(Constants::CHANGESETID40),
m_client(client)
{
- setDiffFilePattern(QRegExp(QLatin1String(Constants::DIFFIDENTIFIER)));
- setLogEntryPattern(QRegExp(QLatin1String("^changeset:\\s+(\\S+)$")));
+ setDiffFilePattern(Constants::DIFFIDENTIFIER);
+ setLogEntryPattern("^changeset:\\s+(\\S+)$");
setAnnotateRevisionTextFormat(tr("&Annotate %1"));
setAnnotatePreviousRevisionTextFormat(tr("Annotate &parent revision %1"));
setAnnotationEntryPattern(Constants::CHANGESETID12);
@@ -61,9 +61,9 @@ QString MercurialEditorWidget::changeUnderCursor(const QTextCursor &cursorIn) co
cursor.select(QTextCursor::WordUnderCursor);
if (cursor.hasSelection()) {
const QString change = cursor.selectedText();
- if (exactIdentifier12.exactMatch(change))
+ if (exactIdentifier12.match(change).hasMatch())
return change;
- if (exactIdentifier40.exactMatch(change))
+ if (exactIdentifier40.match(change).hasMatch())
return change;
}
return QString();
diff --git a/src/plugins/mercurial/mercurialeditor.h b/src/plugins/mercurial/mercurialeditor.h
index 868f84f535..40bf68854d 100644
--- a/src/plugins/mercurial/mercurialeditor.h
+++ b/src/plugins/mercurial/mercurialeditor.h
@@ -27,7 +27,7 @@
#include <vcsbase/vcsbaseeditor.h>
-#include <QRegExp>
+#include <QRegularExpression>
namespace Mercurial {
namespace Internal {
@@ -47,9 +47,9 @@ private:
QString decorateVersion(const QString &revision) const override;
QStringList annotationPreviousVersions(const QString &revision) const override;
- mutable QRegExp exactIdentifier12;
- mutable QRegExp exactIdentifier40;
- const QRegExp changesetIdentifier40;
+ const QRegularExpression exactIdentifier12;
+ const QRegularExpression exactIdentifier40;
+ const QRegularExpression changesetIdentifier40;
MercurialClient *m_client;
};
diff --git a/src/plugins/perforce/perforceeditor.cpp b/src/plugins/perforce/perforceeditor.cpp
index 82e7d166f2..4566efc357 100644
--- a/src/plugins/perforce/perforceeditor.cpp
+++ b/src/plugins/perforce/perforceeditor.cpp
@@ -35,7 +35,6 @@
#include <QDebug>
#include <QFileInfo>
#include <QProcess>
-#include <QRegExp>
#include <QSet>
#include <QTextStream>
@@ -52,7 +51,7 @@ namespace Internal {
// ------------ PerforceEditor
PerforceEditorWidget::PerforceEditorWidget() :
- m_changeNumberPattern(QLatin1String("^\\d+$"))
+ m_changeNumberPattern("^\\d+$")
{
QTC_CHECK(m_changeNumberPattern.isValid());
// Diff format:
@@ -60,8 +59,8 @@ PerforceEditorWidget::PerforceEditorWidget() :
// 2) "==== //depot/.../mainwindow.cpp#15 (text) ====" (created by p4 describe)
// 3) --- //depot/XXX/closingkit/trunk/source/cui/src/cui_core.cpp<tab>2012-02-08 13:54:01.000000000 0100
// +++ P:/XXX\closingkit\trunk\source\cui\src\cui_core.cpp<tab>2012-02-08 13:54:01.000000000 0100
- setDiffFilePattern(QRegExp(QLatin1String("^(?:={4}|\\+{3}) (.+)(?:\\t|#\\d)")));
- setLogEntryPattern(QRegExp(QLatin1String("^... #\\d change (\\d+) ")));
+ setDiffFilePattern("^(?:={4}|\\+{3}) (.+)(?:\\t|#\\d)");
+ setLogEntryPattern("^... #\\d change (\\d+) ");
setAnnotateRevisionTextFormat(tr("Annotate change list \"%1\""));
setAnnotationEntryPattern("^(\\d+):");
}
@@ -74,7 +73,7 @@ QString PerforceEditorWidget::changeUnderCursor(const QTextCursor &c) const
if (!cursor.hasSelection())
return QString();
const QString change = cursor.selectedText();
- return m_changeNumberPattern.exactMatch(change) ? change : QString();
+ return m_changeNumberPattern.match(change).hasMatch() ? change : QString();
}
VcsBase::BaseAnnotationHighlighter *PerforceEditorWidget::createAnnotationHighlighter(const QSet<QString> &changes) const
diff --git a/src/plugins/perforce/perforceeditor.h b/src/plugins/perforce/perforceeditor.h
index 92a9d23486..67e939f6e5 100644
--- a/src/plugins/perforce/perforceeditor.h
+++ b/src/plugins/perforce/perforceeditor.h
@@ -27,7 +27,7 @@
#include <vcsbase/vcsbaseeditor.h>
-#include <QRegExp>
+#include <QRegularExpression>
namespace Perforce {
namespace Internal {
@@ -46,7 +46,7 @@ private:
QString findDiffFile(const QString &f) const override;
QStringList annotationPreviousVersions(const QString &v) const override;
- mutable QRegExp m_changeNumberPattern;
+ const QRegularExpression m_changeNumberPattern;
};
} // namespace Perforce
diff --git a/src/plugins/subversion/subversioneditor.cpp b/src/plugins/subversion/subversioneditor.cpp
index 7ef6e08443..5b6b819615 100644
--- a/src/plugins/subversion/subversioneditor.cpp
+++ b/src/plugins/subversion/subversioneditor.cpp
@@ -34,7 +34,6 @@
#include <QDebug>
#include <QFileInfo>
-#include <QRegExp>
#include <QTextCursor>
#include <QTextBlock>
@@ -42,8 +41,8 @@ using namespace Subversion;
using namespace Subversion::Internal;
SubversionEditorWidget::SubversionEditorWidget() :
- m_changeNumberPattern(QLatin1String("^\\s*(?<area>(?<rev>\\d+))\\s+.*$")),
- m_revisionNumberPattern(QLatin1String("\\b(?<area>(r|[rR]evision )(?<rev>\\d+))\\b"))
+ m_changeNumberPattern("^\\s*(?<area>(?<rev>\\d+))\\s+.*$"),
+ m_revisionNumberPattern("\\b(?<area>(r|[rR]evision )(?<rev>\\d+))\\b")
{
QTC_ASSERT(m_changeNumberPattern.isValid(), return);
QTC_ASSERT(m_revisionNumberPattern.isValid(), return);
@@ -56,8 +55,8 @@ SubversionEditorWidget::SubversionEditorWidget() :
@@ -6,6 +6,5 @@
\endcode
*/
- setDiffFilePattern(QRegExp(QLatin1String("^[-+]{3} ([^\\t]+)|^Index: .*|^=+$")));
- setLogEntryPattern(QRegExp(QLatin1String("^(r\\d+) \\|")));
+ setDiffFilePattern("^[-+]{3} ([^\\t]+)|^Index: .*|^=+$");
+ setLogEntryPattern("^(r\\d+) \\|");
setAnnotateRevisionTextFormat(tr("Annotate revision \"%1\""));
setAnnotationEntryPattern("^(\\d+):");
}
diff --git a/src/plugins/vcsbase/diffandloghighlighter.cpp b/src/plugins/vcsbase/diffandloghighlighter.cpp
index afdc72cc67..a2f0836f35 100644
--- a/src/plugins/vcsbase/diffandloghighlighter.cpp
+++ b/src/plugins/vcsbase/diffandloghighlighter.cpp
@@ -30,7 +30,7 @@
#include <utils/qtcassert.h>
#include <QDebug>
-#include <QRegExp>
+#include <QRegularExpression>
/*!
\class VcsBase::DiffAndLogHighlighter
@@ -88,8 +88,9 @@ static inline QTextCharFormat invertedColorFormat(const QTextCharFormat &in)
class DiffAndLogHighlighterPrivate
{
public:
- DiffAndLogHighlighterPrivate(DiffAndLogHighlighter *q_, const QRegExp &filePattern,
- const QRegExp &changePattern) :
+ DiffAndLogHighlighterPrivate(DiffAndLogHighlighter *q_,
+ const QRegularExpression &filePattern,
+ const QRegularExpression &changePattern) :
q(q_),
m_filePattern(filePattern),
m_changePattern(changePattern),
@@ -106,8 +107,8 @@ public:
DiffAndLogHighlighter *const q;
- mutable QRegExp m_filePattern;
- mutable QRegExp m_changePattern;
+ const QRegularExpression m_filePattern;
+ const QRegularExpression m_changePattern;
const QString m_locationIndicator;
const QChar m_diffInIndicator;
const QChar m_diffOutIndicator;
@@ -120,9 +121,9 @@ TextEditor::TextStyle DiffAndLogHighlighterPrivate::analyzeLine(const QString &t
{
// Do not match on git "--- a/" as a deleted line, check
// file first
- if (m_filePattern.indexIn(text) == 0)
+ if (m_filePattern.match(text).capturedStart() == 0)
return TextEditor::C_DIFF_FILE;
- if (m_changePattern.indexIn(text) == 0)
+ if (m_changePattern.match(text).capturedStart() == 0)
return TextEditor::C_LOG_CHANGE_LINE;
if (text.startsWith(m_diffInIndicator))
return TextEditor::C_ADDED_LINE;
@@ -141,7 +142,8 @@ void DiffAndLogHighlighterPrivate::updateOtherFormats()
}
// --- DiffAndLogHighlighter
-DiffAndLogHighlighter::DiffAndLogHighlighter(const QRegExp &filePattern, const QRegExp &changePattern) :
+DiffAndLogHighlighter::DiffAndLogHighlighter(const QRegularExpression &filePattern,
+ const QRegularExpression &changePattern) :
TextEditor::SyntaxHighlighter(static_cast<QTextDocument *>(nullptr)),
d(new DiffAndLogHighlighterPrivate(this, filePattern, changePattern))
{
diff --git a/src/plugins/vcsbase/diffandloghighlighter.h b/src/plugins/vcsbase/diffandloghighlighter.h
index 3847f287ba..c43f4a510d 100644
--- a/src/plugins/vcsbase/diffandloghighlighter.h
+++ b/src/plugins/vcsbase/diffandloghighlighter.h
@@ -30,7 +30,7 @@
#include <texteditor/syntaxhighlighter.h>
QT_BEGIN_NAMESPACE
-class QRegExp;
+class QRegularExpression;
class QTextCharFormat;
QT_END_NAMESPACE
@@ -45,7 +45,8 @@ class VCSBASE_EXPORT DiffAndLogHighlighter : public TextEditor::SyntaxHighlighte
Q_OBJECT
public:
- explicit DiffAndLogHighlighter(const QRegExp &filePattern, const QRegExp &changePattern);
+ explicit DiffAndLogHighlighter(const QRegularExpression &filePattern,
+ const QRegularExpression &changePattern);
~DiffAndLogHighlighter() override;
void highlightBlock(const QString &text) override;
diff --git a/src/plugins/vcsbase/vcsbaseeditor.cpp b/src/plugins/vcsbase/vcsbaseeditor.cpp
index aae366dcb4..0c1e1eab24 100644
--- a/src/plugins/vcsbase/vcsbaseeditor.cpp
+++ b/src/plugins/vcsbase/vcsbaseeditor.cpp
@@ -51,7 +51,6 @@
#include <QFileInfo>
#include <QFile>
#include <QRegularExpression>
-#include <QRegExp>
#include <QSet>
#include <QTextCodec>
#include <QUrl>
@@ -403,7 +402,7 @@ private:
};
UrlData m_urlData;
- QRegExp m_pattern;
+ QRegularExpression m_pattern;
};
UrlTextCursorHandler::UrlTextCursorHandler(VcsBaseEditorWidget *editorWidget)
@@ -425,16 +424,17 @@ bool UrlTextCursorHandler::findContentsUnderCursor(const QTextCursor &cursor)
const QString line = cursorForUrl.selectedText();
const int cursorCol = cursor.columnNumber();
int urlMatchIndex = -1;
- do {
- urlMatchIndex = m_pattern.indexIn(line, urlMatchIndex + 1);
- if (urlMatchIndex != -1) {
- const QString url = m_pattern.cap(0);
- if (urlMatchIndex <= cursorCol && cursorCol <= urlMatchIndex + url.length()) {
- m_urlData.startColumn = urlMatchIndex;
- m_urlData.url = url;
- }
+ QRegularExpressionMatchIterator i = m_pattern.globalMatch(line);
+ while (i.hasNext()) {
+ const QRegularExpressionMatch match = i.next();
+ urlMatchIndex = match.capturedStart();
+ const QString url = match.captured(0);
+ if (urlMatchIndex <= cursorCol && cursorCol <= urlMatchIndex + url.length()) {
+ m_urlData.startColumn = urlMatchIndex;
+ m_urlData.url = url;
+ break;
}
- } while (urlMatchIndex != -1 && m_urlData.startColumn == -1);
+ };
}
return m_urlData.startColumn != -1;
@@ -475,7 +475,7 @@ QString UrlTextCursorHandler::currentContents() const
void UrlTextCursorHandler::setUrlPattern(const QString &pattern)
{
- m_pattern = QRegExp(pattern);
+ m_pattern = QRegularExpression(pattern);
QTC_ASSERT(m_pattern.isValid(), return);
}
@@ -555,8 +555,8 @@ public:
QString m_workingDirectory;
- QRegExp m_diffFilePattern;
- QRegExp m_logEntryPattern;
+ QRegularExpression m_diffFilePattern;
+ QRegularExpression m_logEntryPattern;
QRegularExpression m_annotationEntryPattern;
QRegularExpression m_annotationSeparatorPattern;
QList<int> m_entrySections; // line number where this section starts
@@ -652,30 +652,34 @@ void VcsBaseEditorWidget::setParameters(const VcsBaseEditorParameters *parameter
d->m_parameters = parameters;
}
-void VcsBaseEditorWidget::setDiffFilePattern(const QRegExp &pattern)
+static void regexpFromString(
+ const QString &pattern,
+ QRegularExpression *regexp,
+ QRegularExpression::PatternOptions options = QRegularExpression::NoPatternOption)
{
- QTC_ASSERT(pattern.isValid() && pattern.captureCount() >= 1, return);
- d->m_diffFilePattern = pattern;
+ const QRegularExpression re(pattern, options);
+ QTC_ASSERT(re.isValid() && re.captureCount() >= 1, return);
+ *regexp = re;
}
-void VcsBaseEditorWidget::setLogEntryPattern(const QRegExp &pattern)
+void VcsBaseEditorWidget::setDiffFilePattern(const QString &pattern)
{
- QTC_ASSERT(pattern.isValid() && pattern.captureCount() >= 1, return);
- d->m_logEntryPattern = pattern;
+ regexpFromString(pattern, &d->m_diffFilePattern);
+}
+
+void VcsBaseEditorWidget::setLogEntryPattern(const QString &pattern)
+{
+ regexpFromString(pattern, &d->m_logEntryPattern);
}
void VcsBaseEditorWidget::setAnnotationEntryPattern(const QString &pattern)
{
- const QRegularExpression re(pattern, QRegularExpression::MultilineOption);
- QTC_ASSERT(re.isValid() && re.captureCount() >= 1, return);
- d->m_annotationEntryPattern = re;
+ regexpFromString(pattern, &d->m_annotationEntryPattern, QRegularExpression::MultilineOption);
}
void VcsBaseEditorWidget::setAnnotationSeparatorPattern(const QString &pattern)
{
- const QRegularExpression re(pattern);
- QTC_ASSERT(re.isValid() && re.captureCount() >= 1, return);
- d->m_annotationSeparatorPattern = re;
+ regexpFromString(pattern, &d->m_annotationSeparatorPattern);
}
bool VcsBaseEditorWidget::supportChangeLinks() const
@@ -881,7 +885,7 @@ void VcsBaseEditorWidget::slotPopulateDiffBrowser()
for (QTextBlock it = document()->begin(); it != cend; it = it.next(), lineNumber++) {
const QString text = it.text();
// Check for a new diff section (not repeating the last filename)
- if (d->m_diffFilePattern.indexIn(text) == 0) {
+ if (d->m_diffFilePattern.match(text).capturedStart() == 0) {
const QString file = fileNameFromDiffSpecification(it);
if (!file.isEmpty() && lastFileName != file) {
lastFileName = file;
@@ -905,9 +909,10 @@ void VcsBaseEditorWidget::slotPopulateLogBrowser()
for (QTextBlock it = document()->begin(); it != cend; it = it.next(), lineNumber++) {
const QString text = it.text();
// Check for a new log section (not repeating the last filename)
- if (d->m_logEntryPattern.indexIn(text) != -1) {
+ const QRegularExpressionMatch match = d->m_logEntryPattern.match(text);
+ if (match.hasMatch()) {
d->m_entrySections.push_back(d->m_entrySections.empty() ? 0 : lineNumber);
- QString entry = d->m_logEntryPattern.cap(1);
+ QString entry = match.captured(1);
QString subject = revisionSubject(it);
if (!subject.isEmpty()) {
if (subject.length() > 100) {
@@ -1215,7 +1220,8 @@ DiffChunk VcsBaseEditorWidget::diffChunk(QTextCursor cursor) const
unicode.append(QLatin1Char('\n'));
for (block = block.next() ; block.isValid() ; block = block.next()) {
const QString line = block.text();
- if (checkChunkLine(line, &chunkStart) || d->m_diffFilePattern.indexIn(line) == 0) {
+ if (checkChunkLine(line, &chunkStart)
+ || d->m_diffFilePattern.match(line).capturedStart() == 0) {
break;
} else {
unicode += line;
@@ -1535,8 +1541,9 @@ QString VcsBaseEditorWidget::fileNameFromDiffSpecification(const QTextBlock &inB
QString fileName;
for (QTextBlock block = inBlock; block.isValid(); block = block.previous()) {
const QString line = block.text();
- if (d->m_diffFilePattern.indexIn(line) != -1) {
- QString cap = d->m_diffFilePattern.cap(1);
+ const QRegularExpressionMatch match = d->m_diffFilePattern.match(line);
+ if (match.hasMatch()) {
+ QString cap = match.captured(1);
if (header)
header->prepend(line + QLatin1String("\n"));
if (fileName.isEmpty() && !cap.isEmpty())
diff --git a/src/plugins/vcsbase/vcsbaseeditor.h b/src/plugins/vcsbase/vcsbaseeditor.h
index caf2d4575d..6e32037b68 100644
--- a/src/plugins/vcsbase/vcsbaseeditor.h
+++ b/src/plugins/vcsbase/vcsbaseeditor.h
@@ -32,7 +32,6 @@
#include <QSet>
QT_BEGIN_NAMESPACE
-class QRegExp;
class QTextCodec;
class QTextCursor;
QT_END_NAMESPACE
@@ -145,9 +144,9 @@ protected:
// virtual functions).
VcsBaseEditorWidget();
// Pattern for diff header. File name must be in the first capture group
- void setDiffFilePattern(const QRegExp &pattern);
+ void setDiffFilePattern(const QString &pattern);
// Pattern for log entry. hash/revision number must be in the first capture group
- void setLogEntryPattern(const QRegExp &pattern);
+ void setLogEntryPattern(const QString &pattern);
// Pattern for annotation entry. hash/revision number must be in the first capture group
void setAnnotationEntryPattern(const QString &pattern);
// Pattern for annotation separator. Lookup will stop on match.