forked from qt-creator/qt-creator
PE: Replace some QRegExp by QRegularExpression
Task-number: QTCREATORBUG-24098 Change-Id: I6d9fde23d5d7a1d3fab3723a22ba385ebaee04a0 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -39,29 +39,25 @@ LinuxIccParser::LinuxIccParser() :
|
|||||||
setObjectName(QLatin1String("LinuxIccParser"));
|
setObjectName(QLatin1String("LinuxIccParser"));
|
||||||
// main.cpp(53): error #308: function \"AClass::privatefunc\" (declared at line 4 of \"main.h\") is inaccessible
|
// main.cpp(53): error #308: function \"AClass::privatefunc\" (declared at line 4 of \"main.h\") is inaccessible
|
||||||
|
|
||||||
m_firstLine.setPattern(QLatin1String("^([^\\(\\)]+)" // filename (cap 1)
|
m_firstLine.setPattern(QLatin1String("^([^\\(\\)]+?)" // filename (cap 1)
|
||||||
"\\((\\d+)\\):" // line number including : (cap 2)
|
"\\((\\d+?)\\):" // line number including : (cap 2)
|
||||||
" ((error|warning)( #\\d+)?: )?" // optional type (cap 4) and optional error number // TODO really optional ?
|
" ((error|warning)( #\\d+?)?: )?" // optional type (cap 4) and optional error number // TODO really optional ?
|
||||||
"(.*)$")); // description (cap 6)
|
"(.*?)$")); // description (cap 6)
|
||||||
//m_firstLine.setMinimal(true);
|
|
||||||
QTC_CHECK(m_firstLine.isValid());
|
QTC_CHECK(m_firstLine.isValid());
|
||||||
|
|
||||||
// Note pattern also matches caret lines
|
// Note pattern also matches caret lines
|
||||||
m_continuationLines.setPattern(QLatin1String("^\\s+" // At least one whitespace
|
m_continuationLines.setPattern(QLatin1String("^\\s+" // At least one whitespace
|
||||||
"(.*)$"));// description
|
"(.*)$"));// description
|
||||||
m_continuationLines.setMinimal(true);
|
|
||||||
QTC_CHECK(m_continuationLines.isValid());
|
QTC_CHECK(m_continuationLines.isValid());
|
||||||
|
|
||||||
m_caretLine.setPattern(QLatin1String("^\\s*" // Whitespaces
|
m_caretLine.setPattern(QLatin1String("^\\s*?" // Whitespaces
|
||||||
"\\^" // a caret
|
"\\^" // a caret
|
||||||
"\\s*$")); // and again whitespaces
|
"\\s*?$")); // and again whitespaces
|
||||||
m_caretLine.setMinimal(true);
|
|
||||||
QTC_CHECK(m_caretLine.isValid());
|
QTC_CHECK(m_caretLine.isValid());
|
||||||
|
|
||||||
// ".pch/Qt5Core.pchi.cpp": creating precompiled header file ".pch/Qt5Core.pchi"
|
// ".pch/Qt5Core.pchi.cpp": creating precompiled header file ".pch/Qt5Core.pchi"
|
||||||
// "animation/qabstractanimation.cpp": using precompiled header file ".pch/Qt5Core.pchi"
|
// "animation/qabstractanimation.cpp": using precompiled header file ".pch/Qt5Core.pchi"
|
||||||
m_pchInfoLine.setPattern(QLatin1String("^\".*\": (creating|using) precompiled header file \".*\"\n$"));
|
m_pchInfoLine.setPattern(QLatin1String("^\".*?\": (creating|using) precompiled header file \".*?\"\n$"));
|
||||||
m_pchInfoLine.setMinimal(true);
|
|
||||||
QTC_CHECK(m_pchInfoLine.isValid());
|
QTC_CHECK(m_pchInfoLine.isValid());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,28 +66,31 @@ OutputLineParser::Result LinuxIccParser::handleLine(const QString &line, OutputF
|
|||||||
if (type != Utils::StdErrFormat)
|
if (type != Utils::StdErrFormat)
|
||||||
return Status::NotHandled;
|
return Status::NotHandled;
|
||||||
|
|
||||||
if (m_pchInfoLine.indexIn(line) != -1)
|
if (line.indexOf(m_pchInfoLine) != -1)
|
||||||
return Status::Done; // totally ignore this line
|
return Status::Done; // totally ignore this line
|
||||||
|
|
||||||
if (m_expectFirstLine && m_firstLine.indexIn(line) != -1) {
|
if (m_expectFirstLine) {
|
||||||
// Clear out old task
|
const QRegularExpressionMatch match = m_firstLine.match(line);
|
||||||
Task::TaskType type = Task::Unknown;
|
if (match.hasMatch()) {
|
||||||
QString category = m_firstLine.cap(4);
|
// Clear out old task
|
||||||
if (category == QLatin1String("error"))
|
Task::TaskType type = Task::Unknown;
|
||||||
type = Task::Error;
|
QString category = match.captured(4);
|
||||||
else if (category == QLatin1String("warning"))
|
if (category == QLatin1String("error"))
|
||||||
type = Task::Warning;
|
type = Task::Error;
|
||||||
const FilePath filePath = absoluteFilePath(FilePath::fromUserInput(m_firstLine.cap(1)));
|
else if (category == QLatin1String("warning"))
|
||||||
const int lineNo = m_firstLine.cap(2).toInt();
|
type = Task::Warning;
|
||||||
LinkSpecs linkSpecs;
|
const FilePath filePath = absoluteFilePath(FilePath::fromUserInput(match.captured(1)));
|
||||||
addLinkSpecForAbsoluteFilePath(linkSpecs, filePath, lineNo, m_firstLine, 1);
|
const int lineNo = match.captured(2).toInt();
|
||||||
m_temporary = CompileTask(type, m_firstLine.cap(6).trimmed(), filePath, lineNo);
|
LinkSpecs linkSpecs;
|
||||||
|
addLinkSpecForAbsoluteFilePath(linkSpecs, filePath, lineNo, match, 1);
|
||||||
|
m_temporary = CompileTask(type, match.captured(6).trimmed(), filePath, lineNo);
|
||||||
|
|
||||||
m_lines = 1;
|
m_lines = 1;
|
||||||
m_expectFirstLine = false;
|
m_expectFirstLine = false;
|
||||||
return Status::InProgress;
|
return Status::InProgress;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!m_expectFirstLine && m_caretLine.indexIn(line) != -1) {
|
if (!m_expectFirstLine && line.indexOf(m_caretLine) != -1) {
|
||||||
// FIXME: m_temporary.details.append(line);
|
// FIXME: m_temporary.details.append(line);
|
||||||
return Status::InProgress;
|
return Status::InProgress;
|
||||||
}
|
}
|
||||||
@@ -101,8 +100,9 @@ OutputLineParser::Result LinuxIccParser::handleLine(const QString &line, OutputF
|
|||||||
m_temporary = Task();
|
m_temporary = Task();
|
||||||
return Status::Done;
|
return Status::Done;
|
||||||
}
|
}
|
||||||
if (!m_expectFirstLine && m_continuationLines.indexIn(line) != -1) {
|
const QRegularExpressionMatch match = m_continuationLines.match(line);
|
||||||
m_temporary.details.append(m_continuationLines.cap(1).trimmed());
|
if (!m_expectFirstLine && match.hasMatch()) {
|
||||||
|
m_temporary.details.append(match.captured(1).trimmed());
|
||||||
++m_lines;
|
++m_lines;
|
||||||
return Status::InProgress;
|
return Status::InProgress;
|
||||||
}
|
}
|
||||||
|
@@ -28,7 +28,7 @@
|
|||||||
#include "ioutputparser.h"
|
#include "ioutputparser.h"
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
|
|
||||||
#include <QRegExp>
|
#include <QRegularExpression>
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
|
|
||||||
@@ -47,10 +47,10 @@ private:
|
|||||||
Result handleLine(const QString &line, Utils::OutputFormat type) override;
|
Result handleLine(const QString &line, Utils::OutputFormat type) override;
|
||||||
void flush() override;
|
void flush() override;
|
||||||
|
|
||||||
QRegExp m_firstLine;
|
QRegularExpression m_firstLine;
|
||||||
QRegExp m_continuationLines;
|
QRegularExpression m_continuationLines;
|
||||||
QRegExp m_caretLine;
|
QRegularExpression m_caretLine;
|
||||||
QRegExp m_pchInfoLine;
|
QRegularExpression m_pchInfoLine;
|
||||||
|
|
||||||
bool m_expectFirstLine = true;
|
bool m_expectFirstLine = true;
|
||||||
Task m_temporary;
|
Task m_temporary;
|
||||||
|
Reference in New Issue
Block a user