Haskell: Move haskell project setup closer to new setup pattern

Change-Id: I3c6e6ad1a6f4b0a8d0a5598ad970c7539d1643e3
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
hjk
2023-11-20 13:16:13 +01:00
parent e6b052e040
commit 8c3a1c7e5c
3 changed files with 46 additions and 59 deletions

View File

@@ -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"));

View File

@@ -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

View File

@@ -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