Fix icons in tasks

Create Tasks in such a way that they have the correct TaskType from
the start. This makes sure the icon chosen by default is the correct
one for that type and avoids the need to override the icon again later.

Change-Id: Ic47f1d119a7d8f85fcb6f2ee9aaaeadf074f8348
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
Tobias Hunger
2014-01-14 10:28:16 +01:00
parent e6b8f046e4
commit fbd9a3509e
6 changed files with 55 additions and 61 deletions

View File

@@ -33,6 +33,15 @@
using namespace ProjectExplorer; using namespace ProjectExplorer;
static Task::TaskType taskType(const QString &capture)
{
if (capture == QLatin1String("warning"))
return Task::Warning;
else if (capture == QLatin1String("note"))
return Task::Unknown;
return Task::Error;
}
// opt. drive letter + filename: (2 brackets) // opt. drive letter + filename: (2 brackets)
static const char * const FILE_PATTERN = "(<command line>|([A-Za-z]:)?[^:]+\\.[^:]+)"; static const char * const FILE_PATTERN = "(<command line>|([A-Za-z]:)?[^:]+\\.[^:]+)";
@@ -60,15 +69,11 @@ void ClangParser::stdError(const QString &line)
if (m_commandRegExp.indexIn(lne) > -1) { if (m_commandRegExp.indexIn(lne) > -1) {
m_expectSnippet = true; m_expectSnippet = true;
Task task(Task::Error, Task task(taskType(m_commandRegExp.cap(3)),
m_commandRegExp.cap(4), m_commandRegExp.cap(4),
Utils::FileName(), /* filename */ Utils::FileName(), /* filename */
-1, /* line */ -1, /* line */
Constants::TASK_CATEGORY_COMPILE); Constants::TASK_CATEGORY_COMPILE);
if (m_commandRegExp.cap(3) == QLatin1String("warning"))
task.type = Task::Warning;
else if (m_commandRegExp.cap(3) == QLatin1String("note"))
task.type = Task::Unknown;
newTask(task); newTask(task);
return; return;
} }
@@ -89,15 +94,11 @@ void ClangParser::stdError(const QString &line)
int lineNo = m_messageRegExp.cap(4).toInt(&ok); int lineNo = m_messageRegExp.cap(4).toInt(&ok);
if (!ok) if (!ok)
lineNo = m_messageRegExp.cap(5).toInt(&ok); lineNo = m_messageRegExp.cap(5).toInt(&ok);
Task task(Task::Error, Task task(taskType(m_messageRegExp.cap(7)),
m_messageRegExp.cap(8), m_messageRegExp.cap(8),
Utils::FileName::fromUserInput(m_messageRegExp.cap(1)), /* filename */ Utils::FileName::fromUserInput(m_messageRegExp.cap(1)), /* filename */
lineNo, lineNo,
Core::Id(Constants::TASK_CATEGORY_COMPILE)); Core::Id(Constants::TASK_CATEGORY_COMPILE));
if (m_messageRegExp.cap(7) == QLatin1String("warning"))
task.type = Task::Warning;
else if (m_messageRegExp.cap(7) == QLatin1String("note"))
task.type = Task::Unknown;
newTask(task); newTask(task);
return; return;
} }

View File

