aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/nim
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2020-04-08 17:45:39 +0200
committerChristian Kandeler <christian.kandeler@qt.io>2020-04-09 14:49:32 +0000
commit45ba9fcd535e4cfd5f057149b1ca4bb4dfed5bdb (patch)
tree3e3246ccf3d971e69004182007bd1b726b88b8bf /src/plugins/nim
parentfa517bd72aa21ea82072af27ce98030c4ff028f2 (diff)
Output parsers: Replace the chaining approach
Use "flat" aggregation instead. This is another step towards the formatter/parser merger. Along the way, also fix some some subclasses (mostly in BareMetal) that erroneously forwarded handled output to other parsers. Task-number: QTCREATORBUG-22665 Change-Id: I12947349ca663d2e6bbfc99efd069d69e2b54969 Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'src/plugins/nim')
-rw-r--r--src/plugins/nim/project/nimblebuildstep.cpp17
-rw-r--r--src/plugins/nim/project/nimcompilerbuildstep.cpp25
-rw-r--r--src/plugins/nim/project/nimtoolchain.cpp4
-rw-r--r--src/plugins/nim/project/nimtoolchain.h2
4 files changed, 19 insertions, 29 deletions
diff --git a/src/plugins/nim/project/nimblebuildstep.cpp b/src/plugins/nim/project/nimblebuildstep.cpp
index eb7a31f07a..36efa46313 100644
--- a/src/plugins/nim/project/nimblebuildstep.cpp
+++ b/src/plugins/nim/project/nimblebuildstep.cpp
@@ -45,15 +45,9 @@ namespace {
class NimParser : public IOutputParser
{
-private:
- void handleLine(const QString &line, Utils::OutputFormat type) override
- {
- parseLine(line.trimmed());
- IOutputParser::handleLine(line, type);
- }
-
- void parseLine(const QString &line)
+ Status doHandleLine(const QString &lne, Utils::OutputFormat) override
{
+ const QString line = lne.trimmed();
static QRegularExpression regex("(.+.nim)\\((\\d+), (\\d+)\\) (.+)",
QRegularExpression::OptimizeOnFirstUsageOption);
static QRegularExpression warning("(Warning):(.*)",
@@ -63,13 +57,13 @@ private:
QRegularExpressionMatch match = regex.match(line);
if (!match.hasMatch())
- return;
+ return Status::NotHandled;
const QString filename = match.captured(1);
bool lineOk = false;
const int lineNumber = match.captured(2).toInt(&lineOk);
const QString message = match.captured(4);
if (!lineOk)
- return;
+ return Status::NotHandled;
Task::TaskType type = Task::Unknown;
@@ -78,10 +72,11 @@ private:
else if (error.match(message).hasMatch())
type = Task::Error;
else
- return;
+ return Status::NotHandled;
emit addTask(CompileTask(type, message, absoluteFilePath(FilePath::fromUserInput(filename)),
lineNumber));
+ return Status::Done;
}
};
diff --git a/src/plugins/nim/project/nimcompilerbuildstep.cpp b/src/plugins/nim/project/nimcompilerbuildstep.cpp
index 071bc85cb2..8bdf39d576 100644
--- a/src/plugins/nim/project/nimcompilerbuildstep.cpp
+++ b/src/plugins/nim/project/nimcompilerbuildstep.cpp
@@ -47,14 +47,9 @@ namespace Nim {
class NimParser : public ProjectExplorer::IOutputParser
{
- void handleLine(const QString &line, Utils::OutputFormat type) override
- {
- parseLine(line.trimmed());
- IOutputParser::handleLine(line, type);
- }
-
- void parseLine(const QString &line)
+ Status doHandleLine(const QString &lne, Utils::OutputFormat) override
{
+ const QString line = lne.trimmed();
static QRegularExpression regex("(.+.nim)\\((\\d+), (\\d+)\\) (.+)",
QRegularExpression::OptimizeOnFirstUsageOption);
static QRegularExpression warning("(Warning):(.*)",
@@ -64,13 +59,13 @@ class NimParser : public ProjectExplorer::IOutputParser
QRegularExpressionMatch match = regex.match(line);
if (!match.hasMatch())
- return;
+ return Status::NotHandled;
const QString filename = match.captured(1);
bool lineOk = false;
const int lineNumber = match.captured(2).toInt(&lineOk);
const QString message = match.captured(4);
if (!lineOk)
- return;
+ return Status::NotHandled;
Task::TaskType type = Task::Unknown;
@@ -79,10 +74,11 @@ class NimParser : public ProjectExplorer::IOutputParser
else if (error.match(message).hasMatch())
type = Task::Error;
else
- return;
+ return Status::NotHandled;
emit addTask(CompileTask(type, message, absoluteFilePath(FilePath::fromUserInput(filename)),
lineNumber));
+ return Status::Done;
}
};
@@ -107,8 +103,7 @@ NimCompilerBuildStep::NimCompilerBuildStep(BuildStepList *parentList, Core::Id i
bool NimCompilerBuildStep::init()
{
setOutputParser(new NimParser());
- if (IOutputParser *parser = target()->kit()->createOutputParser())
- appendOutputParser(parser);
+ appendOutputParsers(target()->kit()->createOutputParsers());
outputParser()->addSearchDir(processParameters()->effectiveWorkingDirectory());
return AbstractProcessStep::init();
}
@@ -308,7 +303,7 @@ void NimPlugin::testNimParser_data()
QTest::newRow("Parse error string")
<< QString::fromLatin1("main.nim(23, 1) Error: undeclared identifier: 'x'")
<< OutputParserTester::STDERR
- << QString("") << QString("main.nim(23, 1) Error: undeclared identifier: 'x'\n")
+ << QString() << QString()
<< Tasks({CompileTask(Task::Error,
"Error: undeclared identifier: 'x'",
FilePath::fromUserInput("main.nim"), 23)})
@@ -317,7 +312,7 @@ void NimPlugin::testNimParser_data()
QTest::newRow("Parse warning string")
<< QString::fromLatin1("lib/pure/parseopt.nim(56, 34) Warning: quoteIfContainsWhite is deprecated [Deprecated]")
<< OutputParserTester::STDERR
- << QString("") << QString("lib/pure/parseopt.nim(56, 34) Warning: quoteIfContainsWhite is deprecated [Deprecated]\n")
+ << QString() << QString()
<< Tasks({CompileTask(Task::Warning,
"Warning: quoteIfContainsWhite is deprecated [Deprecated]",
FilePath::fromUserInput("lib/pure/parseopt.nim"), 56)})
@@ -327,7 +322,7 @@ void NimPlugin::testNimParser_data()
void NimPlugin::testNimParser()
{
OutputParserTester testbench;
- testbench.appendOutputParser(new NimParser);
+ testbench.addLineParser(new NimParser);
QFETCH(QString, input);
QFETCH(OutputParserTester::Channel, inputChannel);
QFETCH(Tasks, tasks);
diff --git a/src/plugins/nim/project/nimtoolchain.cpp b/src/plugins/nim/project/nimtoolchain.cpp
index 031557c889..7aed9dacf6 100644
--- a/src/plugins/nim/project/nimtoolchain.cpp
+++ b/src/plugins/nim/project/nimtoolchain.cpp
@@ -120,9 +120,9 @@ void NimToolChain::setCompilerCommand(const FilePath &compilerCommand)
parseVersion(compilerCommand, m_version);
}
-IOutputParser *NimToolChain::outputParser() const
+QList<IOutputParser *> NimToolChain::outputParsers() const
{
- return nullptr;
+ return {};
}
std::unique_ptr<ProjectExplorer::ToolChainConfigWidget> NimToolChain::createConfigurationWidget()
diff --git a/src/plugins/nim/project/nimtoolchain.h b/src/plugins/nim/project/nimtoolchain.h
index a140f1444f..df21587776 100644
--- a/src/plugins/nim/project/nimtoolchain.h
+++ b/src/plugins/nim/project/nimtoolchain.h
@@ -56,7 +56,7 @@ public:
Utils::FilePath compilerCommand() const final;
QString compilerVersion() const;
void setCompilerCommand(const Utils::FilePath &compilerCommand);
- ProjectExplorer::IOutputParser *outputParser() const final;
+ QList<ProjectExplorer::IOutputParser *> outputParsers() const final;
std::unique_ptr<ProjectExplorer::ToolChainConfigWidget> createConfigurationWidget() final;
QVariantMap toMap() const final;