forked from qt-creator/qt-creator
MsvcParser: Use QRegularExpression
Change-Id: I919218cd5c3047dfbafda9f3adbb4ad6fd8c1de3 Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
@@ -68,7 +68,6 @@ MsvcParser::MsvcParser()
|
|||||||
m_compileRegExp.setPattern(QString::fromLatin1("^") + QLatin1String(FILE_POS_PATTERN)
|
m_compileRegExp.setPattern(QString::fromLatin1("^") + QLatin1String(FILE_POS_PATTERN)
|
||||||
+ QLatin1String("(Command line |fatal )?(warning|error) (")
|
+ QLatin1String("(Command line |fatal )?(warning|error) (")
|
||||||
+ QLatin1String(ERROR_PATTERN) + QLatin1String(".*)$"));
|
+ QLatin1String(ERROR_PATTERN) + QLatin1String(".*)$"));
|
||||||
m_compileRegExp.setMinimal(true);
|
|
||||||
QTC_CHECK(m_compileRegExp.isValid());
|
QTC_CHECK(m_compileRegExp.isValid());
|
||||||
m_additionalInfoRegExp.setPattern(QString::fromLatin1("^ (?:(could be |or )\\s*')?(.*)\\((\\d+)\\) : (.*)$"));
|
m_additionalInfoRegExp.setPattern(QString::fromLatin1("^ (?:(could be |or )\\s*')?(.*)\\((\\d+)\\) : (.*)$"));
|
||||||
QTC_CHECK(m_additionalInfoRegExp.isValid());
|
QTC_CHECK(m_additionalInfoRegExp.isValid());
|
||||||
@@ -76,8 +75,8 @@ MsvcParser::MsvcParser()
|
|||||||
|
|
||||||
void MsvcParser::stdOutput(const QString &line)
|
void MsvcParser::stdOutput(const QString &line)
|
||||||
{
|
{
|
||||||
int infoPos = m_additionalInfoRegExp.indexIn(line);
|
QRegularExpressionMatch match = m_additionalInfoRegExp.match(line);
|
||||||
if (line.startsWith(QLatin1String(" ")) && infoPos < 0) {
|
if (line.startsWith(QLatin1String(" ")) && !match.hasMatch()) {
|
||||||
if (m_lastTask.isNull())
|
if (m_lastTask.isNull())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -121,14 +120,14 @@ void MsvcParser::stdOutput(const QString &line)
|
|||||||
Constants::TASK_CATEGORY_COMPILE);
|
Constants::TASK_CATEGORY_COMPILE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (infoPos > -1) {
|
if (match.hasMatch()) {
|
||||||
QString description = m_additionalInfoRegExp.cap(1)
|
QString description = match.captured(1)
|
||||||
+ m_additionalInfoRegExp.cap(4).trimmed();
|
+ match.captured(4).trimmed();
|
||||||
if (!m_additionalInfoRegExp.cap(1).isEmpty())
|
if (!match.captured(1).isEmpty())
|
||||||
description.chop(1); // Remove trailing quote
|
description.chop(1); // Remove trailing quote
|
||||||
m_lastTask = Task(Task::Unknown, description,
|
m_lastTask = Task(Task::Unknown, description,
|
||||||
Utils::FileName::fromUserInput(m_additionalInfoRegExp.cap(2)), /* fileName */
|
Utils::FileName::fromUserInput(match.captured(2)), /* fileName */
|
||||||
m_additionalInfoRegExp.cap(3).toInt(), /* linenumber */
|
match.captured(3).toInt(), /* linenumber */
|
||||||
Constants::TASK_CATEGORY_COMPILE);
|
Constants::TASK_CATEGORY_COMPILE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -155,15 +154,16 @@ bool MsvcParser::processCompileLine(const QString &line)
|
|||||||
{
|
{
|
||||||
doFlush();
|
doFlush();
|
||||||
|
|
||||||
if (m_compileRegExp.indexIn(line) > -1) {
|
QRegularExpressionMatch match = m_compileRegExp.match(line);
|
||||||
QPair<Utils::FileName, int> position = parseFileName( m_compileRegExp.cap(1));
|
if (match.hasMatch()) {
|
||||||
|
QPair<Utils::FileName, int> position = parseFileName(match.captured(1));
|
||||||
Task::TaskType type = Task::Unknown;
|
Task::TaskType type = Task::Unknown;
|
||||||
const QString category = m_compileRegExp.cap(3);
|
const QString category = match.captured(3);
|
||||||
if (category == QLatin1String("warning"))
|
if (category == QLatin1String("warning"))
|
||||||
type = Task::Warning;
|
type = Task::Warning;
|
||||||
else if (category == QLatin1String("error"))
|
else if (category == QLatin1String("error"))
|
||||||
type = Task::Error;
|
type = Task::Error;
|
||||||
m_lastTask = Task(type, m_compileRegExp.cap(4).trimmed() /* description */,
|
m_lastTask = Task(type, match.captured(4).trimmed() /* description */,
|
||||||
position.first, position.second,
|
position.first, position.second,
|
||||||
Constants::TASK_CATEGORY_COMPILE);
|
Constants::TASK_CATEGORY_COMPILE);
|
||||||
return true;
|
return true;
|
||||||
|
@@ -33,7 +33,7 @@
|
|||||||
#include "ioutputparser.h"
|
#include "ioutputparser.h"
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
|
|
||||||
#include <QRegExp>
|
#include <QRegularExpression>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
@@ -52,8 +52,8 @@ private:
|
|||||||
void doFlush();
|
void doFlush();
|
||||||
bool processCompileLine(const QString &line);
|
bool processCompileLine(const QString &line);
|
||||||
|
|
||||||
QRegExp m_compileRegExp;
|
QRegularExpression m_compileRegExp;
|
||||||
QRegExp m_additionalInfoRegExp;
|
QRegularExpression m_additionalInfoRegExp;
|
||||||
|
|
||||||
Task m_lastTask;
|
Task m_lastTask;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user