@@ -87,38 +87,34 @@ void GccParser::stdError(const QString &line)
return; return;
} else if (m_regExpGccNames.indexIn(lne) > -1) { } else if (m_regExpGccNames.indexIn(lne) > -1) {
QString description = lne.mid(m_regExpGccNames.matchedLength()); QString description = lne.mid(m_regExpGccNames.matchedLength());
Task task(Task::Error, Task::TaskType type = Task::Error;
description,
Utils::FileName(), /* filename */
-1, /* line */
Constants::TASK_CATEGORY_COMPILE);
if (description.startsWith(QLatin1String("warning: "))) { if (description.startsWith(QLatin1String("warning: "))) {
task.type = Task::Warning; type = Task::Warning;
task.description = description.mid(9); description = description.mid(9);
} else if (description.startsWith(QLatin1String("fatal: "))) { } else if (description.startsWith(QLatin1String("fatal: "))) {
task.description = description.mid(7); description = description.mid(7);
} }
Task task(type, description, Utils::FileName(), /* filename */
-1, /* line */ Constants::TASK_CATEGORY_COMPILE);
newTask(task); newTask(task);
return; return;
} else if (m_regExp.indexIn(lne) > -1) { } else if (m_regExp.indexIn(lne) > -1) {
Utils::FileName filename = Utils::FileName::fromUserInput(m_regExp.cap(1)); Utils::FileName filename = Utils::FileName::fromUserInput(m_regExp.cap(1));
int lineno = m_regExp.cap(3).toInt(); int lineno = m_regExp.cap(3).toInt();
Task task(Task::Unknown, Task::TaskType type = Task::Unknown;
m_regExp.cap(8) /* description */, QString description = m_regExp.cap(8);
filename, lineno,
Constants::TASK_CATEGORY_COMPILE);
if (m_regExp.cap(7) == QLatin1String("warning")) if (m_regExp.cap(7) == QLatin1String("warning"))
task.type = Task::Warning; type = Task::Warning;
else if (m_regExp.cap(7) == QLatin1String("error") || else if (m_regExp.cap(7) == QLatin1String("error") ||
task.description.startsWith(QLatin1String("undefined reference to")) || description.startsWith(QLatin1String("undefined reference to")) ||
task.description.startsWith(QLatin1String("multiple definition of"))) description.startsWith(QLatin1String("multiple definition of")))
task.type = Task::Error; type = Task::Error;
// Prepend "#warning" or "#error" if that triggered the match on (warning|error) // Prepend "#warning" or "#error" if that triggered the match on (warning|error)
// We want those to show how the warning was triggered // We want those to show how the warning was triggered
if (m_regExp.cap(5).startsWith(QLatin1Char('#'))) if (m_regExp.cap(5).startsWith(QLatin1Char('#')))
task.description = m_regExp.cap(5) + task.description; description = m_regExp.cap(5) + description;
Task task(type, description, filename, lineno, Constants::TASK_CATEGORY_COMPILE);
newTask(task); newTask(task);
return; return;
} else if (m_regExpIncluded.indexIn(lne) > -1) { } else if (m_regExpIncluded.indexIn(lne) > -1) {

View File

@@ -78,17 +78,15 @@ void LdParser::stdError(const QString &line)
return; return;
} else if (m_regExpGccNames.indexIn(lne) > -1) { } else if (m_regExpGccNames.indexIn(lne) > -1) {
QString description = lne.mid(m_regExpGccNames.matchedLength()); QString description = lne.mid(m_regExpGccNames.matchedLength());
Task task(Task::Error, Task::TaskType type = Task::Error;
description,
Utils::FileName(), /* filename */
-1, /* line */
Constants::TASK_CATEGORY_COMPILE);
if (description.startsWith(QLatin1String("warning: "))) { if (description.startsWith(QLatin1String("warning: "))) {
task.type = Task::Warning; type = Task::Warning;
task.description = description.mid(9); description = description.mid(9);
} else if (description.startsWith(QLatin1String("fatal: "))) { } else if (description.startsWith(QLatin1String("fatal: "))) {
task.description = description.mid(7); description = description.mid(7);
} }
Task task(type, description, Utils::FileName() /* filename */, -1 /* line */,
Constants::TASK_CATEGORY_COMPILE);
emit addTask(task); emit addTask(task);
return; return;
} else if (m_regExpLinker.indexIn(lne) > -1) { } else if (m_regExpLinker.indexIn(lne) > -1) {
@@ -104,20 +102,18 @@ void LdParser::stdError(const QString &line)
filename = Utils::FileName::fromUserInput(sourceFileName); filename = Utils::FileName::fromUserInput(sourceFileName);
} }
QString description = m_regExpLinker.cap(8).trimmed(); QString description = m_regExpLinker.cap(8).trimmed();
Task task(Task::Error, description, filename, lineno, Task::TaskType type = Task::Error;
Constants::TASK_CATEGORY_COMPILE);
if (description.startsWith(QLatin1String("At global scope")) || if (description.startsWith(QLatin1String("At global scope")) ||
description.startsWith(QLatin1String("At top level")) || description.startsWith(QLatin1String("At top level")) ||
description.startsWith(QLatin1String("instantiated from ")) || description.startsWith(QLatin1String("instantiated from ")) ||
description.startsWith(QLatin1String("In ")) || description.startsWith(QLatin1String("In ")) ||
description.startsWith(QLatin1String("first defined here"))) { description.startsWith(QLatin1String("first defined here"))) {
task.type = Task::Unknown; type = Task::Unknown;
} else if (description.startsWith(QLatin1String("warning: "), Qt::CaseInsensitive)) {
type = Task::Warning;
description = description.mid(9);
} }
if (description.startsWith(QLatin1String("warning: "), Qt::CaseInsensitive)) { Task task(type, description, filename, lineno, Constants::TASK_CATEGORY_COMPILE);
task.type = Task::Warning;
task.description = description.mid(9);
}
emit addTask(task); emit addTask(task);
return; return;
} }

