forked from qt-creator/qt-creator
QbsPM:QmakePM: Replace QRegExp by QRegularExpression
Task-number: QTCREATORBUG-24098 Change-Id: If561553a6030f8eaedbafbc1b4531a6b63c4aa36 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -33,7 +33,7 @@
|
||||
#include <QStandardItem>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QRegExp>
|
||||
#include <QRegularExpression>
|
||||
|
||||
namespace QmakeProjectManager {
|
||||
namespace Internal {
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
private:
|
||||
void appendClass(const QString &);
|
||||
|
||||
QRegExp m_validator;
|
||||
QRegularExpression m_validator;
|
||||
const QString m_newClassPlaceHolder;
|
||||
};
|
||||
|
||||
@@ -75,7 +75,7 @@ void ClassModel::appendClass(const QString &c)
|
||||
|
||||
bool ClassModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||
{
|
||||
if (role == Qt::EditRole && !m_validator.exactMatch(value.toString()))
|
||||
if (role == Qt::EditRole && !m_validator.match(value.toString()).hasMatch())
|
||||
return false;
|
||||
return QStandardItemModel::setData(index, value, role);
|
||||
}
|
||||
|
||||
@@ -36,12 +36,12 @@
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QDir>
|
||||
#include <QRegExp>
|
||||
#include <QRegularExpression>
|
||||
#include <QSet>
|
||||
|
||||
static QString headerGuard(const QString &header)
|
||||
{
|
||||
return header.toUpper().replace(QRegExp(QLatin1String("[^A-Z0-9]+")), QLatin1String("_"));
|
||||
return header.toUpper().replace(QRegularExpression("[^A-Z0-9]+"), QString("_"));
|
||||
}
|
||||
|
||||
namespace QmakeProjectManager {
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <QRegExp>
|
||||
#include <QRegularExpression>
|
||||
#include <QTextStream>
|
||||
#include <QLoggingCategory>
|
||||
|
||||
@@ -72,7 +72,7 @@ void MakeFileParse::parseArgs(const QString &args, const QString &project,
|
||||
QList<QMakeAssignment> *assignments,
|
||||
QList<QMakeAssignment> *afterAssignments)
|
||||
{
|
||||
QRegExp regExp(QLatin1String("([^\\s\\+-]*)\\s*(\\+=|=|-=|~=)(.*)"));
|
||||
const QRegularExpression regExp(QLatin1String("^([^\\s\\+-]*)\\s*(\\+=|=|-=|~=)(.*)$"));
|
||||
bool after = false;
|
||||
bool ignoreNext = false;
|
||||
m_unparsedArguments = args;
|
||||
@@ -88,11 +88,12 @@ void MakeFileParse::parseArgs(const QString &args, const QString &project,
|
||||
after = true;
|
||||
ait.deleteArg();
|
||||
} else if (ait.value().contains(QLatin1Char('='))) {
|
||||
if (regExp.exactMatch(ait.value())) {
|
||||
const QRegularExpressionMatch match = regExp.match(ait.value());
|
||||
if (match.hasMatch()) {
|
||||
QMakeAssignment qa;
|
||||
qa.variable = regExp.cap(1);
|
||||
qa.op = regExp.cap(2);
|
||||
qa.value = regExp.cap(3).trimmed();
|
||||
qa.variable = match.captured(1);
|
||||
qa.op = match.captured(2);
|
||||
qa.value = match.captured(3).trimmed();
|
||||
if (after)
|
||||
afterAssignments->append(qa);
|
||||
else
|
||||
@@ -248,11 +249,12 @@ static FilePath findQMakeBinaryFromMakefile(const QString &makefile)
|
||||
QFile fi(makefile);
|
||||
if (fi.exists() && fi.open(QFile::ReadOnly)) {
|
||||
QTextStream ts(&fi);
|
||||
QRegExp r1(QLatin1String("QMAKE\\s*=(.*)"));
|
||||
const QRegularExpression r1(QLatin1String("^QMAKE\\s*=(.*)$"));
|
||||
while (!ts.atEnd()) {
|
||||
QString line = ts.readLine();
|
||||
if (r1.exactMatch(line)) {
|
||||
QFileInfo qmake(r1.cap(1).trimmed());
|
||||
const QRegularExpressionMatch match = r1.match(line);
|
||||
if (match.hasMatch()) {
|
||||
QFileInfo qmake(match.captured(1).trimmed());
|
||||
QString qmakePath = qmake.filePath();
|
||||
if (!QString::fromLatin1(QTC_HOST_EXE_SUFFIX).isEmpty()
|
||||
&& !qmakePath.endsWith(QLatin1String(QTC_HOST_EXE_SUFFIX))) {
|
||||
|
||||
@@ -34,10 +34,9 @@ using namespace Utils;
|
||||
|
||||
namespace QmakeProjectManager {
|
||||
|
||||
QMakeParser::QMakeParser() : m_error(QLatin1String("^(.+):(\\d+):\\s(.+)$"))
|
||||
QMakeParser::QMakeParser() : m_error(QLatin1String("^(.+?):(\\d+?):\\s(.+?)$"))
|
||||
{
|
||||
setObjectName(QLatin1String("QMakeParser"));
|
||||
m_error.setMinimal(true);
|
||||
}
|
||||
|
||||
OutputLineParser::Result QMakeParser::handleLine(const QString &line, OutputFormat type)
|
||||
@@ -45,11 +44,12 @@ OutputLineParser::Result QMakeParser::handleLine(const QString &line, OutputForm
|
||||
if (type != Utils::StdErrFormat)
|
||||
return Status::NotHandled;
|
||||
QString lne = rightTrimmed(line);
|
||||
if (m_error.indexIn(lne) > -1) {
|
||||
QString fileName = m_error.cap(1);
|
||||
QRegularExpressionMatch match = m_error.match(lne);
|
||||
if (match.hasMatch()) {
|
||||
QString fileName = match.captured(1);
|
||||
Task::TaskType type = Task::Error;
|
||||
const QString description = m_error.cap(3);
|
||||
int fileNameOffset = m_error.pos(1);
|
||||
const QString description = match.captured(3);
|
||||
int fileNameOffset = match.capturedStart(1);
|
||||
if (fileName.startsWith(QLatin1String("WARNING: "))) {
|
||||
type = Task::Warning;
|
||||
fileName = fileName.mid(9);
|
||||
@@ -66,7 +66,7 @@ OutputLineParser::Result QMakeParser::handleLine(const QString &line, OutputForm
|
||||
type = Task::Error;
|
||||
|
||||
BuildSystemTask t(type, description, absoluteFilePath(FilePath::fromUserInput(fileName)),
|
||||
m_error.cap(2).toInt() /* line */);
|
||||
match.captured(2).toInt() /* line */);
|
||||
LinkSpecs linkSpecs;
|
||||
addLinkSpecForAbsoluteFilePath(linkSpecs, t.file, t.line, fileNameOffset,
|
||||
fileName.length());
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
#include <projectexplorer/ioutputparser.h>
|
||||
|
||||
#include <QRegExp>
|
||||
#include <QRegularExpression>
|
||||
|
||||
namespace QmakeProjectManager {
|
||||
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
private:
|
||||
Result handleLine(const QString &line, Utils::OutputFormat type) override;
|
||||
|
||||
QRegExp m_error;
|
||||
const QRegularExpression m_error;
|
||||
};
|
||||
|
||||
} // namespace QmakeProjectManager
|
||||
|
||||
Reference in New Issue
Block a user