diff --git a/src/plugins/projectexplorer/clangparser.cpp b/src/plugins/projectexplorer/clangparser.cpp index 88747a054e1..83bb2459bd5 100644 --- a/src/plugins/projectexplorer/clangparser.cpp +++ b/src/plugins/projectexplorer/clangparser.cpp @@ -33,6 +33,15 @@ 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) static const char * const FILE_PATTERN = "(|([A-Za-z]:)?[^:]+\\.[^:]+)"; @@ -60,15 +69,11 @@ void ClangParser::stdError(const QString &line) if (m_commandRegExp.indexIn(lne) > -1) { m_expectSnippet = true; - Task task(Task::Error, + Task task(taskType(m_commandRegExp.cap(3)), m_commandRegExp.cap(4), Utils::FileName(), /* filename */ -1, /* line */ 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); return; } @@ -89,15 +94,11 @@ void ClangParser::stdError(const QString &line) int lineNo = m_messageRegExp.cap(4).toInt(&ok); if (!ok) lineNo = m_messageRegExp.cap(5).toInt(&ok); - Task task(Task::Error, + Task task(taskType(m_messageRegExp.cap(7)), m_messageRegExp.cap(8), Utils::FileName::fromUserInput(m_messageRegExp.cap(1)), /* filename */ lineNo, 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); return; } diff --git a/src/plugins/projectexplorer/gccparser.cpp b/src/plugins/projectexplorer/gccparser.cpp index 2c318b5530e..1df98096e49 100644 --- a/src/plugins/projectexplorer/gccparser.cpp +++ b/src/plugins/projectexplorer/gccparser.cpp @@ -87,38 +87,34 @@ void GccParser::stdError(const QString &line) return; } else if (m_regExpGccNames.indexIn(lne) > -1) { QString description = lne.mid(m_regExpGccNames.matchedLength()); - Task task(Task::Error, - description, - Utils::FileName(), /* filename */ - -1, /* line */ - Constants::TASK_CATEGORY_COMPILE); + Task::TaskType type = Task::Error; if (description.startsWith(QLatin1String("warning: "))) { - task.type = Task::Warning; - task.description = description.mid(9); + type = Task::Warning; + description = description.mid(9); } 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); return; } else if (m_regExp.indexIn(lne) > -1) { Utils::FileName filename = Utils::FileName::fromUserInput(m_regExp.cap(1)); int lineno = m_regExp.cap(3).toInt(); - Task task(Task::Unknown, - m_regExp.cap(8) /* description */, - filename, lineno, - Constants::TASK_CATEGORY_COMPILE); + Task::TaskType type = Task::Unknown; + QString description = m_regExp.cap(8); if (m_regExp.cap(7) == QLatin1String("warning")) - task.type = Task::Warning; + type = Task::Warning; else if (m_regExp.cap(7) == QLatin1String("error") || - task.description.startsWith(QLatin1String("undefined reference to")) || - task.description.startsWith(QLatin1String("multiple definition of"))) - task.type = Task::Error; - + description.startsWith(QLatin1String("undefined reference to")) || + description.startsWith(QLatin1String("multiple definition of"))) + type = Task::Error; // Prepend "#warning" or "#error" if that triggered the match on (warning|error) // We want those to show how the warning was triggered 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); return; } else if (m_regExpIncluded.indexIn(lne) > -1) { diff --git a/src/plugins/projectexplorer/ldparser.cpp b/src/plugins/projectexplorer/ldparser.cpp index 8ea71e96aa0..70691e35f2a 100644 --- a/src/plugins/projectexplorer/ldparser.cpp +++ b/src/plugins/projectexplorer/ldparser.cpp @@ -78,17 +78,15 @@ void LdParser::stdError(const QString &line) return; } else if (m_regExpGccNames.indexIn(lne) > -1) { QString description = lne.mid(m_regExpGccNames.matchedLength()); - Task task(Task::Error, - description, - Utils::FileName(), /* filename */ - -1, /* line */ - Constants::TASK_CATEGORY_COMPILE); + Task::TaskType type = Task::Error; if (description.startsWith(QLatin1String("warning: "))) { - task.type = Task::Warning; - task.description = description.mid(9); + type = Task::Warning; + description = description.mid(9); } 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); return; } else if (m_regExpLinker.indexIn(lne) > -1) { @@ -104,20 +102,18 @@ void LdParser::stdError(const QString &line) filename = Utils::FileName::fromUserInput(sourceFileName); } QString description = m_regExpLinker.cap(8).trimmed(); - Task task(Task::Error, description, filename, lineno, - Constants::TASK_CATEGORY_COMPILE); + Task::TaskType type = Task::Error; if (description.startsWith(QLatin1String("At global scope")) || description.startsWith(QLatin1String("At top level")) || description.startsWith(QLatin1String("instantiated from ")) || description.startsWith(QLatin1String("In ")) || 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.type = Task::Warning; - task.description = description.mid(9); - } - + Task task(type, description, filename, lineno, Constants::TASK_CATEGORY_COMPILE); emit addTask(task); return; } diff --git a/src/plugins/projectexplorer/linuxiccparser.cpp b/src/plugins/projectexplorer/linuxiccparser.cpp index 713ee98d5eb..d4ab5b72ee1 100644 --- a/src/plugins/projectexplorer/linuxiccparser.cpp +++ b/src/plugins/projectexplorer/linuxiccparser.cpp @@ -67,15 +67,16 @@ void LinuxIccParser::stdError(const QString &line) { if (m_expectFirstLine && m_firstLine.indexIn(line) != -1) { // 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)), m_firstLine.cap(2).toInt(), 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; } else if (!m_expectFirstLine && m_caretLine.indexIn(line) != -1) { diff --git a/src/plugins/projectexplorer/msvcparser.cpp b/src/plugins/projectexplorer/msvcparser.cpp index 9ff6c36d4d0..dc6dd1f0203 100644 --- a/src/plugins/projectexplorer/msvcparser.cpp +++ b/src/plugins/projectexplorer/msvcparser.cpp @@ -157,15 +157,15 @@ bool MsvcParser::processCompileLine(const QString &line) if (m_compileRegExp.indexIn(line) > -1) { QPair position = parseFileName( m_compileRegExp.cap(1)); - m_lastTask = Task(Task::Unknown, - m_compileRegExp.cap(4).trimmed() /* description */, + Task::TaskType type = Task::Unknown; + 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, 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 false; diff --git a/src/plugins/qtsupport/qtparser.cpp b/src/plugins/qtsupport/qtparser.cpp index 5a0820bf350..89a237b2a16 100644 --- a/src/plugins/qtsupport/qtparser.cpp +++ b/src/plugins/qtsupport/qtparser.cpp @@ -55,13 +55,13 @@ void QtParser::stdError(const QString &line) int lineno = m_mocRegExp.cap(3).toInt(&ok); if (!ok) lineno = -1; - Task task(Task::Error, - m_mocRegExp.cap(5).trimmed(), + Task::TaskType type = Task::Error; + 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 */, lineno, ProjectExplorer::Constants::TASK_CATEGORY_COMPILE); - if (m_mocRegExp.cap(4).compare(QLatin1String("Warning"), Qt::CaseInsensitive) == 0) - task.type = Task::Warning; emit addTask(task); return; }