diff --git a/src/plugins/haskell/haskellplugin.cpp b/src/plugins/haskell/haskellplugin.cpp index 80039b96b21..d32165075f8 100644 --- a/src/plugins/haskell/haskellplugin.cpp +++ b/src/plugins/haskell/haskellplugin.cpp @@ -31,7 +31,6 @@ class HaskellPluginPrivate public: HaskellEditorFactory editorFactory; HaskellBuildConfigurationFactory buildConfigFactory; - StackBuildStepFactory stackBuildStepFactory; HaskellRunConfigurationFactory runConfigFactory; ProjectExplorer::SimpleTargetRunnerFactory runWorkerFactory{{Constants::C_HASKELL_RUNCONFIG_ID}}; }; @@ -59,6 +58,8 @@ private: { d = new HaskellPluginPrivate; + setupHaskellStackBuildStep(); + ProjectExplorer::ProjectManager::registerProjectType( Constants::C_HASKELL_PROJECT_MIMETYPE); TextEditor::SnippetProvider::registerGroup(Constants::C_HASKELLSNIPPETSGROUP_ID, diff --git a/src/plugins/haskell/stackbuildstep.cpp b/src/plugins/haskell/stackbuildstep.cpp index 4006ae9daad..b7ba35fbb60 100644 --- a/src/plugins/haskell/stackbuildstep.cpp +++ b/src/plugins/haskell/stackbuildstep.cpp @@ -7,6 +7,7 @@ #include "haskellsettings.h" #include "haskelltr.h" +#include #include #include #include @@ -14,43 +15,54 @@ using namespace ProjectExplorer; -namespace Haskell { -namespace Internal { +namespace Haskell::Internal { -StackBuildStep::StackBuildStep(ProjectExplorer::BuildStepList *bsl, Utils::Id id) - : AbstractProcessStep(bsl, id) -{ - setDefaultDisplayName(trDisplayName()); -} - -QWidget *StackBuildStep::createConfigWidget() -{ - return new QWidget; -} - -QString StackBuildStep::trDisplayName() +static QString trDisplayName() { return Tr::tr("Stack Build"); } -bool StackBuildStep::init() +class StackBuildStep final : public AbstractProcessStep { - if (AbstractProcessStep::init()) { - const auto projectDir = QDir(project()->projectDirectory().toString()); - processParameters()->setCommandLine( - {settings().stackPath(), - {"build", "--work-dir", projectDir.relativeFilePath(buildDirectory().toString())}}); - processParameters()->setEnvironment(buildEnvironment()); +public: + StackBuildStep(BuildStepList *bsl, Utils::Id id) + : AbstractProcessStep(bsl, id) + { + setDefaultDisplayName(trDisplayName()); } - return true; -} -StackBuildStepFactory::StackBuildStepFactory() + QWidget *createConfigWidget() final + { + return new QWidget; + } + + bool init() final + { + if (AbstractProcessStep::init()) { + const auto projectDir = QDir(project()->projectDirectory().toString()); + processParameters()->setCommandLine( + {settings().stackPath(), + {"build", "--work-dir", projectDir.relativeFilePath(buildDirectory().toString())}}); + processParameters()->setEnvironment(buildEnvironment()); + } + return true; + } +}; + +class StackBuildStepFactory final : public BuildStepFactory { - registerStep(Constants::C_STACK_BUILD_STEP_ID); - setDisplayName(StackBuildStep::StackBuildStep::trDisplayName()); - setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD); +public: + StackBuildStepFactory() + { + registerStep(Constants::C_STACK_BUILD_STEP_ID); + setDisplayName(trDisplayName()); + setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD); + } +}; + +void setupHaskellStackBuildStep() +{ + static StackBuildStepFactory theStackBuildStepFactory; } -} // namespace Internal -} // namespace Haskell +} // Haskell::Internal diff --git a/src/plugins/haskell/stackbuildstep.h b/src/plugins/haskell/stackbuildstep.h index dbfbf2e72cd..9c3ca89a325 100644 --- a/src/plugins/haskell/stackbuildstep.h +++ b/src/plugins/haskell/stackbuildstep.h @@ -3,31 +3,8 @@ #pragma once -#include +namespace Haskell::Internal { -namespace Haskell { -namespace Internal { +void setupHaskellStackBuildStep(); -class StackBuildStep : public ProjectExplorer::AbstractProcessStep -{ - Q_OBJECT - -public: - StackBuildStep(ProjectExplorer::BuildStepList *bsl, Utils::Id id); - - QWidget *createConfigWidget() override; - - static QString trDisplayName(); - -protected: - bool init() override; -}; - -class StackBuildStepFactory : public ProjectExplorer::BuildStepFactory -{ -public: - StackBuildStepFactory(); -}; - -} // namespace Internal -} // namespace Haskell +} // Haskell::Internal