diff options
author | hjk <[email protected]> | 2023-11-20 13:16:13 +0100 |
---|---|---|
committer | hjk <[email protected]> | 2023-11-20 15:56:27 +0000 |
commit | 8c3a1c7e5c24db154d43cda49f51d6adec4b5224 (patch) | |
tree | 4e24a5981711ae6c7ed34f82d6bd1c32ad631074 /src/plugins/haskell/haskellproject.cpp | |
parent | e6b052e0403e6ec49316d118150579e02a08efbc (diff) |
Haskell: Move haskell project setup closer to new setup pattern
Change-Id: I3c6e6ad1a6f4b0a8d0a5598ad970c7539d1643e3
Reviewed-by: Jarek Kobus <[email protected]>
Diffstat (limited to 'src/plugins/haskell/haskellproject.cpp')
-rw-r--r-- | src/plugins/haskell/haskellproject.cpp | 59 |
1 files changed, 41 insertions, 18 deletions
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 |