forked from qt-creator/qt-creator
CMake: Use setup functions for more plugin items
Change-Id: I48ff764248f29ef2a8f46757cba84705983c7740 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -271,11 +271,11 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
const CMakeFormatterSettingsPage settingsPage;
|
||||
|
||||
CMakeFormatter::CMakeFormatter()
|
||||
void setupCMakeFormatter()
|
||||
{
|
||||
static const CMakeFormatterSettingsPage theCMakeFormatterSettingsPage;
|
||||
|
||||
formatterSettings();
|
||||
}
|
||||
};
|
||||
|
||||
} // CMakeProjectManager::Internal
|
||||
|
||||
@@ -4,14 +4,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace Core { class IDocument; }
|
||||
|
||||
namespace CMakeProjectManager::Internal {
|
||||
|
||||
class CMakeFormatter
|
||||
{
|
||||
public:
|
||||
CMakeFormatter();
|
||||
};
|
||||
void setupCMakeFormatter();
|
||||
|
||||
} // CMakeProjectManager::Internal
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "cmakeprojectmanagertr.h"
|
||||
#include "cmaketool.h"
|
||||
|
||||
#include <projectexplorer/buildstep.h>
|
||||
#include <projectexplorer/buildsteplist.h>
|
||||
#include <projectexplorer/processparameters.h>
|
||||
#include <projectexplorer/project.h>
|
||||
@@ -27,7 +28,7 @@ namespace CMakeProjectManager::Internal {
|
||||
|
||||
// CMakeInstallStep
|
||||
|
||||
class CMakeInstallStep : public CMakeAbstractProcessStep
|
||||
class CMakeInstallStep final : public CMakeAbstractProcessStep
|
||||
{
|
||||
public:
|
||||
CMakeInstallStep(BuildStepList *bsl, Id id)
|
||||
@@ -112,7 +113,10 @@ QWidget *CMakeInstallStep::createConfigWidget()
|
||||
|
||||
// CMakeInstallStepFactory
|
||||
|
||||
CMakeInstallStepFactory::CMakeInstallStepFactory()
|
||||
class CMakeInstallStepFactory : public ProjectExplorer::BuildStepFactory
|
||||
{
|
||||
public:
|
||||
CMakeInstallStepFactory()
|
||||
{
|
||||
registerStep<CMakeInstallStep>(Constants::CMAKE_INSTALL_STEP_ID);
|
||||
setDisplayName(
|
||||
@@ -120,6 +124,11 @@ CMakeInstallStepFactory::CMakeInstallStepFactory()
|
||||
setSupportedProjectType(Constants::CMAKE_PROJECT_ID);
|
||||
setSupportedStepLists({ProjectExplorer::Constants::BUILDSTEPS_DEPLOY});
|
||||
}
|
||||
};
|
||||
|
||||
void setupCMakeInstallStep()
|
||||
{
|
||||
static CMakeInstallStepFactory theCMakeInstallStepFactory;
|
||||
}
|
||||
|
||||
} // CMakeProjectManager::Internal
|
||||
|
||||
|
||||
@@ -3,14 +3,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <projectexplorer/buildstep.h>
|
||||
|
||||
namespace CMakeProjectManager::Internal {
|
||||
|
||||
class CMakeInstallStepFactory : public ProjectExplorer::BuildStepFactory
|
||||
{
|
||||
public:
|
||||
CMakeInstallStepFactory();
|
||||
};
|
||||
void setupCMakeInstallStep();
|
||||
|
||||
} // CMakeProjectManager::Internal
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
#include "cmakeproject.h"
|
||||
#include "cmakeprojectmanagertr.h"
|
||||
|
||||
#include <coreplugin/locator/ilocatorfilter.h>
|
||||
|
||||
#include <projectexplorer/buildmanager.h>
|
||||
#include <projectexplorer/buildsteplist.h>
|
||||
#include <projectexplorer/projectmanager.h>
|
||||
@@ -23,6 +25,8 @@ namespace CMakeProjectManager::Internal {
|
||||
|
||||
using BuildAcceptor = std::function<void(const FilePath &, const QString &)>;
|
||||
|
||||
// CMakeBuildTargetFilter
|
||||
|
||||
static LocatorMatcherTasks cmakeMatchers(const BuildAcceptor &acceptor)
|
||||
{
|
||||
using namespace Tasking;
|
||||
@@ -80,7 +84,7 @@ static LocatorMatcherTasks cmakeMatchers(const BuildAcceptor &acceptor)
|
||||
return {{Sync(onSetup), storage}};
|
||||
}
|
||||
|
||||
void setupFilter(ILocatorFilter *filter)
|
||||
static void setupFilter(ILocatorFilter *filter)
|
||||
{
|
||||
const auto projectListUpdated = [filter] {
|
||||
filter->setEnabled(Utils::contains(ProjectManager::projects(),
|
||||
@@ -92,10 +96,6 @@ void setupFilter(ILocatorFilter *filter)
|
||||
filter, projectListUpdated);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// BuildCMakeTargetLocatorFilter:
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
static void buildAcceptor(const FilePath &projectPath, const QString &displayName)
|
||||
{
|
||||
// Get the project containing the target selected
|
||||
@@ -126,7 +126,10 @@ static void buildAcceptor(const FilePath &projectPath, const QString &displayNam
|
||||
buildStep->setBuildTargets(oldTargets);
|
||||
}
|
||||
|
||||
CMakeBuildTargetFilter::CMakeBuildTargetFilter()
|
||||
class CMakeBuildTargetFilter final : ILocatorFilter
|
||||
{
|
||||
public:
|
||||
CMakeBuildTargetFilter()
|
||||
{
|
||||
setId("Build CMake target");
|
||||
setDisplayName(Tr::tr("Build CMake Target"));
|
||||
@@ -136,16 +139,16 @@ CMakeBuildTargetFilter::CMakeBuildTargetFilter()
|
||||
setupFilter(this);
|
||||
}
|
||||
|
||||
Core::LocatorMatcherTasks CMakeBuildTargetFilter::matchers()
|
||||
private:
|
||||
LocatorMatcherTasks matchers() final { return cmakeMatchers(&buildAcceptor); }
|
||||
};
|
||||
|
||||
// OpenCMakeTargetLocatorFilter
|
||||
|
||||
class CMakeOpenTargetFilter final : ILocatorFilter
|
||||
{
|
||||
return cmakeMatchers(&buildAcceptor);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// OpenCMakeTargetLocatorFilter:
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
CMakeOpenTargetFilter::CMakeOpenTargetFilter()
|
||||
public:
|
||||
CMakeOpenTargetFilter()
|
||||
{
|
||||
setId("Open CMake target definition");
|
||||
setDisplayName(Tr::tr("Open CMake Target"));
|
||||
@@ -155,9 +158,16 @@ CMakeOpenTargetFilter::CMakeOpenTargetFilter()
|
||||
setupFilter(this);
|
||||
}
|
||||
|
||||
Core::LocatorMatcherTasks CMakeOpenTargetFilter::matchers()
|
||||
private:
|
||||
LocatorMatcherTasks matchers() final { return cmakeMatchers({}); }
|
||||
};
|
||||
|
||||
// Setup
|
||||
|
||||
void setupCMakeLocatorFilters()
|
||||
{
|
||||
return cmakeMatchers({});
|
||||
static CMakeBuildTargetFilter theCMakeBuildTargetFilter;
|
||||
static CMakeOpenTargetFilter theCMakeOpenTargetFilter;
|
||||
}
|
||||
|
||||
} // namespace CMakeProjectManager::Internal
|
||||
} // CMakeProjectManager::Internal
|
||||
|
||||
@@ -3,26 +3,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <coreplugin/locator/ilocatorfilter.h>
|
||||
|
||||
namespace CMakeProjectManager::Internal {
|
||||
|
||||
class CMakeBuildTargetFilter : Core::ILocatorFilter
|
||||
{
|
||||
public:
|
||||
CMakeBuildTargetFilter();
|
||||
void setupCMakeLocatorFilters();
|
||||
|
||||
private:
|
||||
Core::LocatorMatcherTasks matchers() final;
|
||||
};
|
||||
|
||||
class CMakeOpenTargetFilter : Core::ILocatorFilter
|
||||
{
|
||||
public:
|
||||
CMakeOpenTargetFilter();
|
||||
|
||||
private:
|
||||
Core::LocatorMatcherTasks matchers() final;
|
||||
};
|
||||
|
||||
} // namespace CMakeProjectManager::Internal
|
||||
} // CMakeProjectManager::Internal
|
||||
|
||||
@@ -51,12 +51,6 @@ public:
|
||||
Tr::tr("Build \"%1\""),
|
||||
Action::AlwaysEnabled/*handled manually*/
|
||||
};
|
||||
|
||||
CMakeInstallStepFactory installStepFactory;
|
||||
CMakeBuildTargetFilter cMakeBuildTargetFilter;
|
||||
CMakeOpenTargetFilter cMakeOpenTargetFilter;
|
||||
|
||||
CMakeFormatter cmakeFormatter;
|
||||
};
|
||||
|
||||
class CMakeProjectPlugin final : public ExtensionSystem::IPlugin
|
||||
@@ -77,9 +71,13 @@ class CMakeProjectPlugin final : public ExtensionSystem::IPlugin
|
||||
|
||||
setupCMakeBuildConfiguration();
|
||||
setupCMakeBuildStep();
|
||||
setupCMakeInstallStep();
|
||||
|
||||
setupCMakeEditor();
|
||||
|
||||
setupCMakeLocatorFilters();
|
||||
setupCMakeFormatter();
|
||||
|
||||
d = new CMakeProjectPluginPrivate;
|
||||
|
||||
setupCMakeManager();
|
||||
|
||||
Reference in New Issue
Block a user