Merge output formatters and output parsers

Now only one piece of code needs to be written to both linkify output in
an output pane and create tasks for it in the issues pane.
The calling sites are also simplified. For instance, until now, build
steps had to feed their output parsers manually and then push the
created tasks up the signal stack in parallel with the actual output,
which the build manager relied upon for cross-linking the output pane
content. Afterwards, the output would get forwarded to the formatter
(and parsed for ANSI escape codes a second time). In contrast, a build
step now just forwards the process output, and task parsing as well as
output formatting is done centrally further up the stack.
Concrete user-visible improvements so far:
    - File paths in compiler/linker messages are clickable links now.
    - QtTest applications now create clickable links also when run
      as part of a build step, not just in the app output pane.

Task-number: QTCREATORBUG-22665
Change-Id: Ic9fb95b2d97f2520ab3ec653315e9219466ec08d
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Christian Kandeler
2020-04-16 13:53:05 +02:00
parent b7851eeb55
commit 1c6e4fbd32
115 changed files with 1124 additions and 1179 deletions

View File

@@ -34,12 +34,12 @@
#include <coreplugin/icore.h>
#include <coreplugin/variablechooser.h>
#include <projectexplorer/buildsteplist.h>
#include <projectexplorer/ioutputparser.h>
#include <projectexplorer/kit.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/target.h>
#include <qtsupport/qtversionmanager.h>
#include <utils/macroexpander.h>
#include <utils/outputformatter.h>
#include <utils/pathchooser.h>
#include <utils/qtcassert.h>
#include <utils/qtcprocess.h>
@@ -155,7 +155,6 @@ QbsBuildStep::~QbsBuildStep()
doCancel();
if (m_session)
m_session->disconnect(this);
delete m_parser;
}
bool QbsBuildStep::init()
@@ -168,11 +167,6 @@ bool QbsBuildStep::init()
if (!bc)
return false;
delete m_parser;
m_parser = new IOutputParser;
m_parser->setLineParsers(target()->kit()->createOutputParsers());
connect(m_parser, &ProjectExplorer::IOutputParser::addTask, this, &QbsBuildStep::addTask);
m_changedFiles = bc->changedFiles();
m_activeFileTags = bc->activeFileTags();
m_products = bc->products();
@@ -180,6 +174,12 @@ bool QbsBuildStep::init()
return true;
}
void QbsBuildStep::setupOutputFormatter(OutputFormatter *formatter)
{
formatter->addLineParsers(target()->kit()->createOutputParsers());
BuildStep::setupOutputFormatter(formatter);
}
void QbsBuildStep::doRun()
{
// We need a pre-build parsing step in order not to lose project file changes done
@@ -371,35 +371,24 @@ void QbsBuildStep::handleProcessResult(
const QStringList &stdErr,
bool success)
{
Q_UNUSED(workingDir);
const bool hasOutput = !stdOut.isEmpty() || !stdErr.isEmpty();
if (success && !hasOutput)
return;
if (m_parser)
m_parser->addSearchDir(workingDir);
emit addOutput(executable.toUserOutput() + ' ' + QtcProcess::joinArgs(arguments),
OutputFormat::Stdout);
for (const QString &line : stdErr) {
if (m_parser)
m_parser->handleStderr(line + '\n');
for (const QString &line : stdErr)
emit addOutput(line, OutputFormat::Stderr);
}
for (const QString &line : stdOut) {
if (m_parser)
m_parser->handleStdout(line + '\n');
for (const QString &line : stdOut)
emit addOutput(line, OutputFormat::Stdout);
}
if (m_parser) {
m_parser->flush();
m_parser->dropSearchDir(workingDir);
}
}
void QbsBuildStep::createTaskAndOutput(ProjectExplorer::Task::TaskType type, const QString &message,
const QString &file, int line)
{
emit addTask(CompileTask(type, message, FilePath::fromString(file), line), 1);
emit addOutput(message, OutputFormat::Stdout);
emit addTask(CompileTask(type, message, FilePath::fromString(file), line), 1);
}
QString QbsBuildStep::buildVariant() const

View File

@@ -30,7 +30,6 @@
#include <projectexplorer/buildstep.h>
#include <projectexplorer/task.h>
namespace ProjectExplorer { class IOutputParser; }
namespace Utils { class FancyLineEdit; }
namespace QbsProjectManager {
@@ -81,6 +80,7 @@ signals:
private:
bool init() override;
void setupOutputFormatter(Utils::OutputFormatter *formatter) override;
void doRun() override;
void doCancel() override;
ProjectExplorer::BuildStepConfigWidget *createConfigWidget() override;
@@ -134,7 +134,6 @@ private:
QString m_currentTask;
int m_maxProgress;
bool m_lastWasSuccess;
ProjectExplorer::IOutputParser *m_parser = nullptr;
bool m_parsingProject = false;
bool m_parsingAfterBuild = false;

View File

@@ -160,8 +160,8 @@ void QbsCleanStep::handleProgress(int value)
void QbsCleanStep::createTaskAndOutput(ProjectExplorer::Task::TaskType type, const QString &message, const QString &file, int line)
{
emit addTask(CompileTask(type, message, Utils::FilePath::fromString(file), line), 1);
emit addOutput(message, OutputFormat::Stdout);
emit addTask(CompileTask(type, message, Utils::FilePath::fromString(file), line), 1);
}
// --------------------------------------------------------------------

View File

@@ -202,9 +202,8 @@ void QbsInstallStep::handleProgress(int value)
void QbsInstallStep::createTaskAndOutput(Task::TaskType type, const QString &message,
const Utils::FilePath &file, int line)
{
const CompileTask task(type, message, file, line);
emit addTask(task, 1);
emit addOutput(message, OutputFormat::Stdout);
emit addTask(CompileTask(type, message, file, line), 1);
}
void QbsInstallStep::setRemoveFirst(bool rf)