Commit b2f68033 authored by Tobias Hunger's avatar Tobias Hunger
Browse files

Use Task class in addToTaskWindow(...) signal.

 * Use Task class in addToTaskWindow(...) signal. This introduces
   support for task categories into the BuildParsers.
 * Add a task category for buildsystem issues.
 * Update existing BuildParsers to new API and assign their
   tasks to the Compile or Buildsystem task category.

Reviewed-By: dt
parent c9d49ab7
......@@ -97,24 +97,25 @@ void AbstractMakeStep::setBuildParser(const QString &parser)
if (m_buildParser) {
m_buildParserName = parser;
connect(m_buildParser, SIGNAL(addToOutputWindow(const QString &)),
this, SIGNAL(addToOutputWindow(const QString &)),
connect(m_buildParser, SIGNAL(addToOutputWindow(QString)),
this, SIGNAL(addToOutputWindow(QString)),
Qt::DirectConnection);
connect(m_buildParser, SIGNAL(addToTaskWindow(const QString &, int, int, const QString &)),
this, SLOT(slotAddToTaskWindow(const QString &, int, int, const QString &)),
connect(m_buildParser, SIGNAL(addToTaskWindow(ProjectExplorer::TaskWindow::Task)),
this, SLOT(slotAddToTaskWindow(ProjectExplorer::TaskWindow::Task)),
Qt::DirectConnection);
connect(m_buildParser, SIGNAL(enterDirectory(const QString &)),
this, SLOT(addDirectory(const QString &)),
connect(m_buildParser, SIGNAL(enterDirectory(QString)),
this, SLOT(addDirectory(QString)),
Qt::DirectConnection);
connect(m_buildParser, SIGNAL(leaveDirectory(const QString &)),
this, SLOT(removeDirectory(const QString &)),
connect(m_buildParser, SIGNAL(leaveDirectory(QString)),
this, SLOT(removeDirectory(QString)),
Qt::DirectConnection);
}
}
void AbstractMakeStep::slotAddToTaskWindow(const QString & fn, int type, int linenumber, const QString & description)
void AbstractMakeStep::slotAddToTaskWindow(const TaskWindow::Task &task)
{
QString filePath = fn;
TaskWindow::Task editable(task);
QString filePath = QDir::cleanPath(task.file.trimmed());
if (!filePath.isEmpty() && !QDir::isAbsolutePath(filePath)) {
// We have no save way to decide which file in which subfolder
// is meant. Therefore we apply following heuristics:
......@@ -123,8 +124,6 @@ void AbstractMakeStep::slotAddToTaskWindow(const QString & fn, int type, int lin
// 3. Check if file is unique in whole project
// 4. Otherwise give up
filePath = filePath.trimmed();
QList<QFileInfo> possibleFiles;
foreach (const QString &dir, m_openDirectories) {
QFileInfo candidate(dir + QLatin1Char('/') + filePath);
......@@ -151,7 +150,7 @@ void AbstractMakeStep::slotAddToTaskWindow(const QString & fn, int type, int lin
}
}
if (possibleFiles.count() == 1) {
filePath = possibleFiles.first().filePath();
editable.file = possibleFiles.first().filePath();
} else {
// More then one filename, so do a better compare
// Chop of any "../"
......@@ -166,12 +165,12 @@ void AbstractMakeStep::slotAddToTaskWindow(const QString & fn, int type, int lin
}
}
if (count == 1)
filePath = possibleFilePath;
editable.file = possibleFilePath;
else
qWarning() << "Could not find absolute location of file " << filePath;
}
}
emit addToTaskWindow(filePath, type, linenumber, description);
emit addToTaskWindow(editable);
}
void AbstractMakeStep::addDirectory(const QString &dir)
......
......@@ -32,6 +32,7 @@
#include "projectexplorer_export.h"
#include "abstractprocessstep.h"
#include "taskwindow.h"
namespace ProjectExplorer {
class BuildStep;
......@@ -59,7 +60,7 @@ protected:
void setBuildParser(const QString &parser);
QString buildParser() const;
private slots:
void slotAddToTaskWindow(const QString & fn, int type, int linenumber, const QString & description);
void slotAddToTaskWindow(const ProjectExplorer::TaskWindow::Task &task);
void addDirectory(const QString &dir);
void removeDirectory(const QString &dir);
private:
......
......@@ -87,6 +87,7 @@ BuildManager::BuildManager(ProjectExplorerPlugin *parent)
pm->addObject(m_taskWindow);
m_taskWindow->addCategory(Constants::TASK_CATEGORY_COMPILE, tr("Compile", "Category for compiler isses listened under 'Build Issues'"));
m_taskWindow->addCategory(Constants::TASK_CATEGORY_BUILDSYSTEM, tr("Buildsystem", "Category for build system isses listened under 'Build Issues'"));
connect(m_taskWindow, SIGNAL(tasksChanged()),
this, SIGNAL(tasksChanged()));
......@@ -126,8 +127,8 @@ void BuildManager::cancel()
// (And we want those to be before the cancel message.)
QTimer::singleShot(0, this, SLOT(emitCancelMessage()));
disconnect(m_currentBuildStep, SIGNAL(addToTaskWindow(QString, int, int, QString)),
this, SLOT(addToTaskWindow(QString, int, int, QString)));
disconnect(m_currentBuildStep, SIGNAL(addToTaskWindow(ProjectExplorer::TaskWindow::Task)),
this, SLOT(addToTaskWindow(ProjectExplorer::TaskWindow::Task)));
disconnect(m_currentBuildStep, SIGNAL(addToOutputWindow(QString)),
this, SLOT(addToOutputWindow(QString)));
decrementActiveBuildSteps(m_currentBuildStep->project());
......@@ -230,10 +231,8 @@ void BuildManager::showBuildResults()
//toggleTaskWindow();
}
void BuildManager::addToTaskWindow(const QString &file, int type, int line, const QString &description)
void BuildManager::addToTaskWindow(const ProjectExplorer::TaskWindow::Task &task)
{
TaskWindow::Task task(TaskWindow::TaskType(type), description, file, line,
Constants::TASK_CATEGORY_COMPILE);
m_taskWindow->addTask(task);
}
......@@ -247,8 +246,8 @@ void BuildManager::nextBuildQueue()
if (m_canceling)
return;
disconnect(m_currentBuildStep, SIGNAL(addToTaskWindow(QString, int, int, QString)),
this, SLOT(addToTaskWindow(QString, int, int, QString)));
disconnect(m_currentBuildStep, SIGNAL(addToTaskWindow(ProjectExplorer::TaskWindow::Task)),
this, SLOT(addToTaskWindow(ProjectExplorer::TaskWindow::Task)));
disconnect(m_currentBuildStep, SIGNAL(addToOutputWindow(QString)),
this, SLOT(addToOutputWindow(QString)));
......@@ -290,8 +289,8 @@ void BuildManager::nextStep()
m_buildQueue.pop_front();
m_configurations.pop_front();
connect(m_currentBuildStep, SIGNAL(addToTaskWindow(QString, int, int, QString)),
this, SLOT(addToTaskWindow(QString, int, int, QString)));
connect(m_currentBuildStep, SIGNAL(addToTaskWindow(ProjectExplorer::TaskWindow::Task)),
this, SLOT(addToTaskWindow(ProjectExplorer::TaskWindow::Task)));
connect(m_currentBuildStep, SIGNAL(addToOutputWindow(QString)),
this, SLOT(addToOutputWindow(QString)));
......
......@@ -31,6 +31,7 @@
#define BUILDMANAGER_H
#include "projectexplorer_export.h"
#include "taskwindow.h"
#include <QtCore/QObject>
#include <QtCore/QStringList>
......@@ -45,7 +46,6 @@ namespace Internal {
class BuildProgressFuture;
}
class TaskWindow;
class BuildStep;
class Project;
class ProjectExplorerPlugin;
......@@ -92,7 +92,7 @@ signals:
void tasksChanged();
private slots:
void addToTaskWindow(const QString &file, int type, int line, const QString &description);
void addToTaskWindow(const ProjectExplorer::TaskWindow::Task &task);
void addToOutputWindow(const QString &string);
void nextBuildQueue();
......
......@@ -126,7 +126,7 @@ protected:
QMap<QString, QVariant> valuesToMap(const QString & buildConfiguration);
Q_SIGNALS:
void addToTaskWindow(const QString &filename, int type, int linenumber, const QString &description);
void addToTaskWindow(const ProjectExplorer::TaskWindow::Task &task);
// The string is added to the output window
// It should be in html format, that is properly escaped
void addToOutputWindow(const QString &string);
......
......@@ -71,42 +71,36 @@ void GccParser::stdError(const QString & line)
QString lne = line.trimmed();
if (m_regExpLinker.indexIn(lne) > -1) {
QString description = m_regExpLinker.cap(2);
emit addToTaskWindow(
m_regExpLinker.cap(1), //filename
TaskWindow::Error,
-1, //linenumber
description);
//qDebug()<<"m_regExpLinker"<<m_regExpLinker.cap(2);
emit addToTaskWindow(TaskWindow::Task(TaskWindow::Error,
description,
m_regExpLinker.cap(1) /* filename */,
-1 /* linenumber */,
Constants::TASK_CATEGORY_COMPILE));
} else if (m_regExp.indexIn(lne) > -1) {
TaskWindow::TaskType type;
TaskWindow::Task task(TaskWindow::Unknown,
m_regExp.cap(6) /* description */,
m_regExp.cap(1) /* filename */,
m_regExp.cap(2).toInt() /* line number */,
Constants::TASK_CATEGORY_COMPILE);
if (m_regExp.cap(5) == "warning")
type = TaskWindow::Warning;
task.type = TaskWindow::Warning;
else if (m_regExp.cap(5) == "error")
type = TaskWindow::Error;
else
type = TaskWindow::Unknown;
task.type = TaskWindow::Error;
QString description = m_regExp.cap(6);
emit addToTaskWindow(
m_regExp.cap(1), //filename
type,
m_regExp.cap(2).toInt(), //line number
description);
emit addToTaskWindow(task);
} else if (m_regExpIncluded.indexIn(lne) > -1) {
emit addToTaskWindow(
m_regExpIncluded.cap(1), //filename
TaskWindow::Unknown,
m_regExpIncluded.cap(2).toInt(), //linenumber
lne //description
);
} else if (lne.startsWith(QLatin1String("collect2:"))) {
emit addToTaskWindow("", TaskWindow::Error, -1, lne);
} else if (lne.startsWith(QLatin1String("ERROR:"))) {
// Triggered by cpp on windows.
emit addToTaskWindow(QString(), TaskWindow::Error, -1, lne);
} else if (lne == QLatin1String("* cpp failed")) {
// Triggered by cpp/make on windows.
emit addToTaskWindow(QString(), TaskWindow::Error, -1, lne);
emit addToTaskWindow(TaskWindow::Task(TaskWindow::Unknown,
lne /* description */,
m_regExpIncluded.cap(1) /* filename */,
m_regExpIncluded.cap(2).toInt() /* linenumber */,
Constants::TASK_CATEGORY_COMPILE));
} else if (lne.startsWith(QLatin1String("collect2:")) ||
lne.startsWith(QLatin1String("ERROR:")) ||
lne == QLatin1String("* cpp failed")) {
emit addToTaskWindow(TaskWindow::Task(TaskWindow::Error,
lne /* description */,
QString() /* filename */,
-1 /* linenumber */,
Constants::TASK_CATEGORY_COMPILE));
}
}
......@@ -31,9 +31,10 @@
#define IBUILDPARSER_H
#include "projectexplorer_export.h"
#include "taskwindow.h"
#include <QtCore/QObject>
#include <QtCore/QStack>
#include <QtCore/QString>
namespace ProjectExplorer {
......@@ -51,7 +52,7 @@ Q_SIGNALS:
void enterDirectory(const QString &dir);
void leaveDirectory(const QString &dir);
void addToOutputWindow(const QString & string);
void addToTaskWindow(const QString & filename, int type, int lineNumber, const QString & description);
void addToTaskWindow(const ProjectExplorer::TaskWindow::Task &task);
};
class PROJECTEXPLORER_EXPORT IBuildParserFactory
......
......@@ -62,4 +62,6 @@ Q_DECLARE_METATYPE(QList<ProjectExplorer::Internal::CommandQObject*>)
Q_DECLARE_METATYPE(ProjectExplorer::IBuildParser*)
Q_DECLARE_METATYPE(ProjectExplorer::GlobalConfigManagerInterface*)
Q_DECLARE_METATYPE(ProjectExplorer::TaskWindow::Task)
#endif // PROJECTEXPLORERMETATYPEDECLARATIONS_H
......@@ -58,24 +58,24 @@ void MsvcParser::stdOutput(const QString & line)
{
QString lne = line.trimmed();
if (m_compileRegExp.indexIn(lne) > -1 && m_compileRegExp.numCaptures() == 4) {
emit addToTaskWindow(
QDir::cleanPath(m_compileRegExp.cap(1)), //filename
toType(m_compileRegExp.cap(3).toInt()), // PatternType
m_compileRegExp.cap(2).toInt(), //linenumber
m_compileRegExp.cap(4) //description
);
} else if (m_linkRegExp.indexIn(lne) > -1 && m_linkRegExp.numCaptures() == 3) {
emit addToTaskWindow(TaskWindow::Task(toType(m_compileRegExp.cap(3).toInt()) /* task type */,
m_compileRegExp.cap(4) /* description */,
m_compileRegExp.cap(1) /* filename */,
m_compileRegExp.cap(2).toInt() /* linenumber */,
Constants::TASK_CATEGORY_COMPILE));
return;
}
if (m_linkRegExp.indexIn(lne) > -1 && m_linkRegExp.numCaptures() == 3) {
QString fileName = m_linkRegExp.cap(1);
if (fileName.contains(QLatin1String("LINK"), Qt::CaseSensitive))
fileName.clear();
emit addToTaskWindow(
QDir::cleanPath(fileName), //filename
toType(m_linkRegExp.cap(2).toInt()), // pattern type
-1, // line number
m_linkRegExp.cap(3) // description
);
emit addToTaskWindow(TaskWindow::Task(toType(m_linkRegExp.cap(2).toInt()) /* task type */,
m_linkRegExp.cap(3) /* description */,
fileName /* filename */,
-1 /* line number */,
Constants::TASK_CATEGORY_COMPILE));
return;
}
}
......
......@@ -192,6 +192,7 @@ const char * const PROJECTEXPLORER_PAGE = "ProjectExplorer.Projec
// task categories
const char * const TASK_CATEGORY_COMPILE = "Task.Category.Compile";
const char * const TASK_CATEGORY_BUILDSYSTEM = "Task.Category.Buildsystem";
} // namespace Constants
} // namespace ProjectExplorer
......
......@@ -52,7 +52,11 @@ void QMakeParser::stdError(const QString & line)
if (lne.startsWith("Project ERROR:"))
{
lne = lne.mid(15);
emit addToTaskWindow(QString(), TaskWindow::Error, -1, lne);
emit addToTaskWindow(TaskWindow::Task(TaskWindow::Error,
lne /* description */,
QString() /* filename */,
-1 /* linenumber */,
Constants::TASK_CATEGORY_BUILDSYSTEM));
return;
}
}
......@@ -47,8 +47,6 @@
#include <QtGui/QStyledItemDelegate>
#include <QtGui/QSortFilterProxyModel>
#include <QDebug>
namespace ProjectExplorer {
namespace Internal {
......@@ -488,6 +486,8 @@ TaskWindow::TaskWindow()
m_categoriesButton->setPopupMode(QToolButton::InstantPopup);
m_categoriesButton->setMenu(m_categoriesMenu);
qRegisterMetaType<ProjectExplorer::TaskWindow::Task>("ProjectExplorer::TaskWindow::Task");
updateActions();
}
......
......@@ -30,7 +30,7 @@
#ifndef TASKWINDOW_H
#define TASKWINDOW_H
#include "ibuildparser.h"
#include "projectexplorer_export.h"
#include <coreplugin/icontext.h>
#include <coreplugin/ioutputpane.h>
......@@ -65,10 +65,14 @@ public:
};
struct Task {
Task() : type(Unknown), line(-1)
{ }
Task(TaskType type_, const QString &description_,
const QString &file_, int line_, const QString &category_) :
type(type_), description(description_), file(file_), line(line_), category(category_)
{ }
~Task()
{ }
TaskType type;
QString description;
......
......@@ -70,14 +70,14 @@ AbldParser::AbldParser(const QString &name) :
}
QTC_ASSERT(0 != m_subparser, return);
connect(m_subparser, SIGNAL(enterDirectory(const QString &)),
this, SIGNAL(enterDirectory(const QString &)));
connect(m_subparser, SIGNAL(leaveDirectory(const QString &)),
this, SIGNAL(leaveDirectory(const QString &)));
connect(m_subparser, SIGNAL(addToOutputWindow(const QString &)),
this, SIGNAL(addToOutputWindow(const QString &)));
connect(m_subparser, SIGNAL(addToTaskWindow(const QString &, int, int, const QString &)),
this, SIGNAL(addToTaskWindow(const QString &, int, int, const QString &)));
connect(m_subparser, SIGNAL(enterDirectory(QString)),
this, SIGNAL(enterDirectory(QString)));
connect(m_subparser, SIGNAL(leaveDirectory(QString)),
this, SIGNAL(leaveDirectory(QString)));
connect(m_subparser, SIGNAL(addToOutputWindow(QString)),
this, SIGNAL(addToOutputWindow(QString)));
connect(m_subparser, SIGNAL(addToTaskWindow(ProjectExplorer::TaskWindow::Task)),
this, SIGNAL(addToTaskWindow(ProjectExplorer::TaskWindow::Task)));
}
AbldParser::~AbldParser()
......@@ -97,35 +97,39 @@ void AbldParser::stdOutput(const QString &line)
QString lne = line.trimmed();
// possible ABLD.bat errors:
if (lne.startsWith("Is Perl, version ")) {
emit addToTaskWindow(
QString(), //filename
TaskWindow::Error,
-1, //linenumber
lne);
emit addToTaskWindow(TaskWindow::Task(TaskWindow::Error,
lne /* description */,
QString() /* filename */,
-1 /* linenumber */,
Constants::TASK_CATEGORY_BUILDSYSTEM));
return;
}
if (lne.startsWith("FATAL ERROR:")) {
emit addToTaskWindow(QString(), TaskWindow::Error,
-1, lne.mid(12));
emit addToTaskWindow(TaskWindow::Task(TaskWindow::Error,
lne /* description */,
QString() /* filename */,
-1 /* linenumber */,
Constants::TASK_CATEGORY_BUILDSYSTEM));
m_waitingForStdOutContinuation = false;
return;
}
if (m_perlIssue.indexIn(lne) > -1) {
m_waitingForStdOutContinuation = true;
TaskWindow::TaskType type;
if (m_perlIssue.cap(1) == QLatin1String("WARNING"))
type = TaskWindow::Warning;
else if (m_perlIssue.cap(1) == QLatin1String("ERROR"))
type = TaskWindow::Error;
else
type = TaskWindow::Unknown;
m_currentFile = m_perlIssue.cap(2);
m_currentLine = m_perlIssue.cap(3).toInt();
emit addToTaskWindow(m_currentFile, type,
m_currentLine, m_perlIssue.cap(4));
TaskWindow::Task task(TaskWindow::Unknown,
m_perlIssue.cap(4) /* description */,
m_currentFile, m_currentLine,
Constants::TASK_CATEGORY_BUILDSYSTEM);
if (m_perlIssue.cap(1) == QLatin1String("WARNING"))
task.type = TaskWindow::Warning;
else if (m_perlIssue.cap(1) == QLatin1String("ERROR"))
task.type = TaskWindow::Error;
emit addToTaskWindow(task);
return;
}
......@@ -135,9 +139,10 @@ void AbldParser::stdOutput(const QString &line)
}
if (m_waitingForStdOutContinuation) {
emit addToTaskWindow(m_currentFile,
TaskWindow::Unknown,
m_currentLine, lne);
emit addToTaskWindow(TaskWindow::Task(TaskWindow::Unknown,
lne /* description */,
m_currentFile, m_currentLine,
Constants::TASK_CATEGORY_BUILDSYSTEM));
m_waitingForStdOutContinuation = true;
return;
}
......@@ -157,18 +162,20 @@ void AbldParser::stdError(const QString &line)
if (lne.startsWith("ABLD ERROR:") ||
lne.startsWith("This project does not support ") ||
lne.startsWith("Platform ")) {
emit addToTaskWindow(
QString(), // filename,
TaskWindow::Error,
-1, // linenumber
lne);
emit addToTaskWindow(TaskWindow::Task(TaskWindow::Error,
lne /* description */,
QString() /* filename */,
-1 /* linenumber */,
Constants::TASK_CATEGORY_BUILDSYSTEM));
return;
}
if (lne.startsWith("Died at ")) {
emit addToTaskWindow(QString(),
TaskWindow::Error,
-1, lne);
emit addToTaskWindow(TaskWindow::Task(TaskWindow::Error,
lne /* description */,
QString() /* filename */,
-1 /* linenumber */,
Constants::TASK_CATEGORY_BUILDSYSTEM));
m_waitingForStdErrContinuation = false;
return;
}
......@@ -184,25 +191,29 @@ void AbldParser::stdError(const QString &line)
}
if (lne.startsWith("WARNING: ")) {
QString description = lne.mid(9);
emit addToTaskWindow(m_currentFile,
TaskWindow::Warning,
-1, description);
emit addToTaskWindow(TaskWindow::Task(TaskWindow::Warning, description,
m_currentFile,
-1 /* linenumber */,
Constants::TASK_CATEGORY_BUILDSYSTEM));
m_waitingForStdErrContinuation = true;
return;
}
if (lne.startsWith("ERROR: ")) {
QString description = lne.mid(7);
emit addToTaskWindow(m_currentFile,
TaskWindow::Error,
-1, description);
emit addToTaskWindow(TaskWindow::Task(TaskWindow::Error, description,
m_currentFile,
-1 /* linenumber */,
Constants::TASK_CATEGORY_BUILDSYSTEM));
m_waitingForStdErrContinuation = true;
return;
}
if (m_waitingForStdErrContinuation)
{
emit addToTaskWindow(m_currentFile,
TaskWindow::Unknown,
-1, lne);
emit addToTaskWindow(TaskWindow::Task(TaskWindow::Unknown,
lne /* description */,
m_currentFile,
-1 /* linenumber */,
Constants::TASK_CATEGORY_BUILDSYSTEM));
m_waitingForStdErrContinuation = true;
return;
}
......
......@@ -74,44 +74,35 @@ void RvctParser::stdOutput(const QString &line)
void RvctParser::stdError(const QString &line)
{
QString lne = line.trimmed();
if (m_linkerProblem.indexIn(lne) > -1) {
QString description = m_linkerProblem.cap(2);
emit addToTaskWindow(
m_linkerProblem.cap(1), //filename
TaskWindow::Error,
-1, //linenumber
description);
emit addToTaskWindow(TaskWindow::Task(TaskWindow::Error,
m_linkerProblem.cap(2) /* description */,
m_linkerProblem.cap(1) /* filename */,
-1 /* linenumber */,
Constants::TASK_CATEGORY_COMPILE));
} else if (m_warningOrError.indexIn(lne) > -1) {
TaskWindow::TaskType type;
m_lastFile = m_warningOrError.cap(1);
m_lastLine = m_warningOrError.cap(2).toInt();
TaskWindow::Task task(TaskWindow::Unknown,
m_warningOrError.cap(5) /* description */,
m_lastFile, m_lastLine,
Constants::TASK_CATEGORY_COMPILE);
if (m_warningOrError.cap(4) == "Warning")
type = TaskWindow::Warning;
task.type = TaskWindow::Warning;
else if (m_warningOrError.cap(4) == "Error")
type = TaskWindow::Error;
else
type = TaskWindow::Unknown;
QString description = m_warningOrError.cap(5);
task.type = TaskWindow::Error;