CMakePM: Replace QRegExp by QRegularExpression

Task-number: QTCREATORBUG-24098
Change-Id: I295e2a9a92880b58b3f6103fe68824c379ab47a4
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Christian Stenger
2020-07-13 11:26:16 +02:00
parent 56de884159
commit 8b26bde438
3 changed files with 26 additions and 18 deletions

View File

@@ -25,6 +25,8 @@
#include "cmakeautocompleter.h"
#include <QRegularExpression>
namespace CMakeProjectManager {
namespace Internal {
@@ -110,7 +112,7 @@ QString CMakeAutoCompleter::insertMatchingQuote(const QTextCursor &cursor,
int CMakeAutoCompleter::paragraphSeparatorAboutToBeInserted(QTextCursor &cursor)
{
const QString line = cursor.block().text().trimmed();
if (line.contains(QRegExp(QStringLiteral("^(endfunction|endmacro|endif|endforeach|endwhile)\\w*\\("))))
if (line.contains(QRegularExpression(QStringLiteral("^(endfunction|endmacro|endif|endforeach|endwhile)\\w*\\("))))
tabSettings().indentLine(cursor.block(), tabSettings().indentationColumn(cursor.block().text()));
return 0;
}

View File

@@ -88,8 +88,8 @@ static bool isCurrentExecutableTarget(const QString &target)
CMakeBuildStep::CMakeBuildStep(BuildStepList *bsl, Utils::Id id) :
AbstractProcessStep(bsl, id)
{
m_percentProgress = QRegExp("^\\[\\s*(\\d*)%\\]");
m_ninjaProgress = QRegExp("^\\[\\s*(\\d*)/\\s*(\\d*)");
m_percentProgress = QRegularExpression("^\\[\\s*(\\d*)%\\]");
m_ninjaProgress = QRegularExpression("^\\[\\s*(\\d*)/\\s*(\\d*)");
m_ninjaProgressString = "[%f/%t "; // ninja: [33/100
//: Default display name for the cmake make step.
setDefaultDisplayName(tr("CMake Build"));
@@ -289,20 +289,23 @@ void CMakeBuildStep::stdOutput(const QString &output)
line = output.mid(offset, newlinePos - offset + 1);
offset = newlinePos + 1;
}
if (m_percentProgress.indexIn(line) != -1) {
QRegularExpressionMatch match = m_percentProgress.match(line);
if (match.hasMatch()) {
AbstractProcessStep::stdOutput(line);
bool ok = false;
int percent = m_percentProgress.cap(1).toInt(&ok);
int percent = match.captured(1).toInt(&ok);
if (ok)
emit progress(percent, QString());
continue;
} else if (m_ninjaProgress.indexIn(line) != -1) {
} else {
match = m_ninjaProgress.match(line);
if (match.hasMatch()) {
AbstractProcessStep::stdOutput(line);
m_useNinja = true;
bool ok = false;
int done = m_ninjaProgress.cap(1).toInt(&ok);
int done = match.captured(1).toInt(&ok);
if (ok) {
int all = m_ninjaProgress.cap(2).toInt(&ok);
int all = match.captured(2).toInt(&ok);
if (ok && all != 0) {
const int percent = static_cast<int>(100.0 * done/all);
emit progress(percent, QString());
@@ -310,6 +313,7 @@ void CMakeBuildStep::stdOutput(const QString &output)
}
continue;
}
}
if (m_useNinja)
AbstractProcessStep::stdError(line);
else

View File

@@ -27,6 +27,8 @@
#include <projectexplorer/abstractprocessstep.h>
#include <QRegularExpression>
namespace Utils { class CommandLine; }
namespace ProjectExplorer { class RunConfiguration; }
@@ -98,8 +100,8 @@ private:
QMetaObject::Connection m_runTrigger;
QRegExp m_percentProgress;
QRegExp m_ninjaProgress;
QRegularExpression m_percentProgress;
QRegularExpression m_ninjaProgress;
QString m_ninjaProgressString;
QStringList m_buildTargets;
QString m_cmakeArguments;