forked from qt-creator/qt-creator
Bazaar: Replace QRegExp
Task-number: QTCREATORBUG-24098 Change-Id: I450d5756359596495f501759670970c9c541d4d9 Reviewed-by: Hugues Delorme <delorme.hugues@fougue.pro>
This commit is contained in:
@@ -26,6 +26,8 @@
|
||||
#include "annotationhighlighter.h"
|
||||
#include "constants.h"
|
||||
|
||||
#include <QRegularExpression>
|
||||
|
||||
using namespace Bazaar::Internal;
|
||||
using namespace Bazaar;
|
||||
|
||||
@@ -37,7 +39,8 @@ BazaarAnnotationHighlighter::BazaarAnnotationHighlighter(const ChangeNumbers &ch
|
||||
|
||||
QString BazaarAnnotationHighlighter::changeNumber(const QString &block) const
|
||||
{
|
||||
if (m_changeset.indexIn(block) != -1)
|
||||
return m_changeset.cap(1);
|
||||
const QRegularExpressionMatch match = m_changeset.match(block);
|
||||
if (match.hasMatch())
|
||||
return match.captured(1);
|
||||
return QString();
|
||||
}
|
||||
|
@@ -26,7 +26,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <vcsbase/baseannotationhighlighter.h>
|
||||
#include <QRegExp>
|
||||
#include <QRegularExpression>
|
||||
|
||||
namespace Bazaar {
|
||||
namespace Internal {
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
|
||||
private:
|
||||
QString changeNumber(const QString &block) const override;
|
||||
mutable QRegExp m_changeset;
|
||||
const QRegularExpression m_changeset;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -36,7 +36,7 @@
|
||||
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <QRegExp>
|
||||
#include <QRegularExpression>
|
||||
#include <QTextStream>
|
||||
#include <QDebug>
|
||||
|
||||
@@ -123,14 +123,18 @@ BranchInfo BazaarClient::synchronousBranchQuery(const QString &repositoryRoot) c
|
||||
QTextStream ts(&branchConfFile);
|
||||
QString branchLocation;
|
||||
QString isBranchBound;
|
||||
QRegExp branchLocationRx(QLatin1String("bound_location\\s*=\\s*(.+)$"));
|
||||
QRegExp isBranchBoundRx(QLatin1String("bound\\s*=\\s*(.+)$"));
|
||||
QRegularExpression branchLocationRx("bound_location\\s*=\\s*(.+)$");
|
||||
QRegularExpression isBranchBoundRx("bound\\s*=\\s*(.+)$");
|
||||
while (!ts.atEnd() && (branchLocation.isEmpty() || isBranchBound.isEmpty())) {
|
||||
const QString line = ts.readLine();
|
||||
if (branchLocationRx.indexIn(line) != -1)
|
||||
branchLocation = branchLocationRx.cap(1);
|
||||
else if (isBranchBoundRx.indexIn(line) != -1)
|
||||
isBranchBound = isBranchBoundRx.cap(1);
|
||||
QRegularExpressionMatch match = branchLocationRx.match(line);
|
||||
if (match.hasMatch()) {
|
||||
branchLocation = match.captured(1);
|
||||
} else {
|
||||
QRegularExpressionMatch match = isBranchBoundRx.match(line);
|
||||
if (match.hasMatch())
|
||||
isBranchBound = match.captured(1);
|
||||
}
|
||||
}
|
||||
if (isBranchBound.simplified().toLower() == QLatin1String("true"))
|
||||
return BranchInfo(branchLocation, true);
|
||||
|
@@ -35,7 +35,7 @@
|
||||
#include <QTextEdit>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QRegExp>
|
||||
#include <QRegularExpression>
|
||||
|
||||
//see the git submit widget for details of the syntax Highlighter
|
||||
|
||||
@@ -62,7 +62,7 @@ public:
|
||||
private:
|
||||
enum State { Header, Comment, Other };
|
||||
const QTextCharFormat m_commentFormat;
|
||||
QRegExp m_keywordPattern;
|
||||
QRegularExpression m_keywordPattern;
|
||||
const QChar m_hashChar;
|
||||
};
|
||||
|
||||
@@ -97,16 +97,18 @@ void BazaarSubmitHighlighter::highlightBlock(const QString &text)
|
||||
case Comment:
|
||||
setFormat(0, text.size(), m_commentFormat);
|
||||
break;
|
||||
case Other:
|
||||
case Other: {
|
||||
// Format key words ("Task:") italic
|
||||
if (m_keywordPattern.indexIn(text, 0, QRegExp::CaretAtZero) == 0) {
|
||||
const QRegularExpressionMatch match = m_keywordPattern.match(text);
|
||||
if (match.hasMatch()) {
|
||||
QTextCharFormat charFormat = format(0);
|
||||
charFormat.setFontItalic(true);
|
||||
setFormat(0, m_keywordPattern.matchedLength(), charFormat);
|
||||
setFormat(0, match.capturedLength(), charFormat);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BazaarCommitWidget::BazaarCommitWidget() : m_bazaarCommitPanel(new QWidget)
|
||||
@@ -143,7 +145,7 @@ QString BazaarCommitWidget::committer() const
|
||||
|
||||
QStringList BazaarCommitWidget::fixedBugs() const
|
||||
{
|
||||
return m_bazaarCommitPanelUi.fixedBugsLineEdit->text().split(QRegExp(QLatin1String("\\s+")));
|
||||
return m_bazaarCommitPanelUi.fixedBugsLineEdit->text().split(QRegularExpression("\\s+"));
|
||||
}
|
||||
|
||||
bool BazaarCommitWidget::isLocalOptionEnabled() const
|
||||
|
@@ -62,16 +62,16 @@ QString BazaarEditorWidget::changeUnderCursor(const QTextCursor &cursorIn) const
|
||||
cursor.select(QTextCursor::LineUnderCursor);
|
||||
if (cursor.hasSelection()) {
|
||||
const QString line = cursor.selectedText();
|
||||
const int start = m_changesetId.indexIn(line);
|
||||
if (start > -1) {
|
||||
const QString match = m_changesetId.cap(0);
|
||||
const int stop = start + match.length();
|
||||
const QRegularExpressionMatch match = m_changesetId.match(line);
|
||||
if (match.hasMatch()) {
|
||||
const int start = match.capturedStart();
|
||||
const int stop = match.capturedEnd();
|
||||
if (start <= cursorCol && cursorCol <= stop) {
|
||||
cursor = cursorIn;
|
||||
cursor.select(QTextCursor::WordUnderCursor);
|
||||
if (cursor.hasSelection()) {
|
||||
const QString change = cursor.selectedText();
|
||||
if (m_exactChangesetId.exactMatch(change))
|
||||
if (m_exactChangesetId.match(change).hasMatch())
|
||||
return change;
|
||||
}
|
||||
}
|
||||
|
@@ -27,7 +27,7 @@
|
||||
|
||||
#include <vcsbase/vcsbaseeditor.h>
|
||||
|
||||
#include <QRegExp>
|
||||
#include <QRegularExpression>
|
||||
|
||||
namespace Bazaar {
|
||||
namespace Internal {
|
||||
@@ -44,8 +44,8 @@ private:
|
||||
VcsBase::BaseAnnotationHighlighter *createAnnotationHighlighter(
|
||||
const QSet<QString> &changes) const override;
|
||||
|
||||
mutable QRegExp m_changesetId;
|
||||
mutable QRegExp m_exactChangesetId;
|
||||
const QRegularExpression m_changesetId;
|
||||
const QRegularExpression m_exactChangesetId;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -41,7 +41,7 @@ const char CHANGESET_ID[] = "^("
|
||||
"| +[.0-9]+" // short
|
||||
"|[.0-9]+: " // line
|
||||
")";
|
||||
const char CHANGESET_ID_EXACT[] = "([.0-9]+)";
|
||||
const char CHANGESET_ID_EXACT[] = "^([.0-9]+)$";
|
||||
const char ANNOTATE_CHANGESET_ID[] = "([.0-9]+)";
|
||||
|
||||
// Base editor parameters
|
||||
|
Reference in New Issue
Block a user