forked from qt-creator/qt-creator
IOutputParser: Replace std{Out,Err} with a single parameterized function
Another step towards parser/formatter unification. Task-number: QTCREATORBUG-22665 Change-Id: I6de86b3aee2c54585cdd4b06d21b0ea67300aeac Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -36,18 +36,6 @@ JavaParser::JavaParser() :
|
||||
m_javaRegExp(QLatin1String("^(.*\\[javac\\]\\s)(.*\\.java):(\\d+):(.*)$"))
|
||||
{ }
|
||||
|
||||
void JavaParser::stdOutput(const QString &line)
|
||||
{
|
||||
parse(line);
|
||||
IOutputParser::stdOutput(line);
|
||||
}
|
||||
|
||||
void JavaParser::stdError(const QString &line)
|
||||
{
|
||||
parse(line);
|
||||
IOutputParser::stdError(line);
|
||||
}
|
||||
|
||||
void JavaParser::setProjectFileList(const QStringList &fileList)
|
||||
{
|
||||
m_fileList = fileList;
|
||||
@@ -63,6 +51,12 @@ void JavaParser::setSourceDirectory(const Utils::FilePath &sourceDirectory)
|
||||
m_sourceDirectory = sourceDirectory;
|
||||
}
|
||||
|
||||
void JavaParser::handleLine(const QString &line, Utils::OutputFormat type)
|
||||
{
|
||||
parse(line);
|
||||
IOutputParser::handleLine(line, type);
|
||||
}
|
||||
|
||||
void JavaParser::parse(const QString &line)
|
||||
{
|
||||
if (m_javaRegExp.indexIn(line) > -1) {
|
||||
|
@@ -39,14 +39,13 @@ class JavaParser : public ProjectExplorer::IOutputParser
|
||||
|
||||
public:
|
||||
JavaParser();
|
||||
void stdOutput(const QString &line) override;
|
||||
void stdError(const QString &line) override;
|
||||
void setProjectFileList(const QStringList &fileList);
|
||||
|
||||
void setBuildDirectory(const Utils::FilePath &buildDirectory);
|
||||
void setSourceDirectory(const Utils::FilePath &sourceDirectory);
|
||||
|
||||
private:
|
||||
void handleLine(const QString &line, Utils::OutputFormat type) override;
|
||||
void parse(const QString &line);
|
||||
|
||||
QRegExp m_javaRegExp;
|
||||
|
@@ -190,9 +190,17 @@ bool IarParser::parseErrorMessage1(const QString &lne)
|
||||
return true;
|
||||
}
|
||||
|
||||
void IarParser::handleLine(const QString &line, OutputFormat type)
|
||||
{
|
||||
if (type == StdOutFormat)
|
||||
stdOutput(line);
|
||||
else
|
||||
stdError(line);
|
||||
}
|
||||
|
||||
void IarParser::stdError(const QString &line)
|
||||
{
|
||||
IOutputParser::stdError(line);
|
||||
IOutputParser::handleLine(line, StdErrFormat);
|
||||
|
||||
const QString lne = rightTrimmed(line);
|
||||
|
||||
@@ -232,7 +240,7 @@ void IarParser::stdError(const QString &line)
|
||||
|
||||
void IarParser::stdOutput(const QString &line)
|
||||
{
|
||||
IOutputParser::stdOutput(line);
|
||||
IOutputParser::handleLine(line, StdOutFormat);
|
||||
|
||||
const QString lne = rightTrimmed(line);
|
||||
|
||||
|
@@ -52,8 +52,9 @@ private:
|
||||
bool parseErrorInCommandLineMessage(const QString &lne);
|
||||
bool parseErrorMessage1(const QString &lne);
|
||||
|
||||
void stdError(const QString &line) final;
|
||||
void stdOutput(const QString &line) final;
|
||||
void handleLine(const QString &line, Utils::OutputFormat type) final;
|
||||
void stdError(const QString &line);
|
||||
void stdOutput(const QString &line);
|
||||
void doFlush() final;
|
||||
|
||||
ProjectExplorer::Task m_lastTask;
|
||||
|
@@ -190,9 +190,17 @@ bool KeilParser::parseMcs51FatalErrorMessage2(const QString &lne)
|
||||
return true;
|
||||
}
|
||||
|
||||
void KeilParser::handleLine(const QString &line, OutputFormat type)
|
||||
{
|
||||
if (type == StdOutFormat)
|
||||
stdOutput(line);
|
||||
else
|
||||
stdError(line);
|
||||
}
|
||||
|
||||
void KeilParser::stdError(const QString &line)
|
||||
{
|
||||
IOutputParser::stdError(line);
|
||||
IOutputParser::handleLine(line, StdErrFormat);
|
||||
|
||||
const QString lne = rightTrimmed(line);
|
||||
|
||||
@@ -228,7 +236,7 @@ static bool hasDetailsPointer(const QString &trimmedLine)
|
||||
|
||||
void KeilParser::stdOutput(const QString &line)
|
||||
{
|
||||
IOutputParser::stdOutput(line);
|
||||
IOutputParser::handleLine(line, StdOutFormat);
|
||||
|
||||
QString lne = rightTrimmed(line);
|
||||
|
||||
|
@@ -55,8 +55,9 @@ private:
|
||||
bool parseMcs51WarningOrFatalErrorMessage(const QString &lne);
|
||||
bool parseMcs51FatalErrorMessage2(const QString &lne);
|
||||
|
||||
void stdError(const QString &line) final;
|
||||
void stdOutput(const QString &line) final;
|
||||
void handleLine(const QString &line, Utils::OutputFormat type) final;
|
||||
void stdError(const QString &line);
|
||||
void stdOutput(const QString &line);
|
||||
void doFlush() final;
|
||||
|
||||
ProjectExplorer::Task m_lastTask;
|
||||
|
@@ -87,9 +87,17 @@ void SdccParser::amendDescription(const QString &desc)
|
||||
++m_lines;
|
||||
}
|
||||
|
||||
void SdccParser::handleLine(const QString &line, OutputFormat type)
|
||||
{
|
||||
if (type == StdOutFormat)
|
||||
stdOutput(line);
|
||||
else
|
||||
stdError(line);
|
||||
}
|
||||
|
||||
void SdccParser::stdError(const QString &line)
|
||||
{
|
||||
IOutputParser::stdError(line);
|
||||
IOutputParser::handleLine(line, StdErrFormat);
|
||||
|
||||
const QString lne = rightTrimmed(line);
|
||||
|
||||
@@ -154,7 +162,7 @@ void SdccParser::stdError(const QString &line)
|
||||
|
||||
void SdccParser::stdOutput(const QString &line)
|
||||
{
|
||||
IOutputParser::stdOutput(line);
|
||||
IOutputParser::handleLine(line, StdOutFormat);
|
||||
}
|
||||
|
||||
void SdccParser::doFlush()
|
||||
|
@@ -45,8 +45,9 @@ private:
|
||||
void newTask(const ProjectExplorer::Task &task);
|
||||
void amendDescription(const QString &desc);
|
||||
|
||||
void stdError(const QString &line) final;
|
||||
void stdOutput(const QString &line) final;
|
||||
void handleLine(const QString &line, Utils::OutputFormat type) final;
|
||||
void stdError(const QString &line);
|
||||
void stdOutput(const QString &line);
|
||||
void doFlush() final;
|
||||
|
||||
ProjectExplorer::Task m_lastTask;
|
||||
|
@@ -57,10 +57,14 @@ void CMakeParser::setSourceDirectory(const QString &sourceDir)
|
||||
m_sourceDirectory = QDir(sourceDir);
|
||||
}
|
||||
|
||||
void CMakeParser::stdError(const QString &line)
|
||||
void CMakeParser::handleLine(const QString &line, OutputFormat type)
|
||||
{
|
||||
QString trimmedLine = rightTrimmed(line);
|
||||
if (type != StdErrFormat) {
|
||||
IOutputParser::handleLine(line, type);
|
||||
return;
|
||||
}
|
||||
|
||||
QString trimmedLine = rightTrimmed(line);
|
||||
switch (m_expectTripleLineErrorData) {
|
||||
case NONE:
|
||||
if (trimmedLine.isEmpty() && !m_lastTask.isNull()) {
|
||||
@@ -110,7 +114,7 @@ void CMakeParser::stdError(const QString &line)
|
||||
// Do not pass on lines starting with "-- " or "* ". Those are typical CMake output
|
||||
return;
|
||||
}
|
||||
IOutputParser::stdError(line);
|
||||
IOutputParser::handleLine(line, StdErrFormat);
|
||||
return;
|
||||
case LINE_LOCATION:
|
||||
{
|
||||
|
@@ -43,12 +43,11 @@ class CMAKE_EXPORT CMakeParser : public ProjectExplorer::IOutputParser
|
||||
public:
|
||||
explicit CMakeParser();
|
||||
void setSourceDirectory(const QString &sourceDir);
|
||||
void stdError(const QString &line) override;
|
||||
|
||||
protected:
|
||||
void doFlush() override;
|
||||
|
||||
private:
|
||||
void handleLine(const QString &line, Utils::OutputFormat type) override;
|
||||
void doFlush() override;
|
||||
|
||||
enum TripleLineError { NONE, LINE_LOCATION, LINE_DESCRIPTION, LINE_DESCRIPTION2 };
|
||||
|
||||
TripleLineError m_expectTripleLineErrorData = NONE;
|
||||
|
@@ -361,7 +361,7 @@ void ServerModeReader::createNewServer()
|
||||
connect(m_cmakeServer.get(), &ServerMode::cmakeMessage, [this](const QString &m) {
|
||||
const QStringList lines = m.split('\n');
|
||||
for (const QString &l : lines) {
|
||||
m_parser.stdError(l);
|
||||
m_parser.handleStderr(l);
|
||||
Core::MessageManager::write(l);
|
||||
}
|
||||
});
|
||||
|
@@ -45,20 +45,13 @@ namespace {
|
||||
|
||||
class NimParser : public IOutputParser
|
||||
{
|
||||
public:
|
||||
void stdOutput(const QString &line) final
|
||||
{
|
||||
parseLine(line.trimmed());
|
||||
IOutputParser::stdOutput(line);
|
||||
}
|
||||
|
||||
void stdError(const QString &line) final
|
||||
{
|
||||
parseLine(line.trimmed());
|
||||
IOutputParser::stdError(line);
|
||||
}
|
||||
|
||||
private:
|
||||
void handleLine(const QString &line, Utils::OutputFormat type) override
|
||||
{
|
||||
parseLine(line.trimmed());
|
||||
IOutputParser::handleLine(line, type);
|
||||
}
|
||||
|
||||
void parseLine(const QString &line)
|
||||
{
|
||||
static QRegularExpression regex("(.+.nim)\\((\\d+), (\\d+)\\) (.+)",
|
||||
|
@@ -47,20 +47,12 @@ namespace Nim {
|
||||
|
||||
class NimParser : public ProjectExplorer::IOutputParser
|
||||
{
|
||||
public:
|
||||
void stdOutput(const QString &line) final
|
||||
void handleLine(const QString &line, Utils::OutputFormat type) override
|
||||
{
|
||||
parseLine(line.trimmed());
|
||||
IOutputParser::stdOutput(line);
|
||||
IOutputParser::handleLine(line, type);
|
||||
}
|
||||
|
||||
void stdError(const QString &line) final
|
||||
{
|
||||
parseLine(line.trimmed());
|
||||
IOutputParser::stdError(line);
|
||||
}
|
||||
|
||||
private:
|
||||
void parseLine(const QString &line)
|
||||
{
|
||||
static QRegularExpression regex("(.+.nim)\\((\\d+), (\\d+)\\) (.+)",
|
||||
|
@@ -54,8 +54,12 @@ ClangParser::ClangParser() :
|
||||
setObjectName(QLatin1String("ClangParser"));
|
||||
}
|
||||
|
||||
void ClangParser::stdError(const QString &line)
|
||||
void ClangParser::handleLine(const QString &line, OutputFormat type)
|
||||
{
|
||||
if (type != StdErrFormat) {
|
||||
IOutputParser::handleLine(line, type);
|
||||
return;
|
||||
}
|
||||
const QString lne = rightTrimmed(line);
|
||||
QRegularExpressionMatch match = m_summaryRegExp.match(lne);
|
||||
if (match.hasMatch()) {
|
||||
@@ -107,7 +111,7 @@ void ClangParser::stdError(const QString &line)
|
||||
return;
|
||||
}
|
||||
|
||||
IOutputParser::stdError(line);
|
||||
IOutputParser::handleLine(line, StdErrFormat);
|
||||
}
|
||||
|
||||
Core::Id ClangParser::id()
|
||||
|
@@ -38,11 +38,12 @@ class PROJECTEXPLORER_EXPORT ClangParser : public ProjectExplorer::GccParser
|
||||
|
||||
public:
|
||||
ClangParser();
|
||||
void stdError(const QString &line) override;
|
||||
|
||||
static Core::Id id();
|
||||
|
||||
private:
|
||||
void handleLine(const QString &line, Utils::OutputFormat type) override;
|
||||
|
||||
QRegularExpression m_commandRegExp;
|
||||
QRegularExpression m_inLineRegExp;
|
||||
QRegularExpression m_messageRegExp;
|
||||
|
@@ -118,22 +118,6 @@ CustomParser::CustomParser(const CustomParserSettings &settings)
|
||||
setSettings(settings);
|
||||
}
|
||||
|
||||
void CustomParser::stdError(const QString &line)
|
||||
{
|
||||
if (parseLine(line, CustomParserExpression::ParseStdErrChannel))
|
||||
return;
|
||||
|
||||
IOutputParser::stdError(line);
|
||||
}
|
||||
|
||||
void CustomParser::stdOutput(const QString &line)
|
||||
{
|
||||
if (parseLine(line, CustomParserExpression::ParseStdOutChannel))
|
||||
return;
|
||||
|
||||
IOutputParser::stdOutput(line);
|
||||
}
|
||||
|
||||
void CustomParser::setSettings(const CustomParserSettings &settings)
|
||||
{
|
||||
m_error = settings.error;
|
||||
@@ -145,6 +129,16 @@ Core::Id CustomParser::id()
|
||||
return Core::Id("ProjectExplorer.OutputParser.Custom");
|
||||
}
|
||||
|
||||
void CustomParser::handleLine(const QString &line, OutputFormat type)
|
||||
{
|
||||
const CustomParserExpression::CustomParserChannel channel = type == StdErrFormat
|
||||
? CustomParserExpression::ParseStdErrChannel
|
||||
: CustomParserExpression::ParseStdOutChannel;
|
||||
if (parseLine(line, channel))
|
||||
return;
|
||||
IOutputParser::handleLine(line, type);
|
||||
}
|
||||
|
||||
bool CustomParser::hasMatch(const QString &line, CustomParserExpression::CustomParserChannel channel,
|
||||
const CustomParserExpression &expression, Task::TaskType taskType)
|
||||
{
|
||||
|
@@ -86,14 +86,13 @@ class CustomParser : public ProjectExplorer::IOutputParser
|
||||
public:
|
||||
CustomParser(const CustomParserSettings &settings = CustomParserSettings());
|
||||
|
||||
void stdError(const QString &line) override;
|
||||
void stdOutput(const QString &line) override;
|
||||
|
||||
void setSettings(const CustomParserSettings &settings);
|
||||
|
||||
static Core::Id id();
|
||||
|
||||
private:
|
||||
void handleLine(const QString &line, Utils::OutputFormat type) override;
|
||||
|
||||
bool hasMatch(const QString &line, CustomParserExpression::CustomParserChannel channel,
|
||||
const CustomParserExpression &expression, Task::TaskType taskType);
|
||||
bool parseLine(const QString &rawLine, CustomParserExpression::CustomParserChannel channel);
|
||||
|
@@ -71,7 +71,7 @@ void GccParser::stdError(const QString &line)
|
||||
// Blacklist some lines to not handle them:
|
||||
if (lne.startsWith(QLatin1String("TeamBuilder ")) ||
|
||||
lne.startsWith(QLatin1String("distcc["))) {
|
||||
IOutputParser::stdError(line);
|
||||
IOutputParser::handleLine(line, StdErrFormat);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -130,13 +130,13 @@ void GccParser::stdError(const QString &line)
|
||||
}
|
||||
|
||||
doFlush();
|
||||
IOutputParser::stdError(line);
|
||||
IOutputParser::handleLine(line, StdErrFormat);
|
||||
}
|
||||
|
||||
void GccParser::stdOutput(const QString &line)
|
||||
{
|
||||
doFlush();
|
||||
IOutputParser::stdOutput(line);
|
||||
IOutputParser::handleLine(line, StdOutFormat);
|
||||
}
|
||||
|
||||
Core::Id GccParser::id()
|
||||
@@ -180,6 +180,14 @@ void GccParser::amendDescription(const QString &desc, bool monospaced)
|
||||
return;
|
||||
}
|
||||
|
||||
void GccParser::handleLine(const QString &line, OutputFormat type)
|
||||
{
|
||||
if (type == StdOutFormat)
|
||||
stdOutput(line);
|
||||
else
|
||||
stdError(line);
|
||||
}
|
||||
|
||||
// Unit tests:
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
|
@@ -40,9 +40,6 @@ class PROJECTEXPLORER_EXPORT GccParser : public ProjectExplorer::IOutputParser
|
||||
public:
|
||||
GccParser();
|
||||
|
||||
void stdError(const QString &line) override;
|
||||
void stdOutput(const QString &line) override;
|
||||
|
||||
static Core::Id id();
|
||||
|
||||
protected:
|
||||
@@ -52,6 +49,11 @@ protected:
|
||||
void amendDescription(const QString &desc, bool monospaced);
|
||||
|
||||
private:
|
||||
void handleLine(const QString &line, Utils::OutputFormat type) override;
|
||||
|
||||
void stdError(const QString &line);
|
||||
void stdOutput(const QString &line);
|
||||
|
||||
QRegularExpression m_regExp;
|
||||
QRegularExpression m_regExpIncluded;
|
||||
QRegularExpression m_regExpGccNames;
|
||||
|
@@ -56,6 +56,14 @@ GnuMakeParser::GnuMakeParser()
|
||||
QTC_CHECK(m_errorInMakefile.isValid());
|
||||
}
|
||||
|
||||
void GnuMakeParser::handleLine(const QString &line, OutputFormat type)
|
||||
{
|
||||
if (type == StdOutFormat)
|
||||
stdOutput(line);
|
||||
else
|
||||
stdError(line);
|
||||
}
|
||||
|
||||
bool GnuMakeParser::hasFatalErrors() const
|
||||
{
|
||||
return (m_fatalErrorCount > 0) || IOutputParser::hasFatalErrors();
|
||||
@@ -74,7 +82,7 @@ void GnuMakeParser::stdOutput(const QString &line)
|
||||
return;
|
||||
}
|
||||
|
||||
IOutputParser::stdOutput(line);
|
||||
IOutputParser::handleLine(line, StdOutFormat);
|
||||
}
|
||||
|
||||
class Result {
|
||||
@@ -145,7 +153,7 @@ void GnuMakeParser::stdError(const QString &line)
|
||||
return;
|
||||
}
|
||||
|
||||
IOutputParser::stdError(line);
|
||||
IOutputParser::handleLine(line, StdErrFormat);
|
||||
}
|
||||
|
||||
void GnuMakeParser::emitTask(const ProjectExplorer::Task &task)
|
||||
|
@@ -39,12 +39,13 @@ class PROJECTEXPLORER_EXPORT GnuMakeParser : public ProjectExplorer::IOutputPars
|
||||
public:
|
||||
explicit GnuMakeParser();
|
||||
|
||||
void stdOutput(const QString &line) override;
|
||||
void stdError(const QString &line) override;
|
||||
|
||||
private:
|
||||
void handleLine(const QString &line, Utils::OutputFormat type) override;
|
||||
bool hasFatalErrors() const override;
|
||||
|
||||
private:
|
||||
void stdOutput(const QString &line);
|
||||
void stdError(const QString &line);
|
||||
|
||||
void emitTask(const ProjectExplorer::Task &task);
|
||||
|
||||
QRegularExpression m_makeDir;
|
||||
|
@@ -55,15 +55,9 @@
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void ProjectExplorer::IOutputParser::stdOutput(const QString &line)
|
||||
\fn void ProjectExplorer::IOutputParser::handleLine(const QString &line, Utils::OutputFormat type)
|
||||
|
||||
Called once for each line if standard output to parse.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void ProjectExplorer::IOutputParser::stdError(const QString &line)
|
||||
|
||||
Called once for each line if standard error to parse.
|
||||
Called once for each line of standard output or standard error to parse.
|
||||
*/
|
||||
|
||||
/*!
|
||||
@@ -109,14 +103,13 @@
|
||||
|
||||
namespace ProjectExplorer {
|
||||
|
||||
class OutputChannelState
|
||||
class IOutputParser::OutputChannelState
|
||||
{
|
||||
public:
|
||||
using LineHandler = void (IOutputParser::*)(const QString &line);
|
||||
|
||||
OutputChannelState(IOutputParser *parser, LineHandler lineHandler,
|
||||
QList<IOutputParser::Filter> &filters)
|
||||
: parser(parser), lineHandler(lineHandler), filters(filters) {}
|
||||
OutputChannelState(IOutputParser *parser, Utils::OutputFormat type)
|
||||
: parser(parser), type(type) {}
|
||||
|
||||
void handleData(const QString &newData)
|
||||
{
|
||||
@@ -128,30 +121,20 @@ public:
|
||||
break;
|
||||
const QString line = pendingData.left(eolPos + 1);
|
||||
pendingData.remove(0, eolPos + 1);
|
||||
(parser->*lineHandler)(filteredLine(line));
|
||||
parser->handleLine(parser->filteredLine(line), type);
|
||||
}
|
||||
}
|
||||
|
||||
void flush()
|
||||
{
|
||||
if (!pendingData.isEmpty()) {
|
||||
(parser->*lineHandler)(filteredLine(pendingData));
|
||||
parser->handleLine(parser->filteredLine(pendingData), type);
|
||||
pendingData.clear();
|
||||
}
|
||||
}
|
||||
|
||||
QString filteredLine(const QString &line)
|
||||
{
|
||||
QString l = line;
|
||||
for (const IOutputParser::Filter &f : filters)
|
||||
l = f(l);
|
||||
return l;
|
||||
}
|
||||
|
||||
|
||||
IOutputParser * const parser;
|
||||
const LineHandler lineHandler;
|
||||
QList<IOutputParser::Filter> &filters;
|
||||
const Utils::OutputFormat type;
|
||||
QString pendingData;
|
||||
};
|
||||
|
||||
@@ -159,8 +142,8 @@ class IOutputParser::IOutputParserPrivate
|
||||
{
|
||||
public:
|
||||
IOutputParserPrivate(IOutputParser *parser)
|
||||
: stdoutState(parser, &IOutputParser::stdOutput, filters),
|
||||
stderrState(parser, &IOutputParser::stdError, filters)
|
||||
: stdoutState(parser, Utils::StdOutFormat),
|
||||
stderrState(parser, Utils::StdErrFormat)
|
||||
{}
|
||||
|
||||
IOutputParser *childParser = nullptr;
|
||||
@@ -218,16 +201,10 @@ void IOutputParser::setChildParser(IOutputParser *parser)
|
||||
connect(parser, &IOutputParser::addTask, this, &IOutputParser::addTask);
|
||||
}
|
||||
|
||||
void IOutputParser::stdOutput(const QString &line)
|
||||
void IOutputParser::handleLine(const QString &line, Utils::OutputFormat type)
|
||||
{
|
||||
if (d->childParser)
|
||||
d->childParser->stdOutput(line);
|
||||
}
|
||||
|
||||
void IOutputParser::stdError(const QString &line)
|
||||
{
|
||||
if (d->childParser)
|
||||
d->childParser->stdError(line);
|
||||
d->childParser->handleLine(line, type);
|
||||
}
|
||||
|
||||
void IOutputParser::skipFileExistsCheck()
|
||||
@@ -237,6 +214,14 @@ void IOutputParser::skipFileExistsCheck()
|
||||
|
||||
void IOutputParser::doFlush() { }
|
||||
|
||||
QString IOutputParser::filteredLine(const QString &line) const
|
||||
{
|
||||
QString l = line;
|
||||
for (const IOutputParser::Filter &f : qAsConst(d->filters))
|
||||
l = f(l);
|
||||
return l;
|
||||
}
|
||||
|
||||
bool IOutputParser::hasFatalErrors() const
|
||||
{
|
||||
return d->childParser && d->childParser->hasFatalErrors();
|
||||
|
@@ -29,6 +29,7 @@
|
||||
#include "buildstep.h"
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/outputformat.h>
|
||||
|
||||
#include <functional>
|
||||
|
||||
@@ -70,14 +71,16 @@ signals:
|
||||
void addTask(const ProjectExplorer::Task &task, int linkedOutputLines = 0, int skipLines = 0);
|
||||
|
||||
protected:
|
||||
virtual void stdOutput(const QString &line);
|
||||
virtual void stdError(const QString &line);
|
||||
virtual void handleLine(const QString &line, Utils::OutputFormat type);
|
||||
|
||||
Utils::FilePath absoluteFilePath(const Utils::FilePath &filePath);
|
||||
|
||||
private:
|
||||
virtual void doFlush();
|
||||
|
||||
QString filteredLine(const QString &line) const;
|
||||
|
||||
class OutputChannelState;
|
||||
class IOutputParserPrivate;
|
||||
IOutputParserPrivate * const d;
|
||||
};
|
||||
|
@@ -54,8 +54,12 @@ LdParser::LdParser()
|
||||
QTC_CHECK(m_regExpGccNames.isValid());
|
||||
}
|
||||
|
||||
void LdParser::stdError(const QString &line)
|
||||
void LdParser::handleLine(const QString &line, Utils::OutputFormat type)
|
||||
{
|
||||
if (type != Utils::StdErrFormat) {
|
||||
IOutputParser::handleLine(line, type);
|
||||
return;
|
||||
}
|
||||
QString lne = rightTrimmed(line);
|
||||
if (!lne.isEmpty() && !lne.at(0).isSpace() && !m_incompleteTask.isNull())
|
||||
flush();
|
||||
@@ -63,7 +67,7 @@ void LdParser::stdError(const QString &line)
|
||||
if (lne.startsWith(QLatin1String("TeamBuilder "))
|
||||
|| lne.startsWith(QLatin1String("distcc["))
|
||||
|| lne.contains(QLatin1String("ar: creating "))) {
|
||||
IOutputParser::stdError(line);
|
||||
IOutputParser::handleLine(line, Utils::StdErrFormat);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -137,7 +141,7 @@ void LdParser::stdError(const QString &line)
|
||||
return;
|
||||
}
|
||||
|
||||
IOutputParser::stdError(line);
|
||||
IOutputParser::handleLine(line, Utils::StdErrFormat);
|
||||
}
|
||||
|
||||
void LdParser::doFlush()
|
||||
|
@@ -39,7 +39,7 @@ class LdParser : public ProjectExplorer::IOutputParser
|
||||
public:
|
||||
LdParser();
|
||||
private:
|
||||
void stdError(const QString &line) override;
|
||||
void handleLine(const QString &line, Utils::OutputFormat type) override;
|
||||
void doFlush() override;
|
||||
|
||||
QRegularExpression m_ranlib;
|
||||
|
@@ -68,8 +68,12 @@ LinuxIccParser::LinuxIccParser() :
|
||||
appendOutputParser(new LdParser);
|
||||
}
|
||||
|
||||
void LinuxIccParser::stdError(const QString &line)
|
||||
void LinuxIccParser::handleLine(const QString &line, OutputFormat type)
|
||||
{
|
||||
if (type != Utils::StdErrFormat) {
|
||||
IOutputParser::handleLine(line, type);
|
||||
return;
|
||||
}
|
||||
if (m_pchInfoLine.indexIn(line) != -1) {
|
||||
// totally ignore this line
|
||||
return;
|
||||
@@ -115,7 +119,7 @@ void LinuxIccParser::stdError(const QString &line)
|
||||
m_temporary.description.append(m_continuationLines.cap(1).trimmed());
|
||||
++m_lines;
|
||||
} else {
|
||||
IOutputParser::stdError(line);
|
||||
IOutputParser::handleLine(line, StdErrFormat);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -39,11 +39,10 @@ class LinuxIccParser : public ProjectExplorer::IOutputParser
|
||||
public:
|
||||
LinuxIccParser();
|
||||
|
||||
void stdError(const QString &line) override;
|
||||
|
||||
static Core::Id id();
|
||||
|
||||
private:
|
||||
void handleLine(const QString &line, Utils::OutputFormat type) override;
|
||||
void doFlush() override;
|
||||
|
||||
QRegExp m_firstLine;
|
||||
|
@@ -35,8 +35,12 @@
|
||||
namespace ProjectExplorer {
|
||||
namespace Internal {
|
||||
|
||||
void LldParser::stdError(const QString &line)
|
||||
void LldParser::handleLine(const QString &line, Utils::OutputFormat type)
|
||||
{
|
||||
if (type != Utils::StdErrFormat) {
|
||||
IOutputParser::handleLine(line, type);
|
||||
return;
|
||||
}
|
||||
const QString trimmedLine = rightTrimmed(line);
|
||||
if (trimmedLine.contains("error:") && trimmedLine.contains("lld")) {
|
||||
emit addTask(CompileTask(Task::Error, trimmedLine));
|
||||
@@ -68,7 +72,7 @@ void LldParser::stdError(const QString &line)
|
||||
absoluteFilePath(file), lineNo));
|
||||
return;
|
||||
}
|
||||
IOutputParser::stdError(line);
|
||||
IOutputParser::handleLine(line, Utils::StdErrFormat);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -32,7 +32,7 @@ namespace Internal {
|
||||
|
||||
class LldParser : public IOutputParser
|
||||
{
|
||||
void stdError(const QString &line) override;
|
||||
void handleLine(const QString &line, Utils::OutputFormat type) override;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -147,7 +147,7 @@ void MsvcParser::stdOutput(const QString &line)
|
||||
m_lines = 1;
|
||||
return;
|
||||
}
|
||||
IOutputParser::stdOutput(line);
|
||||
IOutputParser::handleLine(line, StdOutFormat);
|
||||
}
|
||||
|
||||
void MsvcParser::stdError(const QString &line)
|
||||
@@ -159,7 +159,7 @@ void MsvcParser::stdError(const QString &line)
|
||||
m_lines = 1;
|
||||
return;
|
||||
}
|
||||
IOutputParser::stdError(line);
|
||||
IOutputParser::handleLine(line, StdErrFormat);
|
||||
}
|
||||
|
||||
Core::Id MsvcParser::id()
|
||||
@@ -167,6 +167,14 @@ Core::Id MsvcParser::id()
|
||||
return Core::Id("ProjectExplorer.OutputParser.Msvc");
|
||||
}
|
||||
|
||||
void MsvcParser::handleLine(const QString &line, OutputFormat type)
|
||||
{
|
||||
if (type == OutputFormat::StdOutFormat)
|
||||
stdOutput(line);
|
||||
else
|
||||
stdError(line);
|
||||
}
|
||||
|
||||
bool MsvcParser::processCompileLine(const QString &line)
|
||||
{
|
||||
doFlush();
|
||||
@@ -212,6 +220,14 @@ ClangClParser::ClangClParser()
|
||||
QTC_CHECK(m_compileRegExp.isValid());
|
||||
}
|
||||
|
||||
void ClangClParser::handleLine(const QString &line, OutputFormat type)
|
||||
{
|
||||
if (type == StdOutFormat)
|
||||
stdOutput(line);
|
||||
else
|
||||
stdError(line);
|
||||
}
|
||||
|
||||
void ClangClParser::stdOutput(const QString &line)
|
||||
{
|
||||
if (handleNmakeJomMessage(line, &m_lastTask)) {
|
||||
@@ -219,7 +235,7 @@ void ClangClParser::stdOutput(const QString &line)
|
||||
doFlush();
|
||||
return;
|
||||
}
|
||||
IOutputParser::stdOutput(line);
|
||||
IOutputParser::handleLine(line, StdOutFormat);
|
||||
}
|
||||
|
||||
// Check for a code marker '~~~~ ^ ~~~~~~~~~~~~' underlining above code.
|
||||
@@ -274,7 +290,7 @@ void ClangClParser::stdError(const QString &lineIn)
|
||||
return;
|
||||
}
|
||||
|
||||
IOutputParser::stdError(lineIn);
|
||||
IOutputParser::handleLine(lineIn, StdErrFormat);
|
||||
}
|
||||
|
||||
void ClangClParser::doFlush()
|
||||
|
@@ -40,13 +40,14 @@ class PROJECTEXPLORER_EXPORT MsvcParser : public ProjectExplorer::IOutputParser
|
||||
public:
|
||||
MsvcParser();
|
||||
|
||||
void stdOutput(const QString &line) override;
|
||||
void stdError(const QString &line) override;
|
||||
|
||||
static Core::Id id();
|
||||
|
||||
private:
|
||||
void handleLine(const QString &line, Utils::OutputFormat type) override;
|
||||
void doFlush() override;
|
||||
|
||||
void stdOutput(const QString &line);
|
||||
void stdError(const QString &line);
|
||||
bool processCompileLine(const QString &line);
|
||||
|
||||
QRegularExpression m_compileRegExp;
|
||||
@@ -63,12 +64,13 @@ class PROJECTEXPLORER_EXPORT ClangClParser : public ProjectExplorer::IOutputPar
|
||||
public:
|
||||
ClangClParser();
|
||||
|
||||
void stdOutput(const QString &line) override;
|
||||
void stdError(const QString &line) override;
|
||||
|
||||
private:
|
||||
void handleLine(const QString &line, Utils::OutputFormat type) override;
|
||||
void doFlush() override;
|
||||
|
||||
void stdOutput(const QString &line);
|
||||
void stdError(const QString &line);
|
||||
|
||||
const QRegularExpression m_compileRegExp;
|
||||
Task m_lastTask;
|
||||
int m_linkedLines = 0;
|
||||
|
@@ -36,6 +36,14 @@ OsParser::OsParser()
|
||||
setObjectName(QLatin1String("OsParser"));
|
||||
}
|
||||
|
||||
void OsParser::handleLine(const QString &line, Utils::OutputFormat type)
|
||||
{
|
||||
if (type == Utils::StdOutFormat)
|
||||
stdOutput(line);
|
||||
else
|
||||
stdError(line);
|
||||
}
|
||||
|
||||
void OsParser::stdError(const QString &line)
|
||||
{
|
||||
if (Utils::HostOsInfo::isLinuxHost()) {
|
||||
@@ -43,7 +51,7 @@ void OsParser::stdError(const QString &line)
|
||||
if (trimmed.contains(QLatin1String(": error while loading shared libraries:")))
|
||||
emit addTask(CompileTask(Task::Error, trimmed));
|
||||
}
|
||||
IOutputParser::stdError(line);
|
||||
IOutputParser::handleLine(line, Utils::StdErrFormat);
|
||||
}
|
||||
|
||||
void OsParser::stdOutput(const QString &line)
|
||||
@@ -57,7 +65,7 @@ void OsParser::stdOutput(const QString &line)
|
||||
m_hasFatalError = true;
|
||||
}
|
||||
}
|
||||
IOutputParser::stdOutput(line);
|
||||
IOutputParser::handleLine(line, Utils::StdOutFormat);
|
||||
}
|
||||
|
||||
bool OsParser::hasFatalErrors() const
|
||||
|
@@ -40,12 +40,13 @@ class PROJECTEXPLORER_EXPORT OsParser : public ProjectExplorer::IOutputParser
|
||||
public:
|
||||
OsParser();
|
||||
|
||||
void stdError(const QString &line) override;
|
||||
void stdOutput(const QString &line) override;
|
||||
|
||||
private:
|
||||
void handleLine(const QString &line, Utils::OutputFormat type) override;
|
||||
bool hasFatalErrors() const override;
|
||||
|
||||
private:
|
||||
void stdError(const QString &line);
|
||||
void stdOutput(const QString &line);
|
||||
|
||||
bool m_hasFatalError = false;
|
||||
};
|
||||
|
||||
|
@@ -103,16 +103,13 @@ TestTerminator::TestTerminator(OutputParserTester *t) :
|
||||
m_tester(t)
|
||||
{ }
|
||||
|
||||
void TestTerminator::stdOutput(const QString &line)
|
||||
void TestTerminator::handleLine(const QString &line, Utils::OutputFormat type)
|
||||
{
|
||||
QVERIFY(line.endsWith('\n'));
|
||||
m_tester->m_receivedStdOutChildLine.append(line);
|
||||
}
|
||||
|
||||
void TestTerminator::stdError(const QString &line)
|
||||
{
|
||||
QVERIFY(line.endsWith('\n'));
|
||||
m_tester->m_receivedStdErrChildLine.append(line);
|
||||
if (type == Utils::StdOutFormat)
|
||||
m_tester->m_receivedStdOutChildLine.append(line);
|
||||
else
|
||||
m_tester->m_receivedStdErrChildLine.append(line);
|
||||
}
|
||||
|
||||
} // namespace ProjectExplorer
|
||||
|
@@ -81,10 +81,9 @@ class TestTerminator : public IOutputParser
|
||||
public:
|
||||
TestTerminator(OutputParserTester *t);
|
||||
|
||||
void stdOutput(const QString &line) override;
|
||||
void stdError(const QString &line) override;
|
||||
|
||||
private:
|
||||
void handleLine(const QString &line, Utils::OutputFormat type) override;
|
||||
|
||||
OutputParserTester *m_tester = nullptr;
|
||||
};
|
||||
|
||||
|
@@ -52,6 +52,14 @@ XcodebuildParser::XcodebuildParser()
|
||||
QTC_CHECK(m_buildRe.isValid());
|
||||
}
|
||||
|
||||
void XcodebuildParser::handleLine(const QString &line, OutputFormat type)
|
||||
{
|
||||
if (type == StdOutFormat)
|
||||
stdOutput(line);
|
||||
else
|
||||
stdError(line);
|
||||
}
|
||||
|
||||
bool XcodebuildParser::hasFatalErrors() const
|
||||
{
|
||||
return (m_fatalErrorCount > 0) || IOutputParser::hasFatalErrors();
|
||||
@@ -79,9 +87,9 @@ void XcodebuildParser::stdOutput(const QString &line)
|
||||
emit addTask(task, 1);
|
||||
return;
|
||||
}
|
||||
IOutputParser::stdError(line);
|
||||
IOutputParser::handleLine(line, StdErrFormat); // ??
|
||||
} else {
|
||||
IOutputParser::stdOutput(line);
|
||||
IOutputParser::handleLine(line, StdOutFormat);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +104,7 @@ void XcodebuildParser::stdError(const QString &line)
|
||||
return;
|
||||
}
|
||||
if (m_xcodeBuildParserState == OutsideXcodebuild) { // also forward if UnknownXcodebuildState ?
|
||||
IOutputParser::stdError(line);
|
||||
IOutputParser::handleLine(line, StdErrFormat);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@@ -46,11 +46,13 @@ public:
|
||||
|
||||
XcodebuildParser();
|
||||
|
||||
void stdOutput(const QString &line) override;
|
||||
void stdError(const QString &line) override;
|
||||
private:
|
||||
void handleLine(const QString &line, Utils::OutputFormat type) override;
|
||||
bool hasFatalErrors() const override;
|
||||
|
||||
private:
|
||||
void stdOutput(const QString &line);
|
||||
void stdError(const QString &line);
|
||||
|
||||
int m_fatalErrorCount = 0;
|
||||
QRegExp m_failureRe;
|
||||
QRegExp m_successRe;
|
||||
|
@@ -40,8 +40,12 @@ QMakeParser::QMakeParser() : m_error(QLatin1String("^(.+):(\\d+):\\s(.+)$"))
|
||||
m_error.setMinimal(true);
|
||||
}
|
||||
|
||||
void QMakeParser::stdError(const QString &line)
|
||||
void QMakeParser::handleLine(const QString &line, OutputFormat type)
|
||||
{
|
||||
if (type != Utils::StdErrFormat) {
|
||||
IOutputParser::handleLine(line, type);
|
||||
return;
|
||||
}
|
||||
QString lne = rightTrimmed(line);
|
||||
if (m_error.indexIn(lne) > -1) {
|
||||
QString fileName = m_error.cap(1);
|
||||
@@ -78,7 +82,7 @@ void QMakeParser::stdError(const QString &line)
|
||||
emit addTask(BuildSystemTask(Task::Warning, description), 1);
|
||||
return;
|
||||
}
|
||||
IOutputParser::stdError(line);
|
||||
IOutputParser::handleLine(line, StdErrFormat);
|
||||
}
|
||||
|
||||
} // QmakeProjectManager
|
||||
|
@@ -39,9 +39,10 @@ class QMAKEPROJECTMANAGER_EXPORT QMakeParser : public ProjectExplorer::IOutputPa
|
||||
|
||||
public:
|
||||
QMakeParser();
|
||||
void stdError(const QString &line) override;
|
||||
|
||||
private:
|
||||
void handleLine(const QString &line, Utils::OutputFormat type) override;
|
||||
|
||||
QRegExp m_error;
|
||||
};
|
||||
|
||||
|
@@ -43,8 +43,12 @@ QtParser::QtParser() :
|
||||
m_translationRegExp.setMinimal(true);
|
||||
}
|
||||
|
||||
void QtParser::stdError(const QString &line)
|
||||
void QtParser::handleLine(const QString &line, Utils::OutputFormat type)
|
||||
{
|
||||
if (type != Utils::StdErrFormat) {
|
||||
IOutputParser::handleLine(line, type);
|
||||
return;
|
||||
}
|
||||
QString lne = rightTrimmed(line);
|
||||
if (m_mocRegExp.indexIn(lne) > -1) {
|
||||
bool ok;
|
||||
@@ -72,7 +76,7 @@ void QtParser::stdError(const QString &line)
|
||||
emit addTask(task, 1);
|
||||
return;
|
||||
}
|
||||
IOutputParser::stdError(line);
|
||||
IOutputParser::handleLine(line, Utils::StdErrFormat);
|
||||
}
|
||||
|
||||
// Unit tests:
|
||||
|
@@ -40,9 +40,10 @@ class QTSUPPORT_EXPORT QtParser : public ProjectExplorer::IOutputParser
|
||||
|
||||
public:
|
||||
QtParser();
|
||||
void stdError(const QString &line) override;
|
||||
|
||||
private:
|
||||
void handleLine(const QString &line, Utils::OutputFormat type) override;
|
||||
|
||||
QRegExp m_mocRegExp;
|
||||
QRegExp m_translationRegExp;
|
||||
};
|
||||
|
@@ -47,8 +47,12 @@ using namespace Utils;
|
||||
namespace QtSupport {
|
||||
namespace Internal {
|
||||
|
||||
void QtTestParser::stdOutput(const QString &line)
|
||||
void QtTestParser::handleLine(const QString &line, OutputFormat type)
|
||||
{
|
||||
if (type != StdOutFormat) {
|
||||
IOutputParser::handleLine(line, type);
|
||||
return;
|
||||
}
|
||||
const QString theLine = rightTrimmed(line);
|
||||
static const QRegularExpression triggerPattern("^(?:XPASS|FAIL!) : .+$");
|
||||
QTC_CHECK(triggerPattern.isValid());
|
||||
@@ -59,7 +63,7 @@ void QtTestParser::stdOutput(const QString &line)
|
||||
return;
|
||||
}
|
||||
if (m_currentTask.isNull()) {
|
||||
IOutputParser::stdOutput(line);
|
||||
IOutputParser::handleLine(line, StdOutFormat);
|
||||
return;
|
||||
}
|
||||
static const QRegularExpression locationPattern(HostOsInfo::isWindowsHost()
|
||||
|
@@ -35,7 +35,7 @@ class QtTestParser : public ProjectExplorer::IOutputParser
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
void stdOutput(const QString &line) override;
|
||||
void handleLine(const QString &line, Utils::OutputFormat type) override;
|
||||
void doFlush() override { emitCurrentTask(); }
|
||||
|
||||
void emitCurrentTask();
|
||||
|
@@ -73,7 +73,7 @@ void CompilerOutputProcessor::start()
|
||||
connect(&parser, &ProjectExplorer::IOutputParser::addTask,
|
||||
this, &CompilerOutputProcessor::handleTask);
|
||||
while (!m_source.atEnd())
|
||||
parser.stdError(QString::fromLocal8Bit(m_source.readLine().trimmed()));
|
||||
parser.handleStderr(QString::fromLocal8Bit(m_source.readLine().trimmed()));
|
||||
QCoreApplication::quit();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user