ProjectManager: Add convenience Task subclasses

For Compile, BuildSystem and Deployment. Unclutters user code and reduces
binary size.

Change-Id: Ia18e917bb411754162e9f4ec6056d752a020bb50
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2020-01-15 08:56:11 +01:00
parent 7e19d1af7c
commit 0334b6e491
56 changed files with 1233 additions and 1548 deletions

View File

@@ -34,6 +34,7 @@
#include <QRegularExpression>
using namespace ProjectExplorer;
using namespace Utils;
namespace BareMetal {
namespace Internal {
@@ -114,8 +115,7 @@ bool IarParser::parseErrorOrFatalErrorDetailsMessage1(const QString &lne)
match.captured(DescriptionIndex));
// This task has a file path, but this patch are split on
// some lines, which will be received later.
const Task task(type, descr, {}, -1, Constants::TASK_CATEGORY_COMPILE);
newTask(task);
newTask(CompileTask(type, descr));
// Prepare first part of a file path.
QString firstPart = match.captured(FilepathBeginIndex);
firstPart.remove("referenced from ");
@@ -138,8 +138,7 @@ bool IarParser::parseErrorOrFatalErrorDetailsMessage2(const QString &lne)
match.captured(DescriptionIndex));
// This task has not a file path. The description details
// will be received later on the next lines.
const Task task(type, descr, {}, -1, Constants::TASK_CATEGORY_COMPILE);
newTask(task);
newTask(CompileTask(type, descr));
m_expectSnippet = true;
m_expectFilePath = false;
m_expectDescription = false;
@@ -159,8 +158,7 @@ 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.
const Task task(type, {}, fileName, lineno, Constants::TASK_CATEGORY_COMPILE);
newTask(task);
newTask(CompileTask(type, {}, fileName, lineno));
const QString firstPart = QString("[%1]: ").arg(match.captured(MessageCodeIndex));
m_descriptionParts.append(firstPart);
m_expectDescription = true;
@@ -173,9 +171,7 @@ bool IarParser::parseErrorInCommandLineMessage(const QString &lne)
{
if (!lne.startsWith("Error in command line"))
return false;
const Task task(Task::TaskType::Error, lne.trimmed(), {},
-1, Constants::TASK_CATEGORY_COMPILE);
newTask(task);
newTask(CompileTask(Task::TaskType::Error, lne.trimmed()));
return true;
}
@@ -190,8 +186,7 @@ bool IarParser::parseErrorMessage1(const QString &lne)
const QString descr = QString("[%1]: %2").arg(match.captured(MessageCodeIndex),
match.captured(DescriptionIndex));
// This task has not a file path and line number (as it is a linker message)
const Task task(type, descr, {}, -1, Constants::TASK_CATEGORY_COMPILE);
newTask(task);
newTask(CompileTask(type, descr));
return true;
}
@@ -301,19 +296,14 @@ void BareMetalPlugin::testIarOutputParsers_data()
<< Tasks()
<< QString();
const Core::Id categoryCompile = Constants::TASK_CATEGORY_COMPILE;
// For std out.
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()
<< (Tasks() << Task(Task::Error,
"Error in command line: Some error",
Utils::FilePath(),
-1,
categoryCompile))
<< (Tasks() << CompileTask(Task::Error,
"Error in command line: Some error"))
<< QString();
QTest::newRow("Linker error")
@@ -321,11 +311,8 @@ void BareMetalPlugin::testIarOutputParsers_data()
<< OutputParserTester::STDOUT
<< QString::fromLatin1("Error[e46]: Some error\n")
<< QString()
<< (Tasks() << Task(Task::Error,
"[e46]: Some error",
Utils::FilePath(),
-1,
categoryCompile))
<< (Tasks() << CompileTask(Task::Error,
"[e46]: Some error"))
<< QString();
// For std error.
@@ -336,11 +323,10 @@ void BareMetalPlugin::testIarOutputParsers_data()
<< QString()
<< QString::fromLatin1("\"c:\\foo\\main.c\",63 Warning[Pe223]:\n"
" Some warning \"foo\" bar\n")
<< (Tasks() << Task(Task::Warning,
"[Pe223]: Some warning \"foo\" bar",
Utils::FilePath::fromUserInput("c:\\foo\\main.c"),
63,
categoryCompile))
<< (Tasks() << CompileTask(Task::Warning,
"[Pe223]: Some warning \"foo\" bar",
Utils::FilePath::fromUserInput("c:\\foo\\main.c"),
63))
<< QString();
QTest::newRow("Details warning")
@@ -354,13 +340,12 @@ void BareMetalPlugin::testIarOutputParsers_data()
" ^\n"
"\"c:\\foo\\main.c\",63 Warning[Pe223]:\n"
" Some warning\n")
<< (Tasks() << Task(Task::Warning,
"[Pe223]: Some warning\n"
" some_detail;\n"
" ^",
Utils::FilePath::fromUserInput("c:\\foo\\main.c"),
63,
categoryCompile))
<< (Tasks() << CompileTask(Task::Warning,
"[Pe223]: Some warning\n"
" some_detail;\n"
" ^",
FilePath::fromUserInput("c:\\foo\\main.c"),
63))
<< QString();
QTest::newRow("No details split-description warning")
@@ -372,11 +357,10 @@ void BareMetalPlugin::testIarOutputParsers_data()
<< QString::fromLatin1("\"c:\\foo\\main.c\",63 Warning[Pe223]:\n"
" Some warning\n"
" , split\n")
<< (Tasks() << Task(Task::Warning,
"[Pe223]: Some warning, split",
Utils::FilePath::fromUserInput("c:\\foo\\main.c"),
63,
categoryCompile))
<< (Tasks() << CompileTask(Task::Warning,
"[Pe223]: Some warning, split",
FilePath::fromUserInput("c:\\foo\\main.c"),
63))
<< QString();
QTest::newRow("No details error")
@@ -386,11 +370,10 @@ void BareMetalPlugin::testIarOutputParsers_data()
<< QString()
<< QString::fromLatin1("\"c:\\foo\\main.c\",63 Error[Pe223]:\n"
" Some error\n")
<< (Tasks() << Task(Task::Error,
"[Pe223]: Some error",
Utils::FilePath::fromUserInput("c:\\foo\\main.c"),
63,
categoryCompile))
<< (Tasks() << CompileTask(Task::Error,
"[Pe223]: Some error",
FilePath::fromUserInput("c:\\foo\\main.c"),
63))
<< QString();
QTest::newRow("Details error")
@@ -404,13 +387,12 @@ void BareMetalPlugin::testIarOutputParsers_data()
" ^\n"
"\"c:\\foo\\main.c\",63 Error[Pe223]:\n"
" Some error\n")
<< (Tasks() << Task(Task::Error,
"[Pe223]: Some error\n"
" some_detail;\n"
" ^",
Utils::FilePath::fromUserInput("c:\\foo\\main.c"),
63,
categoryCompile))
<< (Tasks() << CompileTask(Task::Error,
"[Pe223]: Some error\n"
" some_detail;\n"
" ^",
FilePath::fromUserInput("c:\\foo\\main.c"),
63))
<< QString();
QTest::newRow("No details split-description error")
@@ -422,11 +404,10 @@ void BareMetalPlugin::testIarOutputParsers_data()
<< QString::fromLatin1("\"c:\\foo\\main.c\",63 Error[Pe223]:\n"
" Some error\n"
" , split\n")
<< (Tasks() << Task(Task::Error,
"[Pe223]: Some error, split",
Utils::FilePath::fromUserInput("c:\\foo\\main.c"),
63,
categoryCompile))
<< (Tasks() << CompileTask(Task::Error,
"[Pe223]: Some error, split",
FilePath::fromUserInput("c:\\foo\\main.c"),
63))
<< QString();
QTest::newRow("No definition for")
@@ -440,11 +421,9 @@ void BareMetalPlugin::testIarOutputParsers_data()
" o\\bar\\mai\n"
" n.c.o\n"
"]\n")
<< (Tasks() << Task(Task::Error,
"[Li005]: Some error \"foo\"",
Utils::FilePath::fromUserInput("c:\\foo\\bar\\main.c.o"),
-1,
categoryCompile))
<< (Tasks() << CompileTask(Task::Error,
"[Li005]: Some error \"foo\"",
FilePath::fromUserInput("c:\\foo\\bar\\main.c.o")))
<< QString();
QTest::newRow("More than one source file specified")
@@ -458,13 +437,10 @@ void BareMetalPlugin::testIarOutputParsers_data()
" c:\\foo.c\n"
" c:\\bar.c\n"
"Fatal error detected, aborting.\n")
<< (Tasks() << Task(Task::Error,
"[Su011]: Some error:\n"
" c:\\foo.c\n"
" c:\\bar.c",
Utils::FilePath(),
-1,
categoryCompile))
<< (Tasks() << CompileTask(Task::Error,
"[Su011]: Some error:\n"
" c:\\foo.c\n"
" c:\\bar.c"))
<< QString();
QTest::newRow("At end of source")
@@ -472,11 +448,8 @@ void BareMetalPlugin::testIarOutputParsers_data()
<< OutputParserTester::STDERR
<< QString()
<< QString::fromLatin1("At end of source Error[Pe040]: Some error \";\"\n")
<< (Tasks() << Task(Task::Error,
"[Pe040]: Some error \";\"",
Utils::FilePath(),
-1,
categoryCompile))
<< (Tasks() << CompileTask(Task::Error,
"[Pe040]: Some error \";\""))
<< QString();
}