aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/baremetal/iarewparser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/baremetal/iarewparser.cpp')
-rw-r--r--src/plugins/baremetal/iarewparser.cpp153
1 files changed, 58 insertions, 95 deletions
diff --git a/src/plugins/baremetal/iarewparser.cpp b/src/plugins/baremetal/iarewparser.cpp
index 2686f58d90..314c471400 100644
--- a/src/plugins/baremetal/iarewparser.cpp
+++ b/src/plugins/baremetal/iarewparser.cpp
@@ -28,9 +28,6 @@
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/task.h>
-#include <texteditor/fontsettings.h>
-#include <texteditor/texteditorsettings.h>
-
#include <QRegularExpression>
using namespace ProjectExplorer;
@@ -57,40 +54,18 @@ IarParser::IarParser()
setObjectName("IarParser");
}
-Core::Id IarParser::id()
+Utils::Id IarParser::id()
{
return "BareMetal.OutputParser.Iar";
}
void IarParser::newTask(const Task &task)
{
- doFlush();
+ flush();
m_lastTask = task;
m_lines = 1;
}
-void IarParser::amendDescription()
-{
- while (!m_descriptionParts.isEmpty())
- m_lastTask.description.append(m_descriptionParts.takeFirst());
-
- while (!m_snippets.isEmpty()) {
- const QString snippet = m_snippets.takeFirst();
- const int start = m_lastTask.description.count() + 1;
- m_lastTask.description.append('\n');
- m_lastTask.description.append(snippet);
-
- QTextLayout::FormatRange fr;
- fr.start = start;
- fr.length = m_lastTask.description.count() + 1;
- fr.format.setFont(TextEditor::TextEditorSettings::fontSettings().font());
- fr.format.setFontStyleHint(QFont::Monospace);
- m_lastTask.formats.append(fr);
-
- ++m_lines;
- }
-}
-
void IarParser::amendFilePath()
{
if (m_filePathParts.isEmpty())
@@ -145,12 +120,12 @@ bool IarParser::parseErrorOrFatalErrorDetailsMessage2(const QString &lne)
return true;
}
-bool IarParser::parseWarningOrErrorOrFatalErrorDetailsMessage1(const QString &lne)
+OutputLineParser::Result IarParser::parseWarningOrErrorOrFatalErrorDetailsMessage1(const QString &lne)
{
const QRegularExpression re("^\"(.+)\",(\\d+)?\\s+(Warning|Error|Fatal error)\\[(.+)\\].+$");
const QRegularExpressionMatch match = re.match(lne);
if (!match.hasMatch())
- return false;
+ return Status::NotHandled;
enum CaptureIndex { FilePathIndex = 1, LineNumberIndex,
MessageTypeIndex, MessageCodeIndex };
const Utils::FilePath fileName = Utils::FilePath::fromUserInput(
@@ -158,13 +133,16 @@ bool IarParser::parseWarningOrErrorOrFatalErrorDetailsMessage1(const QString &ln
const int lineno = match.captured(LineNumberIndex).toInt();
const Task::TaskType type = taskType(match.captured(MessageTypeIndex));
// A full description will be received later on next lines.
- newTask(CompileTask(type, {}, fileName, lineno));
+ newTask(CompileTask(type, {}, absoluteFilePath(fileName), lineno));
const QString firstPart = QString("[%1]: ").arg(match.captured(MessageCodeIndex));
m_descriptionParts.append(firstPart);
m_expectDescription = true;
m_expectSnippet = false;
m_expectFilePath = false;
- return true;
+ LinkSpecs linkSpecs;
+ addLinkSpecForAbsoluteFilePath(linkSpecs, m_lastTask.file, m_lastTask.line, match,
+ FilePathIndex);
+ return {Status::InProgress, linkSpecs};
}
bool IarParser::parseErrorInCommandLineMessage(const QString &lne)
@@ -190,67 +168,70 @@ bool IarParser::parseErrorMessage1(const QString &lne)
return true;
}
-void IarParser::stdError(const QString &line)
+OutputLineParser::Result IarParser::handleLine(const QString &line, OutputFormat type)
{
- IOutputParser::stdError(line);
-
const QString lne = rightTrimmed(line);
+ if (type == StdOutFormat) {
+ // The call sequence has the meaning!
+ const bool leastOneParsed = parseErrorInCommandLineMessage(lne)
+ || parseErrorMessage1(lne);
+ if (!leastOneParsed) {
+ flush();
+ return Status::NotHandled;
+ }
+ return Status::InProgress;
+ }
if (parseErrorOrFatalErrorDetailsMessage1(lne))
- return;
+ return Status::InProgress;
if (parseErrorOrFatalErrorDetailsMessage2(lne))
- return;
- if (parseWarningOrErrorOrFatalErrorDetailsMessage1(lne))
- return;
+ return Status::InProgress;
+ const Result res = parseWarningOrErrorOrFatalErrorDetailsMessage1(lne);
+ if (res.status != Status::NotHandled)
+ return res;
- if (lne.isEmpty()) {
- //
- } else if (!lne.startsWith(' ')) {
- return;
- } else if (m_expectFilePath) {
+ if (m_expectFilePath) {
if (lne.endsWith(']')) {
const QString lastPart = lne.left(lne.size() - 1);
m_filePathParts.push_back(lastPart);
+ flush();
+ return Status::Done;
} else {
m_filePathParts.push_back(lne);
- return;
+ return Status::InProgress;
}
- } else if (m_expectSnippet) {
+ }
+ if (m_expectSnippet && lne.startsWith(' ')) {
if (!lne.endsWith("Fatal error detected, aborting.")) {
m_snippets.push_back(lne);
- return;
+ return Status::InProgress;
}
} else if (m_expectDescription) {
if (!lne.startsWith(" ")) {
m_descriptionParts.push_back(lne.trimmed());
- return;
+ return Status::InProgress;
}
}
- doFlush();
-}
-
-void IarParser::stdOutput(const QString &line)
-{
- IOutputParser::stdOutput(line);
-
- const QString lne = rightTrimmed(line);
-
- // The call sequence has the meaning!
- const bool leastOneParsed = parseErrorInCommandLineMessage(lne)
- || parseErrorMessage1(lne);
- if (!leastOneParsed)
- return;
+ if (!m_lastTask.isNull()) {
+ flush();
+ return Status::Done;
+ }
- doFlush();
+ return Status::NotHandled;
}
-void IarParser::doFlush()
+void IarParser::flush()
{
if (m_lastTask.isNull())
return;
- amendDescription();
+ while (!m_descriptionParts.isEmpty())
+ m_lastTask.summary.append(m_descriptionParts.takeFirst());
+ m_lastTask.details = m_snippets;
+ m_snippets.clear();
+ m_lines += m_lastTask.details.count();
+ setDetailsFormat(m_lastTask);
amendFilePath();
m_expectSnippet = true;
@@ -259,7 +240,7 @@ void IarParser::doFlush()
Task t = m_lastTask;
m_lastTask.clear();
- emit addTask(t, m_lines, 1);
+ scheduleTask(t, m_lines, 1);
m_lines = 0;
}
@@ -300,7 +281,7 @@ void BareMetalPlugin::testIarOutputParsers_data()
QTest::newRow("Error in command line")
<< QString::fromLatin1("Error in command line: Some error")
<< OutputParserTester::STDOUT
- << QString::fromLatin1("Error in command line: Some error\n")
+ << QString()
<< QString()
<< (Tasks() << CompileTask(Task::Error,
"Error in command line: Some error"))
@@ -309,7 +290,7 @@ void BareMetalPlugin::testIarOutputParsers_data()
QTest::newRow("Linker error")
<< QString::fromLatin1("Error[e46]: Some error")
<< OutputParserTester::STDOUT
- << QString::fromLatin1("Error[e46]: Some error\n")
+ << QString()
<< QString()
<< (Tasks() << CompileTask(Task::Error,
"[e46]: Some error"))
@@ -321,8 +302,7 @@ void BareMetalPlugin::testIarOutputParsers_data()
" Some warning \"foo\" bar")
<< OutputParserTester::STDERR
<< QString()
- << QString::fromLatin1("\"c:\\foo\\main.c\",63 Warning[Pe223]:\n"
- " Some warning \"foo\" bar\n")
+ << QString()
<< (Tasks() << CompileTask(Task::Warning,
"[Pe223]: Some warning \"foo\" bar",
Utils::FilePath::fromUserInput("c:\\foo\\main.c"),
@@ -336,10 +316,7 @@ void BareMetalPlugin::testIarOutputParsers_data()
" Some warning")
<< OutputParserTester::STDERR
<< QString()
- << QString::fromLatin1(" some_detail;\n"
- " ^\n"
- "\"c:\\foo\\main.c\",63 Warning[Pe223]:\n"
- " Some warning\n")
+ << QString()
<< (Tasks() << CompileTask(Task::Warning,
"[Pe223]: Some warning\n"
" some_detail;\n"
@@ -354,9 +331,7 @@ void BareMetalPlugin::testIarOutputParsers_data()
" , split")
<< OutputParserTester::STDERR
<< QString()
- << QString::fromLatin1("\"c:\\foo\\main.c\",63 Warning[Pe223]:\n"
- " Some warning\n"
- " , split\n")
+ << QString()
<< (Tasks() << CompileTask(Task::Warning,
"[Pe223]: Some warning, split",
FilePath::fromUserInput("c:\\foo\\main.c"),
@@ -368,8 +343,7 @@ void BareMetalPlugin::testIarOutputParsers_data()
" Some error")
<< OutputParserTester::STDERR
<< QString()
- << QString::fromLatin1("\"c:\\foo\\main.c\",63 Error[Pe223]:\n"
- " Some error\n")
+ << QString()
<< (Tasks() << CompileTask(Task::Error,
"[Pe223]: Some error",
FilePath::fromUserInput("c:\\foo\\main.c"),
@@ -383,10 +357,7 @@ void BareMetalPlugin::testIarOutputParsers_data()
" Some error")
<< OutputParserTester::STDERR
<< QString()
- << QString::fromLatin1(" some_detail;\n"
- " ^\n"
- "\"c:\\foo\\main.c\",63 Error[Pe223]:\n"
- " Some error\n")
+ << QString()
<< (Tasks() << CompileTask(Task::Error,
"[Pe223]: Some error\n"
" some_detail;\n"
@@ -401,9 +372,7 @@ void BareMetalPlugin::testIarOutputParsers_data()
" , split")
<< OutputParserTester::STDERR
<< QString()
- << QString::fromLatin1("\"c:\\foo\\main.c\",63 Error[Pe223]:\n"
- " Some error\n"
- " , split\n")
+ << QString()
<< (Tasks() << CompileTask(Task::Error,
"[Pe223]: Some error, split",
FilePath::fromUserInput("c:\\foo\\main.c"),
@@ -417,10 +386,7 @@ void BareMetalPlugin::testIarOutputParsers_data()
"]")
<< OutputParserTester::STDERR
<< QString()
- << QString::fromLatin1("Error[Li005]: Some error \"foo\" [referenced from c:\\fo\n"
- " o\\bar\\mai\n"
- " n.c.o\n"
- "]\n")
+ << QString()
<< (Tasks() << CompileTask(Task::Error,
"[Li005]: Some error \"foo\"",
FilePath::fromUserInput("c:\\foo\\bar\\main.c.o")))
@@ -433,10 +399,7 @@ void BareMetalPlugin::testIarOutputParsers_data()
"Fatal error detected, aborting.")
<< OutputParserTester::STDERR
<< QString()
- << QString::fromLatin1("Fatal error[Su011]: Some error:\n"
- " c:\\foo.c\n"
- " c:\\bar.c\n"
- "Fatal error detected, aborting.\n")
+ << QString()
<< (Tasks() << CompileTask(Task::Error,
"[Su011]: Some error:\n"
" c:\\foo.c\n"
@@ -447,7 +410,7 @@ void BareMetalPlugin::testIarOutputParsers_data()
<< QString::fromLatin1("At end of source Error[Pe040]: Some error \";\"")
<< OutputParserTester::STDERR
<< QString()
- << QString::fromLatin1("At end of source Error[Pe040]: Some error \";\"\n")
+ << QString()
<< (Tasks() << CompileTask(Task::Error,
"[Pe040]: Some error \";\""))
<< QString();
@@ -456,7 +419,7 @@ void BareMetalPlugin::testIarOutputParsers_data()
void BareMetalPlugin::testIarOutputParsers()
{
OutputParserTester testbench;
- testbench.appendOutputParser(new IarParser);
+ testbench.addLineParser(new IarParser);
QFETCH(QString, input);
QFETCH(OutputParserTester::Channel, inputChannel);
QFETCH(Tasks, tasks);