From 9dd2477c2a9f7383e9eaa0b6f6b1f7691baae1f1 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Thu, 19 Dec 2019 15:12:08 +0100 Subject: Adapt to changes in upstream Change-Id: Ib541f1cedacf4472223d11ae545a3d444190180c Reviewed-by: hjk --- plugins/haskell/haskellbuildconfiguration.cpp | 26 +++++------ plugins/haskell/haskellbuildconfiguration.h | 1 - plugins/haskell/haskellproject.cpp | 63 ++++++++++++--------------- plugins/haskell/haskellproject.h | 21 ++++++--- plugins/haskell/haskellrunconfiguration.cpp | 14 ++---- plugins/haskell/haskellrunconfiguration.h | 1 - 6 files changed, 58 insertions(+), 68 deletions(-) (limited to 'plugins') diff --git a/plugins/haskell/haskellbuildconfiguration.cpp b/plugins/haskell/haskellbuildconfiguration.cpp index ebf5960..dcd582a 100644 --- a/plugins/haskell/haskellbuildconfiguration.cpp +++ b/plugins/haskell/haskellbuildconfiguration.cpp @@ -74,7 +74,16 @@ QList HaskellBuildConfigurationFactory::availableBuilds( HaskellBuildConfiguration::HaskellBuildConfiguration(Target *target, Core::Id id) : BuildConfiguration(target, id) -{} +{ + setInitializer([this](const BuildInfo &info) { + setBuildDirectory(info.buildDirectory); + setBuildType(info.buildType); + setDisplayName(info.displayName); + + auto stackBuildStep = new StackBuildStep(buildSteps()); + buildSteps()->appendStep(stackBuildStep); + }); +} NamedWidget *HaskellBuildConfiguration::createConfigWidget() { @@ -91,23 +100,10 @@ void HaskellBuildConfiguration::setBuildType(BuildConfiguration::BuildType type) m_buildType = type; } -void HaskellBuildConfiguration::initialize() -{ - BuildConfiguration::initialize(); - setBuildDirectory(initialBuildDirectory()); - setBuildType(initialBuildType()); - setDisplayName(initialDisplayName()); - - BuildStepList *buildSteps = stepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD); - auto stackBuildStep = new StackBuildStep(buildSteps); - buildSteps->appendStep(stackBuildStep); -} - HaskellBuildConfigurationWidget::HaskellBuildConfigurationWidget(HaskellBuildConfiguration *bc) - : NamedWidget() + : NamedWidget(tr("General")) , m_buildConfiguration(bc) { - setDisplayName(tr("General")); setLayout(new QVBoxLayout); layout()->setMargin(0); auto box = new Utils::DetailsWidget; diff --git a/plugins/haskell/haskellbuildconfiguration.h b/plugins/haskell/haskellbuildconfiguration.h index 5516626..f07f918 100644 --- a/plugins/haskell/haskellbuildconfiguration.h +++ b/plugins/haskell/haskellbuildconfiguration.h @@ -53,7 +53,6 @@ public: ProjectExplorer::NamedWidget *createConfigWidget() override; BuildType buildType() const override; void setBuildType(BuildType type); - void initialize() override; private: BuildType m_buildType = BuildType::Release; diff --git a/plugins/haskell/haskellproject.cpp b/plugins/haskell/haskellproject.cpp index fdea603..c4d4318 100644 --- a/plugins/haskell/haskellproject.cpp +++ b/plugins/haskell/haskellproject.cpp @@ -65,18 +65,12 @@ static QVector parseExecutableNames(const FilePath &projectFilePath) return result; } -HaskellProjectNode::HaskellProjectNode(const FilePath &projectFilePath) - : ProjectNode(projectFilePath) -{} - HaskellProject::HaskellProject(const Utils::FilePath &fileName) : Project(Constants::C_HASKELL_PROJECT_MIMETYPE, fileName) { setId(Constants::C_HASKELL_PROJECT_ID); setDisplayName(fileName.toFileInfo().completeBaseName()); - updateFiles(); - connect(this, &Project::activeTargetChanged, this, &HaskellProject::updateApplicationTargets); - connect(this, &Project::projectFileIsDirty, this, &HaskellProject::refresh); + setBuildSystemCreator([](Target *t) { return new HaskellBuildSystem(t); }); } bool HaskellProject::isHaskellProject(Project *project) @@ -84,35 +78,43 @@ bool HaskellProject::isHaskellProject(Project *project) return project && project->id() == Constants::C_HASKELL_PROJECT_ID; } -void HaskellProject::updateFiles() +HaskellBuildSystem::HaskellBuildSystem(Target *t) + : BuildSystem(t) { - m_parseGuard = guardParsingRun(); - FilePath projectDir = projectDirectory(); - QFuture> future = Utils::runAsync([this, projectDir] { - return FileNode::scanForFiles(projectDir, [this](const FilePath &fn) -> FileNode * { - if (fn != FilePath::fromString(projectFilePath().toString() + ".user")) - return new FileNode(fn, FileType::Source); - else - return nullptr; - }); - }); - Utils::onResultReady(future, this, [this](const QList &nodes) { - auto root = new HaskellProjectNode(projectDirectory()); - root->setDisplayName(displayName()); + connect(&m_scanner, &TreeScanner::finished, this, [this] { + auto root = std::make_unique(projectDirectory()); + root->setDisplayName(target()->project()->displayName()); std::vector> nodePtrs - = Utils::transform(nodes, [](FileNode *fn) { + = Utils::transform(m_scanner.release(), [](FileNode *fn) { return std::unique_ptr(fn); }); root->addNestedNodes(std::move(nodePtrs)); - setRootProjectNode(std::unique_ptr(root)); + setRootProjectNode(std::move(root)); + + updateApplicationTargets(); + m_parseGuard.markAsSuccess(); m_parseGuard = {}; + + emitBuildSystemUpdated(); }); + + connect(target()->project(), + &Project::projectFileIsDirty, + this, + &BuildSystem::requestDelayedParse); + + requestDelayedParse(); } -void HaskellProject::updateApplicationTargets(Target *target) +void HaskellBuildSystem::triggerParsing() +{ + m_parseGuard = guardParsingRun(); + m_scanner.asyncScanForFiles(target()->project()->projectDirectory()); +} + +void HaskellBuildSystem::updateApplicationTargets() { - QTC_ASSERT(target, return); const QVector executables = parseExecutableNames(projectFilePath()); const Utils::FilePath projFilePath = projectFilePath(); const QList appTargets @@ -125,15 +127,8 @@ void HaskellProject::updateApplicationTargets(Target *target) bti.isQtcRunnable = true; return bti; }); - target->setApplicationTargets(appTargets); - target->updateDefaultRunConfigurations(); -} - -void HaskellProject::refresh() -{ - updateFiles(); - if (activeTarget()) - updateApplicationTargets(activeTarget()); + setApplicationTargets(appTargets); + target()->updateDefaultRunConfigurations(); } } // namespace Internal diff --git a/plugins/haskell/haskellproject.h b/plugins/haskell/haskellproject.h index 4f6e1e4..af78e54 100644 --- a/plugins/haskell/haskellproject.h +++ b/plugins/haskell/haskellproject.h @@ -25,33 +25,40 @@ #pragma once +#include #include #include +#include namespace Haskell { namespace Internal { -class HaskellProjectNode : public ProjectExplorer::ProjectNode +class HaskellProject : public ProjectExplorer::Project { + Q_OBJECT + public: - HaskellProjectNode(const Utils::FilePath &projectFilePath); + explicit HaskellProject(const Utils::FilePath &fileName); + + static bool isHaskellProject(Project *project); }; -class HaskellProject : public ProjectExplorer::Project +class HaskellBuildSystem : public ProjectExplorer::BuildSystem { Q_OBJECT public: - explicit HaskellProject(const Utils::FilePath &fileName); + HaskellBuildSystem(ProjectExplorer::Target *t); - static bool isHaskellProject(Project *project); + void triggerParsing() override; private: - void updateFiles(); - void updateApplicationTargets(ProjectExplorer::Target *target); + void updateApplicationTargets(); void refresh(); +private: ParseGuard m_parseGuard; + ProjectExplorer::TreeScanner m_scanner; }; } // namespace Internal diff --git a/plugins/haskell/haskellrunconfiguration.cpp b/plugins/haskell/haskellrunconfiguration.cpp index f2f47c5..c421571 100644 --- a/plugins/haskell/haskellrunconfiguration.cpp +++ b/plugins/haskell/haskellrunconfiguration.cpp @@ -58,12 +58,7 @@ HaskellRunConfiguration::HaskellRunConfiguration(Target *target, Core::Id id) { addAspect(target); - auto executableAspect = addAspect(); - connect(target, &Target::applicationTargetsChanged, this, [this, target, executableAspect] { - BuildTargetInfo bti = target->buildTarget(buildKey()); - executableAspect->setValue(bti.targetFilePath.toString()); - }); - + addAspect(); addAspect(); auto workingDirAspect = addAspect(); @@ -71,11 +66,10 @@ HaskellRunConfiguration::HaskellRunConfiguration(Target *target, Core::Id id) workingDirAspect->setVisible(false); addAspect(); -} -void HaskellRunConfiguration::doAdditionalSetup(const RunConfigurationCreationInfo &info) -{ - aspect()->setValue(info.buildKey); + setUpdater([this] { aspect()->setValue(buildTargetInfo().buildKey); }); + connect(target, &Target::buildSystemUpdated, this, &RunConfiguration::update); + update(); } Runnable HaskellRunConfiguration::runnable() const diff --git a/plugins/haskell/haskellrunconfiguration.h b/plugins/haskell/haskellrunconfiguration.h index 529544e..6ff8331 100644 --- a/plugins/haskell/haskellrunconfiguration.h +++ b/plugins/haskell/haskellrunconfiguration.h @@ -41,7 +41,6 @@ public: HaskellRunConfiguration(ProjectExplorer::Target *target, Core::Id id); private: - void doAdditionalSetup(const ProjectExplorer::RunConfigurationCreationInfo &info) final; ProjectExplorer::Runnable runnable() const final; }; -- cgit v1.2.3