aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2017-11-27 14:56:45 +0100
committerEike Ziller <eike.ziller@qt.io>2018-03-19 09:35:42 +0000
commit50e8ba6e959c533491fc8b8e64e155468b333552 (patch)
treead9241a4821649093ba0ecd1d90af22972461e3c
parent53592d59133868de4d9e667f647fac126e9f930b (diff)
Adapt to upstream infrastructure changes
Change-Id: Ic3f470b1d3df47b90f054ef1e006927b9ee675ca Reviewed-by: Eike Ziller <eike.ziller@qt.io>
-rw-r--r--plugins/haskell/followsymbol.cpp3
-rw-r--r--plugins/haskell/haskellbuildconfiguration.cpp1
-rw-r--r--plugins/haskell/haskellplugin.cpp43
-rw-r--r--plugins/haskell/haskellplugin.h12
-rw-r--r--plugins/haskell/haskellproject.cpp40
-rw-r--r--plugins/haskell/haskellproject.h4
-rw-r--r--plugins/haskell/haskellrunconfiguration.cpp22
-rw-r--r--plugins/haskell/haskellrunconfiguration.h19
8 files changed, 64 insertions, 80 deletions
diff --git a/plugins/haskell/followsymbol.cpp b/plugins/haskell/followsymbol.cpp
index e7ce1ea..d75c680 100644
--- a/plugins/haskell/followsymbol.cpp
+++ b/plugins/haskell/followsymbol.cpp
@@ -79,7 +79,8 @@ IAssistProposal *FollowSymbolAssistProcessor::immediateProposal(const AssistInte
item->setData(QString());
item->setOrder(-1000);
- auto proposal = new GenericProposal(interface->position(), {item});
+ const QList<TextEditor::AssistProposalItemInterface *> list = {item};
+ auto proposal = new GenericProposal(interface->position(), list);
proposal->setFragile(true);
return proposal;
}
diff --git a/plugins/haskell/haskellbuildconfiguration.cpp b/plugins/haskell/haskellbuildconfiguration.cpp
index c5c5d18..618ddd7 100644
--- a/plugins/haskell/haskellbuildconfiguration.cpp
+++ b/plugins/haskell/haskellbuildconfiguration.cpp
@@ -110,7 +110,6 @@ void HaskellBuildConfiguration::setBuildType(BuildConfiguration::BuildType type)
void HaskellBuildConfiguration::initialize(const BuildInfo *info)
{
BuildConfiguration::initialize(info);
- QTC_ASSERT(HaskellProject::isHaskellProject(target()->project()), return);
setBuildDirectory(info->buildDirectory);
setBuildType(info->buildType);
setDisplayName(info->displayName);
diff --git a/plugins/haskell/haskellplugin.cpp b/plugins/haskell/haskellplugin.cpp
index c5386a4..d92c4f8 100644
--- a/plugins/haskell/haskellplugin.cpp
+++ b/plugins/haskell/haskellplugin.cpp
@@ -42,34 +42,28 @@
namespace Haskell {
namespace Internal {
-HaskellPlugin::HaskellPlugin()
+class HaskellPluginPrivate
{
- // Create your members
-}
+public:
+ HaskellEditorFactory editorFactory;
+ OptionsPage optionsPage;
+ HaskellBuildConfigurationFactory buildConfigFactory;
+ StackBuildStepFactory stackBuildStepFactory;
+ HaskellRunConfigurationFactory runConfigFactory;
+};
HaskellPlugin::~HaskellPlugin()
{
- // Unregister objects from the plugin manager's object pool
- // Delete members
+ delete d;
}
bool HaskellPlugin::initialize(const QStringList &arguments, QString *errorString)
{
- // Register objects in the plugin manager's object pool
- // Load settings
- // Add actions to menus
- // Connect to other plugins' signals
- // In the initialize function, a plugin can be sure that the plugins it
- // depends on have initialized their members.
-
Q_UNUSED(arguments)
Q_UNUSED(errorString)
- addAutoReleasedObject(new HaskellEditorFactory);
- addAutoReleasedObject(new OptionsPage);
- addAutoReleasedObject(new HaskellBuildConfigurationFactory);
- addAutoReleasedObject(new StackBuildStepFactory);
- addAutoReleasedObject(new HaskellRunConfigurationFactory);
+ d = new HaskellPluginPrivate;
+
ProjectExplorer::ProjectManager::registerProjectType<HaskellProject>(
Constants::C_HASKELL_PROJECT_MIMETYPE);
TextEditor::SnippetProvider::registerGroup(Constants::C_HASKELLSNIPPETSGROUP_ID,
@@ -85,20 +79,5 @@ bool HaskellPlugin::initialize(const QStringList &arguments, QString *errorStrin
return true;
}
-void HaskellPlugin::extensionsInitialized()
-{
- // Retrieve objects from the plugin manager's object pool
- // In the extensionsInitialized function, a plugin can be sure that all
- // plugins that depend on it are completely initialized.
-}
-
-ExtensionSystem::IPlugin::ShutdownFlag HaskellPlugin::aboutToShutdown()
-{
- // Save settings
- // Disconnect from signals that are not needed during shutdown
- // Hide UI (if you add UI that is not in the main window directly)
- return SynchronousShutdown;
-}
-
} // namespace Internal
} // namespace Haskell
diff --git a/plugins/haskell/haskellplugin.h b/plugins/haskell/haskellplugin.h
index fd5180d..163f40b 100644
--- a/plugins/haskell/haskellplugin.h
+++ b/plugins/haskell/haskellplugin.h
@@ -38,12 +38,14 @@ class HaskellPlugin : public ExtensionSystem::IPlugin
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "Haskell.json")
public:
- HaskellPlugin();
- ~HaskellPlugin();
+ HaskellPlugin() = default;
+ ~HaskellPlugin() final;
- bool initialize(const QStringList &arguments, QString *errorString);
- void extensionsInitialized();
- ShutdownFlag aboutToShutdown();
+private:
+ bool initialize(const QStringList &arguments, QString *errorString) final;
+ void extensionsInitialized() final {}
+
+ class HaskellPluginPrivate *d = nullptr;
};
} // namespace Internal
diff --git a/plugins/haskell/haskellproject.cpp b/plugins/haskell/haskellproject.cpp
index 31af7b7..d87f6fc 100644
--- a/plugins/haskell/haskellproject.cpp
+++ b/plugins/haskell/haskellproject.cpp
@@ -29,8 +29,13 @@
#include <coreplugin/iversioncontrol.h>
#include <coreplugin/vcsmanager.h>
+
+#include <projectexplorer/buildtargetinfo.h>
+#include <projectexplorer/target.h>
+
#include <utils/algorithm.h>
#include <utils/fileutils.h>
+#include <utils/qtcassert.h>
#include <utils/runextensions.h>
#include <QFile>
@@ -70,6 +75,7 @@ HaskellProject::HaskellProject(const Utils::FileName &fileName)
setId(Constants::C_HASKELL_PROJECT_ID);
setDisplayName(fileName.toFileInfo().completeBaseName());
updateFiles();
+ connect(this, &Project::activeTargetChanged, this, &HaskellProject::updateApplicationTargets);
}
bool HaskellProject::isHaskellProject(Project *project)
@@ -77,18 +83,6 @@ bool HaskellProject::isHaskellProject(Project *project)
return project && project->id() == Constants::C_HASKELL_PROJECT_ID;
}
-HaskellProject *HaskellProject::toHaskellProject(Project *project)
-{
- if (project && project->id() == Constants::C_HASKELL_PROJECT_ID)
- return static_cast<HaskellProject *>(project);
- return nullptr;
-}
-
-QList<QString> HaskellProject::availableExecutables() const
-{
- return parseExecutableNames(projectFilePath()).toList();
-}
-
void HaskellProject::updateFiles()
{
emitParsingStarted();
@@ -114,5 +108,27 @@ void HaskellProject::updateFiles()
});
}
+void HaskellProject::updateApplicationTargets(Target *target)
+{
+ QTC_ASSERT(target, return);
+ const QVector<QString> executables = parseExecutableNames(projectFilePath());
+ const Utils::FileName projFilePath = projectFilePath();
+ const QList<BuildTargetInfo> appTargets
+ = Utils::transform<QList>(executables, [projFilePath](const QString &executable) {
+ BuildTargetInfo bti;
+ bti.targetName = executable;
+ bti.displayName = executable;
+ bti.buildKey = executable;
+ bti.targetFilePath = FileName::fromString(executable);
+ bti.projectFilePath = projFilePath;
+ bti.isQtcRunnable = true;
+ return bti;
+ });
+ BuildTargetInfoList list;
+ list.list = appTargets;
+ target->setApplicationTargets(list);
+ target->updateDefaultRunConfigurations();
+}
+
} // namespace Internal
} // namespace Haskell
diff --git a/plugins/haskell/haskellproject.h b/plugins/haskell/haskellproject.h
index e3019d2..245c997 100644
--- a/plugins/haskell/haskellproject.h
+++ b/plugins/haskell/haskellproject.h
@@ -45,12 +45,10 @@ public:
explicit HaskellProject(const Utils::FileName &fileName);
static bool isHaskellProject(Project *project);
- static HaskellProject *toHaskellProject(Project *project);
-
- QList<QString> availableExecutables() const;
private:
void updateFiles();
+ void updateApplicationTargets(ProjectExplorer::Target *target);
};
} // namespace Internal
diff --git a/plugins/haskell/haskellrunconfiguration.cpp b/plugins/haskell/haskellrunconfiguration.cpp
index 661fa05..c9ac93f 100644
--- a/plugins/haskell/haskellrunconfiguration.cpp
+++ b/plugins/haskell/haskellrunconfiguration.cpp
@@ -48,19 +48,7 @@ HaskellRunConfigurationFactory::HaskellRunConfigurationFactory()
{
registerRunConfiguration<HaskellRunConfiguration>(Constants::C_HASKELL_RUNCONFIG_ID_PREFIX);
addSupportedProjectType(Constants::C_HASKELL_PROJECT_ID);
- setSupportedTargetDeviceTypes({ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE});
-}
-
-QList<BuildTargetInfo> HaskellRunConfigurationFactory::availableBuildTargets(
- Target *parent, IRunConfigurationFactory::CreationMode mode) const
-{
- Q_UNUSED(mode)
- const auto project = HaskellProject::toHaskellProject(parent->project());
- if (!project)
- return {};
- return Utils::transform(project->availableExecutables(), [](const QString &name) {
- return BuildTargetInfo(name, Utils::FileName(), Utils::FileName());
- });
+ addSupportedTargetDeviceType(ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE);
}
HaskellRunConfiguration::HaskellRunConfiguration(Target *parent)
@@ -117,12 +105,16 @@ bool HaskellRunConfiguration::fromMap(const QVariantMap &map)
if (!RunConfiguration::fromMap(map))
return false;
m_executable = map.value(QString(Constants::C_HASKELL_EXECUTABLE_KEY)).toString();
- if (m_executable.isEmpty())
- m_executable = ProjectExplorer::idFromMap(map).suffixAfter(id());
setDefaultDisplayName(m_executable);
return true;
}
+void HaskellRunConfiguration::doAdditionalSetup(const RunConfigurationCreationInfo &info)
+{
+ m_executable = info.targetName;
+ setDefaultDisplayName(m_executable);
+}
+
QVariantMap HaskellRunConfiguration::toMap() const
{
QVariantMap map = RunConfiguration::toMap();
diff --git a/plugins/haskell/haskellrunconfiguration.h b/plugins/haskell/haskellrunconfiguration.h
index 9970d65..3b40694 100644
--- a/plugins/haskell/haskellrunconfiguration.h
+++ b/plugins/haskell/haskellrunconfiguration.h
@@ -30,15 +30,10 @@
namespace Haskell {
namespace Internal {
-class HaskellRunConfigurationFactory : public ProjectExplorer::IRunConfigurationFactory
+class HaskellRunConfigurationFactory : public ProjectExplorer::RunConfigurationFactory
{
- Q_OBJECT
-
public:
HaskellRunConfigurationFactory();
-
- QList<ProjectExplorer::BuildTargetInfo> availableBuildTargets(ProjectExplorer::Target *parent,
- CreationMode mode) const override;
};
class HaskellRunConfiguration : public ProjectExplorer::RunConfiguration
@@ -48,13 +43,15 @@ class HaskellRunConfiguration : public ProjectExplorer::RunConfiguration
public:
HaskellRunConfiguration(ProjectExplorer::Target *parent);
- QWidget *createConfigurationWidget() override;
- ProjectExplorer::Runnable runnable() const override;
+private:
+ QWidget *createConfigurationWidget() final;
+ ProjectExplorer::Runnable runnable() const final;
+ void handleBuildSystemDataUpdated();
- bool fromMap(const QVariantMap &map) override;
- QVariantMap toMap() const override;
+ bool fromMap(const QVariantMap &map) final;
+ QVariantMap toMap() const final;
+ void doAdditionalSetup(const ProjectExplorer::RunConfigurationCreationInfo &info) final;
-private:
QString m_executable;
};