Android: Use QRegularExpression instead of QRegExp

Task-number: QTCREATORBUG-24098
Change-Id: Ic19bd73dd2bac39b393bf87c4567193631b57c80
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Christian Stenger
2020-06-16 07:48:09 +02:00
parent 555970eeb0
commit 4b1adeca7f
5 changed files with 14 additions and 12 deletions

View File

@@ -64,7 +64,6 @@
#include <QLoggingCategory>
#include <QMessageBox>
#include <QProcess>
#include <QRegExp>
#include <QRegularExpression>
#include <QVersionNumber>

View File

@@ -42,6 +42,8 @@
#include <proparser/profileevaluator.h>
#include <QRegularExpression>
using namespace ProjectExplorer;
namespace Android {
@@ -168,10 +170,11 @@ void AndroidQtVersion::parseMkSpec(ProFileEvaluator *evaluator) const
m_androidAbis = QStringList{evaluator->value("ANDROID_TARGET_ARCH")};
const QString androidPlatform = evaluator->value("ANDROID_PLATFORM");
if (!androidPlatform.isEmpty()) {
const QRegExp regex("android-(\\d+)");
if (regex.exactMatch(androidPlatform)) {
const QRegularExpression regex("android-(\\d+)");
const QRegularExpressionMatch match = regex.match(androidPlatform);
if (match.hasMatch()) {
bool ok = false;
int tmp = regex.cap(1).toInt(&ok);
int tmp = match.captured(1).toInt(&ok);
if (ok)
m_minNdk = tmp;
}

View File

@@ -35,7 +35,6 @@
#include <QFileInfo>
#include <QLoggingCategory>
#include <QRegExp>
namespace {

View File

@@ -55,14 +55,15 @@ Utils::OutputLineParser::Result JavaParser::handleLine(const QString &line,
Utils::OutputFormat type)
{
Q_UNUSED(type);
if (m_javaRegExp.indexIn(line) == -1)
const QRegularExpressionMatch match = m_javaRegExp.match(line);
if (!match.hasMatch())
return Status::NotHandled;
bool ok;
int lineno = m_javaRegExp.cap(3).toInt(&ok);
int lineno = match.captured(3).toInt(&ok);
if (!ok)
lineno = -1;
Utils::FilePath file = Utils::FilePath::fromUserInput(m_javaRegExp.cap(2));
Utils::FilePath file = Utils::FilePath::fromUserInput(match.captured(2));
if (file.isChildOf(m_buildDirectory)) {
Utils::FilePath relativePath = file.relativeChildPath(m_buildDirectory);
file = m_sourceDirectory.pathAppended(relativePath.toString());
@@ -76,11 +77,11 @@ Utils::OutputLineParser::Result JavaParser::handleLine(const QString &line,
}
CompileTask task(Task::Error,
m_javaRegExp.cap(4).trimmed(),
match.captured(4).trimmed(),
absoluteFilePath(file),
lineno);
LinkSpecs linkSpecs;
addLinkSpecForAbsoluteFilePath(linkSpecs, task.file, task.line, m_javaRegExp, 2);
addLinkSpecForAbsoluteFilePath(linkSpecs, task.file, task.line, match, 2);
scheduleTask(task, 1);
return {Status::Done, linkSpecs};
}

View File

@@ -28,7 +28,7 @@
#include <projectexplorer/ioutputparser.h>
#include <utils/fileutils.h>
#include <QRegExp>
#include <QRegularExpression>
namespace Android {
namespace Internal {
@@ -47,7 +47,7 @@ public:
private:
Result handleLine(const QString &line, Utils::OutputFormat type) override;
QRegExp m_javaRegExp;
QRegularExpression m_javaRegExp;
QStringList m_fileList;
Utils::FilePath m_sourceDirectory;
Utils::FilePath m_buildDirectory;