Haskell: Use new setup for run related classes

Change-Id: I9c6324aea586838d83bf81098499627c8c6c6d4a
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
hjk
2023-11-20 13:05:52 +01:00
parent cc711d7903
commit e6b052e040
3 changed files with 22 additions and 27 deletions

View File

@@ -26,13 +26,6 @@
namespace Haskell::Internal { namespace Haskell::Internal {
class HaskellPluginPrivate
{
public:
HaskellRunConfigurationFactory runConfigFactory;
ProjectExplorer::SimpleTargetRunnerFactory runWorkerFactory{{Constants::C_HASKELL_RUNCONFIG_ID}};
};
static void registerGhciAction(QObject *guard) static void registerGhciAction(QObject *guard)
{ {
QAction *action = new QAction(Tr::tr("Run GHCi"), guard); QAction *action = new QAction(Tr::tr("Run GHCi"), guard);
@@ -49,15 +42,13 @@ class HaskellPlugin final : public ExtensionSystem::IPlugin
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "Haskell.json") Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "Haskell.json")
public: public:
~HaskellPlugin() final { delete d; }
private:
void initialize() final void initialize() final
{ {
d = new HaskellPluginPrivate;
setupHaskellStackBuildStep(); setupHaskellStackBuildStep();
setupHaskellBuildConfiguration(); setupHaskellBuildConfiguration();
setupHaskellRunSupport();
setupHaskellEditor(); setupHaskellEditor();
ProjectExplorer::ProjectManager::registerProjectType<HaskellProject>( ProjectExplorer::ProjectManager::registerProjectType<HaskellProject>(
@@ -69,8 +60,6 @@ private:
ProjectExplorer::JsonWizardFactory::addWizardPath(":/haskell/share/wizards/"); ProjectExplorer::JsonWizardFactory::addWizardPath(":/haskell/share/wizards/");
} }
HaskellPluginPrivate *d = nullptr;
}; };
} // Haskell::Internal } // Haskell::Internal

View File

@@ -11,7 +11,9 @@
#include <projectexplorer/buildsystem.h> #include <projectexplorer/buildsystem.h>
#include <projectexplorer/project.h> #include <projectexplorer/project.h>
#include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/runconfiguration.h>
#include <projectexplorer/runconfigurationaspects.h> #include <projectexplorer/runconfigurationaspects.h>
#include <projectexplorer/runcontrol.h>
#include <projectexplorer/target.h> #include <projectexplorer/target.h>
#include <utils/processinterface.h> #include <utils/processinterface.h>
@@ -21,7 +23,7 @@ using namespace Utils;
namespace Haskell::Internal { namespace Haskell::Internal {
class HaskellRunConfiguration : public RunConfiguration class HaskellRunConfiguration final : public RunConfiguration
{ {
public: public:
HaskellRunConfiguration(Target *target, Id id) HaskellRunConfiguration(Target *target, Id id)
@@ -46,7 +48,7 @@ public:
} }
private: private:
Utils::ProcessRunData runnable() const final ProcessRunData runnable() const final
{ {
const FilePath projectDirectory = project()->projectDirectory(); const FilePath projectDirectory = project()->projectDirectory();
ProcessRunData r; ProcessRunData r;
@@ -75,11 +77,21 @@ private:
// Factory // Factory
HaskellRunConfigurationFactory::HaskellRunConfigurationFactory() class HaskellRunConfigurationFactory final : public ProjectExplorer::RunConfigurationFactory
{ {
public:
HaskellRunConfigurationFactory()
{
registerRunConfiguration<HaskellRunConfiguration>(Constants::C_HASKELL_RUNCONFIG_ID); registerRunConfiguration<HaskellRunConfiguration>(Constants::C_HASKELL_RUNCONFIG_ID);
addSupportedProjectType(Constants::C_HASKELL_PROJECT_ID); addSupportedProjectType(Constants::C_HASKELL_PROJECT_ID);
addSupportedTargetDeviceType(ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE); addSupportedTargetDeviceType(ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE);
}
};
void setupHaskellRunSupport()
{
static HaskellRunConfigurationFactory runConfigFactory;
static SimpleTargetRunnerFactory runWorkerFactory{{Constants::C_HASKELL_RUNCONFIG_ID}};
} }
} // Haskell::Internal } // Haskell::Internal

View File

@@ -3,14 +3,8 @@
#pragma once #pragma once
#include <projectexplorer/runconfiguration.h>
namespace Haskell::Internal { namespace Haskell::Internal {
class HaskellRunConfigurationFactory : public ProjectExplorer::RunConfigurationFactory void setupHaskellRunSupport();
{
public:
HaskellRunConfigurationFactory();
};
} // Haskell::Internal } // Haskell::Internal