ProjectExplorer: Use direct aspect registration in ProcessStep

Task-number: QTCREATORBUG-29168
Change-Id: If83acc092689a935cf81c8133d6a07d802a07177
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2023-06-29 18:05:07 +02:00
parent f3654b8fd2
commit 345c946255
2 changed files with 53 additions and 60 deletions

View File

@@ -11,13 +11,11 @@
#include "projectexplorertr.h"
#include <utils/aspects.h>
#include <utils/fileutils.h>
#include <utils/outputformatter.h>
using namespace Utils;
namespace ProjectExplorer {
namespace Internal {
namespace ProjectExplorer::Internal {
const char PROCESS_COMMAND_KEY[] = "ProjectExplorer.ProcessStep.Command";
const char PROCESS_WORKINGDIRECTORY_KEY[] = "ProjectExplorer.ProcessStep.WorkingDirectory";
@@ -26,40 +24,32 @@ const char PROCESS_ARGUMENTS_KEY[] = "ProjectExplorer.ProcessStep.Arguments";
class ProcessStep final : public AbstractProcessStep
{
public:
ProcessStep(BuildStepList *bsl, Id id);
void setupOutputFormatter(OutputFormatter *formatter) final;
};
ProcessStep::ProcessStep(BuildStepList *bsl, Id id)
ProcessStep(BuildStepList *bsl, Id id)
: AbstractProcessStep(bsl, id)
{
auto command = addAspect<FilePathAspect>();
command->setSettingsKey(PROCESS_COMMAND_KEY);
command->setLabelText(Tr::tr("Command:"));
command->setExpectedKind(PathChooser::Command);
command->setHistoryCompleter("PE.ProcessStepCommand.History");
command.setSettingsKey(PROCESS_COMMAND_KEY);
command.setLabelText(Tr::tr("Command:"));
command.setExpectedKind(PathChooser::Command);
command.setHistoryCompleter("PE.ProcessStepCommand.History");
auto arguments = addAspect<StringAspect>();
arguments->setSettingsKey(PROCESS_ARGUMENTS_KEY);
arguments->setDisplayStyle(StringAspect::LineEditDisplay);
arguments->setLabelText(Tr::tr("Arguments:"));
arguments.setSettingsKey(PROCESS_ARGUMENTS_KEY);
arguments.setDisplayStyle(StringAspect::LineEditDisplay);
arguments.setLabelText(Tr::tr("Arguments:"));
auto workingDirectory = addAspect<FilePathAspect>();
workingDirectory->setSettingsKey(PROCESS_WORKINGDIRECTORY_KEY);
workingDirectory->setValue(Constants::DEFAULT_WORKING_DIR);
workingDirectory->setLabelText(Tr::tr("Working directory:"));
workingDirectory->setExpectedKind(PathChooser::Directory);
workingDirectory.setSettingsKey(PROCESS_WORKINGDIRECTORY_KEY);
workingDirectory.setValue(Constants::DEFAULT_WORKING_DIR);
workingDirectory.setLabelText(Tr::tr("Working directory:"));
workingDirectory.setExpectedKind(PathChooser::Directory);
setWorkingDirectoryProvider([this, workingDirectory] {
const FilePath workingDir = workingDirectory->filePath();
setWorkingDirectoryProvider([this] {
const FilePath workingDir = workingDirectory();
if (workingDir.isEmpty())
return FilePath::fromString(fallbackWorkingDirectory());
return workingDir;
});
setCommandLineProvider([command, arguments] {
return CommandLine{command->filePath(), arguments->value(), CommandLine::Raw};
setCommandLineProvider([this] {
return CommandLine{command(), arguments(), CommandLine::Raw};
});
setSummaryUpdater([this] {
@@ -74,12 +64,18 @@ ProcessStep::ProcessStep(BuildStepList *bsl, Id id)
addMacroExpander();
}
void ProcessStep::setupOutputFormatter(OutputFormatter *formatter)
private:
void setupOutputFormatter(OutputFormatter *formatter) final
{
formatter->addLineParsers(kit()->createOutputParsers());
AbstractProcessStep::setupOutputFormatter(formatter);
}
FilePathAspect command{this};
StringAspect arguments{this};
FilePathAspect workingDirectory{this};
};
// ProcessStepFactory
ProcessStepFactory::ProcessStepFactory()
@@ -89,5 +85,4 @@ ProcessStepFactory::ProcessStepFactory()
setDisplayName(Tr::tr("Custom Process Step"));
}
} // Internal
} // ProjectExplorer
} // ProjectExplorer::Internal

View File

@@ -5,8 +5,7 @@
#include "buildstep.h"
namespace ProjectExplorer {
namespace Internal {
namespace ProjectExplorer::Internal {
class ProcessStepFactory final : public BuildStepFactory
{
@@ -14,5 +13,4 @@ public:
ProcessStepFactory();
};
} // namespace Internal
} // namespace ProjectExplorer
} // ProjectExplorer::Internal