aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhjk <[email protected]>2023-11-20 13:16:13 +0100
committerhjk <[email protected]>2023-11-20 15:56:27 +0000
commit8c3a1c7e5c24db154d43cda49f51d6adec4b5224 (patch)
tree4e24a5981711ae6c7ed34f82d6bd1c32ad631074
parente6b052e0403e6ec49316d118150579e02a08efbc (diff)
Haskell: Move haskell project setup closer to new setup pattern
Change-Id: I3c6e6ad1a6f4b0a8d0a5598ad970c7539d1643e3 Reviewed-by: Jarek Kobus <[email protected]>
-rw-r--r--src/plugins/haskell/haskellplugin.cpp6
-rw-r--r--src/plugins/haskell/haskellproject.cpp59
-rw-r--r--src/plugins/haskell/haskellproject.h40
3 files changed, 46 insertions, 59 deletions
diff --git a/src/plugins/haskell/haskellplugin.cpp b/src/plugins/haskell/haskellplugin.cpp
index 6da003c1a50..632b9514a98 100644
--- a/src/plugins/haskell/haskellplugin.cpp
+++ b/src/plugins/haskell/haskellplugin.cpp
@@ -17,8 +17,6 @@
#include <extensionsystem/iplugin.h>
#include <projectexplorer/jsonwizard/jsonwizardfactory.h>
-#include <projectexplorer/projectmanager.h>
-#include <projectexplorer/runcontrol.h>
#include <texteditor/snippets/snippetprovider.h>
@@ -51,8 +49,8 @@ public:
setupHaskellEditor();
- ProjectExplorer::ProjectManager::registerProjectType<HaskellProject>(
- Constants::C_HASKELL_PROJECT_MIMETYPE);
+ setupHaskellProject();
+
TextEditor::SnippetProvider::registerGroup(Constants::C_HASKELLSNIPPETSGROUP_ID,
Tr::tr("Haskell", "SnippetProvider"));
diff --git a/src/plugins/haskell/haskellproject.cpp b/src/plugins/haskell/haskellproject.cpp
index f19840a67f5..01d652c49ef 100644
--- a/src/plugins/haskell/haskellproject.cpp
+++ b/src/plugins/haskell/haskellproject.cpp
@@ -5,14 +5,16 @@
#include "haskellconstants.h"
-#include <coreplugin/iversioncontrol.h>
-#include <coreplugin/vcsmanager.h>
-
+#include <projectexplorer/buildsystem.h>
#include <projectexplorer/buildtargetinfo.h>
+#include <projectexplorer/project.h>
+#include <projectexplorer/projectmanager.h>
+#include <projectexplorer/projectnodes.h>
#include <projectexplorer/target.h>
+#include <projectexplorer/treescanner.h>
#include <utils/algorithm.h>
-#include <utils/fileutils.h>
+#include <utils/filepath.h>
#include <utils/qtcassert.h>
#include <QFile>
@@ -21,8 +23,7 @@
using namespace ProjectExplorer;
using namespace Utils;
-namespace Haskell {
-namespace Internal {
+namespace Haskell::Internal {
static QVector<QString> parseExecutableNames(const FilePath &projectFilePath)
{
@@ -42,18 +43,23 @@ static QVector<QString> parseExecutableNames(const FilePath &projectFilePath)
return result;
}
-HaskellProject::HaskellProject(const Utils::FilePath &fileName)
- : Project(Constants::C_HASKELL_PROJECT_MIMETYPE, fileName)
+class HaskellBuildSystem final : public BuildSystem
{
- setId(Constants::C_HASKELL_PROJECT_ID);
- setDisplayName(fileName.toFileInfo().completeBaseName());
- setBuildSystemCreator([](Target *t) { return new HaskellBuildSystem(t); });
-}
+public:
+ HaskellBuildSystem(Target *t);
-bool HaskellProject::isHaskellProject(Project *project)
-{
- return project && project->id() == Constants::C_HASKELL_PROJECT_ID;
-}
+ void triggerParsing() final;
+
+ QString name() const final { return QLatin1String("haskell"); }
+
+private:
+ void updateApplicationTargets();
+ void refresh();
+
+private:
+ ParseGuard m_parseGuard;
+ TreeScanner m_scanner;
+};
HaskellBuildSystem::HaskellBuildSystem(Target *t)
: BuildSystem(t)
@@ -108,5 +114,22 @@ void HaskellBuildSystem::updateApplicationTargets()
target()->updateDefaultRunConfigurations();
}
-} // namespace Internal
-} // namespace Haskell
+class HaskellProject final : public Project
+{
+public:
+ explicit HaskellProject(const FilePath &fileName)
+ : Project(Constants::C_HASKELL_PROJECT_MIMETYPE, fileName)
+ {
+ setId(Constants::C_HASKELL_PROJECT_ID);
+ setDisplayName(fileName.toFileInfo().completeBaseName());
+ setBuildSystemCreator([](Target *t) { return new HaskellBuildSystem(t); });
+ }
+};
+
+void setupHaskellProject()
+{
+ ProjectManager::registerProjectType<HaskellProject>(
+ Constants::C_HASKELL_PROJECT_MIMETYPE);
+}
+
+} // Haskell::Internal
diff --git a/src/plugins/haskell/haskellproject.h b/src/plugins/haskell/haskellproject.h
index 79bec049ae4..79627d9c5b0 100644
--- a/src/plugins/haskell/haskellproject.h
+++ b/src/plugins/haskell/haskellproject.h
@@ -3,42 +3,8 @@
#pragma once
-#include <projectexplorer/buildsystem.h>
-#include <projectexplorer/project.h>
-#include <projectexplorer/projectnodes.h>
-#include <projectexplorer/treescanner.h>
+namespace Haskell::Internal {
-namespace Haskell {
-namespace Internal {
+void setupHaskellProject();
-class HaskellProject : public ProjectExplorer::Project
-{
- Q_OBJECT
-
-public:
- explicit HaskellProject(const Utils::FilePath &fileName);
-
- static bool isHaskellProject(Project *project);
-};
-
-class HaskellBuildSystem : public ProjectExplorer::BuildSystem
-{
- Q_OBJECT
-
-public:
- HaskellBuildSystem(ProjectExplorer::Target *t);
-
- void triggerParsing() override;
- QString name() const final { return QLatin1String("haskell"); }
-
-private:
- void updateApplicationTargets();
- void refresh();
-
-private:
- ParseGuard m_parseGuard;
- ProjectExplorer::TreeScanner m_scanner;
-};
-
-} // namespace Internal
-} // namespace Haskell
+} // Haskell::Internal