forked from qt-creator/qt-creator
CMakePM: Replace QRegExp by QRegularExpression
Task-number: QTCREATORBUG-24098 Change-Id: I295e2a9a92880b58b3f6103fe68824c379ab47a4 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
#include "cmakeautocompleter.h"
|
#include "cmakeautocompleter.h"
|
||||||
|
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
namespace CMakeProjectManager {
|
namespace CMakeProjectManager {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -110,7 +112,7 @@ QString CMakeAutoCompleter::insertMatchingQuote(const QTextCursor &cursor,
|
|||||||
int CMakeAutoCompleter::paragraphSeparatorAboutToBeInserted(QTextCursor &cursor)
|
int CMakeAutoCompleter::paragraphSeparatorAboutToBeInserted(QTextCursor &cursor)
|
||||||
{
|
{
|
||||||
const QString line = cursor.block().text().trimmed();
|
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()));
|
tabSettings().indentLine(cursor.block(), tabSettings().indentationColumn(cursor.block().text()));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,8 +88,8 @@ static bool isCurrentExecutableTarget(const QString &target)
|
|||||||
CMakeBuildStep::CMakeBuildStep(BuildStepList *bsl, Utils::Id id) :
|
CMakeBuildStep::CMakeBuildStep(BuildStepList *bsl, Utils::Id id) :
|
||||||
AbstractProcessStep(bsl, id)
|
AbstractProcessStep(bsl, id)
|
||||||
{
|
{
|
||||||
m_percentProgress = QRegExp("^\\[\\s*(\\d*)%\\]");
|
m_percentProgress = QRegularExpression("^\\[\\s*(\\d*)%\\]");
|
||||||
m_ninjaProgress = QRegExp("^\\[\\s*(\\d*)/\\s*(\\d*)");
|
m_ninjaProgress = QRegularExpression("^\\[\\s*(\\d*)/\\s*(\\d*)");
|
||||||
m_ninjaProgressString = "[%f/%t "; // ninja: [33/100
|
m_ninjaProgressString = "[%f/%t "; // ninja: [33/100
|
||||||
//: Default display name for the cmake make step.
|
//: Default display name for the cmake make step.
|
||||||
setDefaultDisplayName(tr("CMake Build"));
|
setDefaultDisplayName(tr("CMake Build"));
|
||||||
@@ -289,26 +289,30 @@ void CMakeBuildStep::stdOutput(const QString &output)
|
|||||||
line = output.mid(offset, newlinePos - offset + 1);
|
line = output.mid(offset, newlinePos - offset + 1);
|
||||||
offset = newlinePos + 1;
|
offset = newlinePos + 1;
|
||||||
}
|
}
|
||||||
if (m_percentProgress.indexIn(line) != -1) {
|
QRegularExpressionMatch match = m_percentProgress.match(line);
|
||||||
|
if (match.hasMatch()) {
|
||||||
AbstractProcessStep::stdOutput(line);
|
AbstractProcessStep::stdOutput(line);
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
int percent = m_percentProgress.cap(1).toInt(&ok);
|
int percent = match.captured(1).toInt(&ok);
|
||||||
if (ok)
|
if (ok)
|
||||||
emit progress(percent, QString());
|
emit progress(percent, QString());
|
||||||
continue;
|
continue;
|
||||||
} else if (m_ninjaProgress.indexIn(line) != -1) {
|
} else {
|
||||||
AbstractProcessStep::stdOutput(line);
|
match = m_ninjaProgress.match(line);
|
||||||
m_useNinja = true;
|
if (match.hasMatch()) {
|
||||||
bool ok = false;
|
AbstractProcessStep::stdOutput(line);
|
||||||
int done = m_ninjaProgress.cap(1).toInt(&ok);
|
m_useNinja = true;
|
||||||
if (ok) {
|
bool ok = false;
|
||||||
int all = m_ninjaProgress.cap(2).toInt(&ok);
|
int done = match.captured(1).toInt(&ok);
|
||||||
if (ok && all != 0) {
|
if (ok) {
|
||||||
const int percent = static_cast<int>(100.0 * done/all);
|
int all = match.captured(2).toInt(&ok);
|
||||||
emit progress(percent, QString());
|
if (ok && all != 0) {
|
||||||
|
const int percent = static_cast<int>(100.0 * done/all);
|
||||||
|
emit progress(percent, QString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
if (m_useNinja)
|
if (m_useNinja)
|
||||||
AbstractProcessStep::stdError(line);
|
AbstractProcessStep::stdError(line);
|
||||||
|
|||||||
@@ -27,6 +27,8 @@
|
|||||||
|
|
||||||
#include <projectexplorer/abstractprocessstep.h>
|
#include <projectexplorer/abstractprocessstep.h>
|
||||||
|
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
namespace Utils { class CommandLine; }
|
namespace Utils { class CommandLine; }
|
||||||
|
|
||||||
namespace ProjectExplorer { class RunConfiguration; }
|
namespace ProjectExplorer { class RunConfiguration; }
|
||||||
@@ -98,8 +100,8 @@ private:
|
|||||||
|
|
||||||
QMetaObject::Connection m_runTrigger;
|
QMetaObject::Connection m_runTrigger;
|
||||||
|
|
||||||
QRegExp m_percentProgress;
|
QRegularExpression m_percentProgress;
|
||||||
QRegExp m_ninjaProgress;
|
QRegularExpression m_ninjaProgress;
|
||||||
QString m_ninjaProgressString;
|
QString m_ninjaProgressString;
|
||||||
QStringList m_buildTargets;
|
QStringList m_buildTargets;
|
||||||
QString m_cmakeArguments;
|
QString m_cmakeArguments;
|
||||||
|
|||||||
Reference in New Issue
Block a user