aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2017-11-27 14:56:45 +0100
committerEike Ziller <eike.ziller@qt.io>2017-12-11 09:24:42 +0000
commita1fd1a7abb54a3d4fbe88268470dc9fdc13668b0 (patch)
tree4e427f0bfb1c5cbf1f9196138588224d7be0aff9
parent6ee714619f6cdd95098c98e86c840ee56b2f07f4 (diff)
Adapt to upstream build config and Utils::Link changes
Change-Id: Ib3f470b1d3df47b90f054ef1e006927b9ee675ca Reviewed-by: Eike Ziller <eike.ziller@qt.io>
-rw-r--r--plugins/haskell/haskellbuildconfiguration.cpp75
-rw-r--r--plugins/haskell/haskellbuildconfiguration.h12
-rw-r--r--plugins/haskell/haskellconstants.h2
-rw-r--r--plugins/haskell/haskelleditorwidget.cpp8
-rw-r--r--plugins/haskell/haskelleditorwidget.h4
-rw-r--r--plugins/haskell/haskellproject.cpp8
-rw-r--r--plugins/haskell/haskellrunconfiguration.cpp19
-rw-r--r--plugins/haskell/haskellrunconfiguration.h4
-rw-r--r--plugins/haskell/stackbuildstep.cpp26
-rw-r--r--plugins/haskell/stackbuildstep.h11
10 files changed, 52 insertions, 117 deletions
diff --git a/plugins/haskell/haskellbuildconfiguration.cpp b/plugins/haskell/haskellbuildconfiguration.cpp
index 0412340..c5c5d18 100644
--- a/plugins/haskell/haskellbuildconfiguration.cpp
+++ b/plugins/haskell/haskellbuildconfiguration.cpp
@@ -51,11 +51,11 @@ const char C_HASKELL_BUILDCONFIGURATION_ID[] = "Haskell.BuildConfiguration";
namespace Haskell {
namespace Internal {
-HaskellBuildConfigurationFactory::HaskellBuildConfigurationFactory() {}
-
-int HaskellBuildConfigurationFactory::priority(const Target *parent) const
+HaskellBuildConfigurationFactory::HaskellBuildConfigurationFactory()
{
- return HaskellProject::isHaskellProject(parent->project()) ? 0 : -1;
+ registerBuildConfiguration<HaskellBuildConfiguration>(C_HASKELL_BUILDCONFIGURATION_ID);
+ setSupportedProjectType(Constants::C_HASKELL_PROJECT_ID);
+ setSupportedProjectMimeTypeName(Constants::C_HASKELL_PROJECT_MIMETYPE);
}
static QList<BuildInfo *> createInfos(const HaskellBuildConfigurationFactory *factory,
@@ -74,7 +74,6 @@ static QList<BuildInfo *> createInfos(const HaskellBuildConfigurationFactory *fa
QList<BuildInfo *> HaskellBuildConfigurationFactory::availableBuilds(const Target *parent) const
{
// Entries that are available in add build configuration dropdown
- QTC_ASSERT(priority(parent) > -1, return {});
return Utils::transform(createInfos(this, parent->kit(), parent->project()->projectFilePath()),
[](BuildInfo *info) {
info->displayName.clear();
@@ -82,13 +81,6 @@ QList<BuildInfo *> HaskellBuildConfigurationFactory::availableBuilds(const Targe
});
}
-int HaskellBuildConfigurationFactory::priority(const Kit *k, const QString &projectPath) const
-{
- if (k && Utils::mimeTypeForFile(projectPath).matchesName(Constants::C_HASKELL_PROJECT_MIMETYPE))
- return 0;
- return -1;
-}
-
QList<BuildInfo *> HaskellBuildConfigurationFactory::availableSetups(
const Kit *k, const QString &projectPath) const
{
@@ -96,52 +88,6 @@ QList<BuildInfo *> HaskellBuildConfigurationFactory::availableSetups(
return createInfos(this, k, Utils::FileName::fromString(projectPath));
}
-BuildConfiguration *HaskellBuildConfigurationFactory::create(Target *parent,
- const BuildInfo *info) const
-{
- QTC_ASSERT(HaskellProject::isHaskellProject(parent->project()), return nullptr);
- auto config = new HaskellBuildConfiguration(parent);
- config->setBuildDirectory(info->buildDirectory);
- config->setBuildType(info->buildType);
- config->setDisplayName(info->displayName);
-
- BuildStepList *buildSteps = config->stepList(Core::Id(ProjectExplorer::Constants::BUILDSTEPS_BUILD));
- auto stackBuildStep = new StackBuildStep(buildSteps);
- buildSteps->appendStep(stackBuildStep);
-
- return config;
-}
-
-bool HaskellBuildConfigurationFactory::canRestore(const Target *parent, const QVariantMap &map) const
-{
- Q_UNUSED(map)
- return HaskellProject::isHaskellProject(parent->project());
-}
-
-BuildConfiguration *HaskellBuildConfigurationFactory::restore(Target *parent, const QVariantMap &map)
-{
- QTC_ASSERT(canRestore(parent, map), return nullptr);
- auto config = new HaskellBuildConfiguration(parent);
- config->fromMap(map);
- return config;
-}
-
-bool HaskellBuildConfigurationFactory::canClone(const Target *parent,
- BuildConfiguration *product) const
-{
- Q_UNUSED(parent)
- return product->id() == C_HASKELL_BUILDCONFIGURATION_ID;
-}
-
-BuildConfiguration *HaskellBuildConfigurationFactory::clone(Target *parent,
- BuildConfiguration *product)
-{
- QTC_ASSERT(canClone(parent, product), return nullptr);
- auto config = new HaskellBuildConfiguration(parent);
- config->fromMap(product->toMap());
- return config;
-}
-
HaskellBuildConfiguration::HaskellBuildConfiguration(Target *target)
: BuildConfiguration(target, C_HASKELL_BUILDCONFIGURATION_ID)
{}
@@ -161,6 +107,19 @@ void HaskellBuildConfiguration::setBuildType(BuildConfiguration::BuildType type)
m_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);
+
+ BuildStepList *buildSteps = stepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD);
+ auto stackBuildStep = new StackBuildStep(buildSteps);
+ buildSteps->appendStep(stackBuildStep);
+}
+
HaskellBuildConfigurationWidget::HaskellBuildConfigurationWidget(HaskellBuildConfiguration *bc)
: NamedWidget()
, m_buildConfiguration(bc)
diff --git a/plugins/haskell/haskellbuildconfiguration.h b/plugins/haskell/haskellbuildconfiguration.h
index 56ec088..66e3323 100644
--- a/plugins/haskell/haskellbuildconfiguration.h
+++ b/plugins/haskell/haskellbuildconfiguration.h
@@ -38,21 +38,10 @@ class HaskellBuildConfigurationFactory : public ProjectExplorer::IBuildConfigura
public:
HaskellBuildConfigurationFactory();
- int priority(const ProjectExplorer::Target *parent) const override;
QList<ProjectExplorer::BuildInfo *> availableBuilds(
const ProjectExplorer::Target *parent) const override;
- int priority(const ProjectExplorer::Kit *k, const QString &projectPath) const override;
QList<ProjectExplorer::BuildInfo *> availableSetups(const ProjectExplorer::Kit *k,
const QString &projectPath) const override;
- ProjectExplorer::BuildConfiguration *create(
- ProjectExplorer::Target *parent, const ProjectExplorer::BuildInfo *info) const override;
- bool canRestore(const ProjectExplorer::Target *parent, const QVariantMap &map) const override;
- ProjectExplorer::BuildConfiguration *restore(ProjectExplorer::Target *parent,
- const QVariantMap &map) override;
- bool canClone(const ProjectExplorer::Target *parent,
- ProjectExplorer::BuildConfiguration *product) const override;
- ProjectExplorer::BuildConfiguration *clone(
- ProjectExplorer::Target *parent, ProjectExplorer::BuildConfiguration *product) override;
};
class HaskellBuildConfiguration : public ProjectExplorer::BuildConfiguration
@@ -65,6 +54,7 @@ public:
ProjectExplorer::NamedWidget *createConfigWidget() override;
BuildType buildType() const override;
void setBuildType(BuildType type);
+ void initialize(const ProjectExplorer::BuildInfo *info) override;
private:
BuildType m_buildType = BuildType::Release;
diff --git a/plugins/haskell/haskellconstants.h b/plugins/haskell/haskellconstants.h
index 1ff285c..1ec7113 100644
--- a/plugins/haskell/haskellconstants.h
+++ b/plugins/haskell/haskellconstants.h
@@ -32,6 +32,8 @@ const char C_HASKELLEDITOR_ID[] = "Haskell.HaskellEditor";
const char C_HASKELLSNIPPETSGROUP_ID[] = "Haskell";
const char C_HASKELL_PROJECT_MIMETYPE[] = "text/x-haskell-project";
const char C_HASKELL_RUNCONFIG_ID_PREFIX[] = "Haskell.Run.";
+const char C_HASKELL_PROJECT_ID[] = "Haskell.Project";
+const char C_HASKELL_EXECUTABLE_KEY[] = "Haskell.Executable";
} // namespace Haskell
} // namespace Constants
diff --git a/plugins/haskell/haskelleditorwidget.cpp b/plugins/haskell/haskelleditorwidget.cpp
index 785f4e0..8d052a9 100644
--- a/plugins/haskell/haskelleditorwidget.cpp
+++ b/plugins/haskell/haskelleditorwidget.cpp
@@ -63,14 +63,14 @@ Utils::optional<Token> HaskellEditorWidget::symbolAt(QTextDocument *doc, int pos
return Utils::nullopt;
}
-TextEditorWidget::Link HaskellEditorWidget::findLinkAt(const QTextCursor &cursor,
- bool resolveTarget, bool inNextSplit)
+Utils::Link HaskellEditorWidget::findLinkAt(const QTextCursor &cursor,
+ bool resolveTarget, bool inNextSplit)
{
int line, column;
const Utils::optional<Token> symbol = symbolAt(document(), cursor.position(), &line, &column);
if (symbol) {
const QTextBlock block = document()->findBlockByNumber(line - 1);
- Link link;
+ Utils::Link link;
link.linkTextStart = block.position() + symbol->startCol;
link.linkTextEnd = link.linkTextStart + symbol->length;
if (resolveTarget) {
@@ -79,7 +79,7 @@ TextEditorWidget::Link HaskellEditorWidget::findLinkAt(const QTextCursor &cursor
}
return link;
}
- return Link();
+ return Utils::Link();
}
} // namespace Internal
diff --git a/plugins/haskell/haskelleditorwidget.h b/plugins/haskell/haskelleditorwidget.h
index f8b2102..819e040 100644
--- a/plugins/haskell/haskelleditorwidget.h
+++ b/plugins/haskell/haskelleditorwidget.h
@@ -44,8 +44,8 @@ public:
int *line, int *column);
protected:
- Link findLinkAt(const QTextCursor &cursor, bool resolveTarget = true,
- bool inNextSplit = false) override;
+ Utils::Link findLinkAt(const QTextCursor &cursor, bool resolveTarget = true,
+ bool inNextSplit = false) override;
private:
FollowSymbolAssistProvider m_followSymbolAssistProvider;
diff --git a/plugins/haskell/haskellproject.cpp b/plugins/haskell/haskellproject.cpp
index 420ea9e..31af7b7 100644
--- a/plugins/haskell/haskellproject.cpp
+++ b/plugins/haskell/haskellproject.cpp
@@ -39,8 +39,6 @@
using namespace ProjectExplorer;
using namespace Utils;
-const char C_HASKELL_PROJECT_ID[] = "Haskell.Project";
-
namespace Haskell {
namespace Internal {
@@ -69,19 +67,19 @@ HaskellProjectNode::HaskellProjectNode(const FileName &projectFilePath, Core::Id
HaskellProject::HaskellProject(const Utils::FileName &fileName)
: Project(Constants::C_HASKELL_PROJECT_MIMETYPE, fileName)
{
- setId(C_HASKELL_PROJECT_ID);
+ setId(Constants::C_HASKELL_PROJECT_ID);
setDisplayName(fileName.toFileInfo().completeBaseName());
updateFiles();
}
bool HaskellProject::isHaskellProject(Project *project)
{
- return project && project->id() == C_HASKELL_PROJECT_ID;
+ return project && project->id() == Constants::C_HASKELL_PROJECT_ID;
}
HaskellProject *HaskellProject::toHaskellProject(Project *project)
{
- if (project && project->id() == C_HASKELL_PROJECT_ID)
+ if (project && project->id() == Constants::C_HASKELL_PROJECT_ID)
return static_cast<HaskellProject *>(project);
return nullptr;
}
diff --git a/plugins/haskell/haskellrunconfiguration.cpp b/plugins/haskell/haskellrunconfiguration.cpp
index 9e7b6ff..7b47ff6 100644
--- a/plugins/haskell/haskellrunconfiguration.cpp
+++ b/plugins/haskell/haskellrunconfiguration.cpp
@@ -60,7 +60,7 @@ QList<QString> HaskellRunConfigurationFactory::availableBuildTargets(
}
HaskellRunConfiguration::HaskellRunConfiguration(Target *parent)
- : RunConfiguration(parent)
+ : RunConfiguration(parent, Constants::C_HASKELL_RUNCONFIG_ID_PREFIX)
{
auto argumentAspect = new ArgumentsAspect(this, "Haskell.RunAspect.Arguments");
auto workingDirAspect = new WorkingDirectoryAspect(this, "Haskell.RunAspect.WorkingDirectory");
@@ -108,11 +108,22 @@ Runnable HaskellRunConfiguration::runnable() const
return r;
}
-void HaskellRunConfiguration::initialize(Core::Id id)
+bool HaskellRunConfiguration::fromMap(const QVariantMap &map)
{
- RunConfiguration::initialize(id);
- m_executable = id.suffixAfter(Constants::C_HASKELL_RUNCONFIG_ID_PREFIX);
+ 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;
+}
+
+QVariantMap HaskellRunConfiguration::toMap() const
+{
+ QVariantMap map = RunConfiguration::toMap();
+ map.insert(QString(Constants::C_HASKELL_EXECUTABLE_KEY), m_executable);
+ return map;
}
} // namespace Internal
diff --git a/plugins/haskell/haskellrunconfiguration.h b/plugins/haskell/haskellrunconfiguration.h
index e40a9cc..7423487 100644
--- a/plugins/haskell/haskellrunconfiguration.h
+++ b/plugins/haskell/haskellrunconfiguration.h
@@ -50,7 +50,9 @@ public:
QWidget *createConfigurationWidget() override;
ProjectExplorer::Runnable runnable() const override;
- void initialize(Core::Id id);
+
+ bool fromMap(const QVariantMap &map) override;
+ QVariantMap toMap() const override;
private:
QString m_executable;
diff --git a/plugins/haskell/stackbuildstep.cpp b/plugins/haskell/stackbuildstep.cpp
index f4b1cfb..d392c03 100644
--- a/plugins/haskell/stackbuildstep.cpp
+++ b/plugins/haskell/stackbuildstep.cpp
@@ -75,30 +75,10 @@ QString StackBuildStep::trDisplayName()
return tr("Stack Build");
}
-QList<BuildStepInfo> StackBuildStepFactory::availableSteps(BuildStepList *parent) const
+StackBuildStepFactory::StackBuildStepFactory()
{
- Q_UNUSED(parent)
- return {BuildStepInfo(C_STACK_BUILD_STEP_ID, StackBuildStep::trDisplayName())};
-}
-
-BuildStep *StackBuildStepFactory::create(BuildStepList *parent, Core::Id id)
-{
- Q_UNUSED(id)
- return new StackBuildStep(parent);
-}
-
-BuildStep *StackBuildStepFactory::restore(BuildStepList *parent, const QVariantMap &map)
-{
- auto step = new StackBuildStep(parent);
- step->fromMap(map);
- return step;
-}
-
-BuildStep *StackBuildStepFactory::clone(BuildStepList *parent, BuildStep *product)
-{
- auto step = new StackBuildStep(parent);
- step->fromMap(product->toMap());
- return step;
+ registerStep<StackBuildStep>(C_STACK_BUILD_STEP_ID);
+ setDisplayName(StackBuildStep::StackBuildStep::trDisplayName());
}
} // namespace Internal
diff --git a/plugins/haskell/stackbuildstep.h b/plugins/haskell/stackbuildstep.h
index e786d18..e03ab97 100644
--- a/plugins/haskell/stackbuildstep.h
+++ b/plugins/haskell/stackbuildstep.h
@@ -42,17 +42,10 @@ public:
static QString trDisplayName();
};
-class StackBuildStepFactory : public ProjectExplorer::IBuildStepFactory
+class StackBuildStepFactory : public ProjectExplorer::BuildStepFactory
{
- // IBuildStepFactory interface
public:
- QList<ProjectExplorer::BuildStepInfo> availableSteps(
- ProjectExplorer::BuildStepList *parent) const override;
- ProjectExplorer::BuildStep *create(ProjectExplorer::BuildStepList *parent, Core::Id id) override;
- ProjectExplorer::BuildStep *restore(ProjectExplorer::BuildStepList *parent,
- const QVariantMap &map) override;
- ProjectExplorer::BuildStep *clone(ProjectExplorer::BuildStepList *parent,
- ProjectExplorer::BuildStep *product) override;
+ StackBuildStepFactory();
};
} // namespace Internal