View File

@@ -67,15 +67,16 @@ void LinuxIccParser::stdError(const QString &line)
{ {
if (m_expectFirstLine && m_firstLine.indexIn(line) != -1) { if (m_expectFirstLine && m_firstLine.indexIn(line) != -1) {
// Clear out old task // Clear out old task
m_temporary = ProjectExplorer::Task(Task::Unknown, m_firstLine.cap(6).trimmed(), Task::TaskType type = Task::Unknown;
QString category = m_firstLine.cap(4);
if (category == QLatin1String("error"))
type = Task::Error;
else if (category == QLatin1String("warning"))
type = Task::Warning;
m_temporary = ProjectExplorer::Task(type, m_firstLine.cap(6).trimmed(),
Utils::FileName::fromUserInput(m_firstLine.cap(1)), Utils::FileName::fromUserInput(m_firstLine.cap(1)),
m_firstLine.cap(2).toInt(), m_firstLine.cap(2).toInt(),
Constants::TASK_CATEGORY_COMPILE); Constants::TASK_CATEGORY_COMPILE);
QString category = m_firstLine.cap(4);
if (category == QLatin1String("error"))
m_temporary.type = Task::Error;
else if (category == QLatin1String("warning"))
m_temporary.type = Task::Warning;
m_expectFirstLine = false; m_expectFirstLine = false;
} else if (!m_expectFirstLine && m_caretLine.indexIn(line) != -1) { } else if (!m_expectFirstLine && m_caretLine.indexIn(line) != -1) {

View File

@@ -157,15 +157,15 @@ bool MsvcParser::processCompileLine(const QString &line)
if (m_compileRegExp.indexIn(line) > -1) { if (m_compileRegExp.indexIn(line) > -1) {
QPair<Utils::FileName, int> position = parseFileName( m_compileRegExp.cap(1)); QPair<Utils::FileName, int> position = parseFileName( m_compileRegExp.cap(1));
m_lastTask = Task(Task::Unknown, Task::TaskType type = Task::Unknown;
m_compileRegExp.cap(4).trimmed() /* description */, const QString category = m_compileRegExp.cap(3);
if (category == QLatin1String("warning"))
type = Task::Warning;
else if (category == QLatin1String("error"))
type = Task::Error;
m_lastTask = Task(type, m_compileRegExp.cap(4).trimmed() /* description */,
position.first, position.second, position.first, position.second,
Constants::TASK_CATEGORY_COMPILE); Constants::TASK_CATEGORY_COMPILE);
if (m_compileRegExp.cap(3) == QLatin1String("warning"))
m_lastTask.type = Task::Warning;
else if (m_compileRegExp.cap(3) == QLatin1String("error"))
m_lastTask.type = Task::Error;
return true; return true;
} }
return false; return false;

View File

@@ -55,13 +55,13 @@ void QtParser::stdError(const QString &line)
int lineno = m_mocRegExp.cap(3).toInt(&ok); int lineno = m_mocRegExp.cap(3).toInt(&ok);
if (!ok) if (!ok)
lineno = -1; lineno = -1;
Task task(Task::Error, Task::TaskType type = Task::Error;
m_mocRegExp.cap(5).trimmed(), if (m_mocRegExp.cap(4).compare(QLatin1String("Warning"), Qt::CaseInsensitive) == 0)
type = Task::Warning;
Task task(type, m_mocRegExp.cap(5).trimmed() /* description */,
Utils::FileName::fromUserInput(m_mocRegExp.cap(1)) /* filename */, Utils::FileName::fromUserInput(m_mocRegExp.cap(1)) /* filename */,
lineno, lineno,
ProjectExplorer::Constants::TASK_CATEGORY_COMPILE); ProjectExplorer::Constants::TASK_CATEGORY_COMPILE);
if (m_mocRegExp.cap(4).compare(QLatin1String("Warning"), Qt::CaseInsensitive) == 0)
task.type = Task::Warning;
emit addTask(task); emit addTask(task);
return; return;
} }