MacroExpanders: Remove legacy "Current(Project|Build|Kit)" variables

Should use "CurrentDocument:....." now.

Change-Id: Ie47f0e0f77b506bef6fc7a173aec8cfdcf863e5e
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Eike Ziller
2023-01-04 14:08:13 +01:00
parent 37fafcabb2
commit 23fa784e9c
5 changed files with 1 additions and 98 deletions

View File

@@ -170,16 +170,9 @@ BuildConfiguration::BuildConfiguration(Target *target, Utils::Id id)
expander->registerVariable("buildDir", tr("Build directory"), expander->registerVariable("buildDir", tr("Build directory"),
[this] { return buildDirectory().toUserOutput(); }); [this] { return buildDirectory().toUserOutput(); });
// TODO: Remove "Current" variants in ~4.16.
expander->registerVariable(Constants::VAR_CURRENTBUILD_NAME, tr("Name of current build"),
[this] { return displayName(); }, false);
expander->registerVariable("BuildConfig:Name", tr("Name of the build configuration"), expander->registerVariable("BuildConfig:Name", tr("Name of the build configuration"),
[this] { return displayName(); }); [this] { return displayName(); });
expander->registerPrefix(Constants::VAR_CURRENTBUILD_ENV,
tr("Variables in the current build environment"),
[this](const QString &var) { return environment().expandedValueForKey(var); }, false);
expander->registerPrefix("BuildConfig:Env", expander->registerPrefix("BuildConfig:Env",
tr("Variables in the build configuration's environment"), tr("Variables in the build configuration's environment"),
[this](const QString &var) { return environment().expandedValueForKey(var); }); [this](const QString &var) { return environment().expandedValueForKey(var); });
@@ -602,22 +595,12 @@ FilePath BuildConfiguration::buildDirectoryFromTemplate(const FilePath &projectD
qCDebug(bcLog) << Q_FUNC_INFO << projectDir << mainFilePath << projectName << bcName; qCDebug(bcLog) << Q_FUNC_INFO << projectDir << mainFilePath << projectName << bcName;
// TODO: Remove "Current" variants in ~4.16
exp.registerFileVariables(Constants::VAR_CURRENTPROJECT_PREFIX,
QCoreApplication::translate("ProjectExplorer", "Main file of current project"),
[mainFilePath] { return mainFilePath; }, false);
exp.registerFileVariables("Project", exp.registerFileVariables("Project",
QCoreApplication::translate("ProjectExplorer", "Main file of the project"), QCoreApplication::translate("ProjectExplorer", "Main file of the project"),
[mainFilePath] { return mainFilePath; }); [mainFilePath] { return mainFilePath; });
exp.registerVariable(Constants::VAR_CURRENTPROJECT_NAME,
QCoreApplication::translate("ProjectExplorer", "Name of current project"),
[projectName] { return projectName; }, false);
exp.registerVariable("Project:Name", exp.registerVariable("Project:Name",
QCoreApplication::translate("ProjectExplorer", "Name of the project"), QCoreApplication::translate("ProjectExplorer", "Name of the project"),
[projectName] { return projectName; }); [projectName] { return projectName; });
exp.registerVariable(Constants::VAR_CURRENTBUILD_NAME,
QCoreApplication::translate("ProjectExplorer", "Name of current build"),
[bcName] { return bcName; }, false);
exp.registerVariable("BuildConfig:Name", exp.registerVariable("BuildConfig:Name",
QCoreApplication::translate( QCoreApplication::translate(
"ProjectExplorer", "Name of the project's active build configuration"), "ProjectExplorer", "Name of the project's active build configuration"),

View File

@@ -74,27 +74,14 @@ public:
for (KitAspect *aspect : KitManager::kitAspects()) for (KitAspect *aspect : KitManager::kitAspects())
aspect->addToMacroExpander(kit, &m_macroExpander); aspect->addToMacroExpander(kit, &m_macroExpander);
// TODO: Remove the "Current" variants in ~4.16
m_macroExpander.registerVariable("CurrentKit:Name",
tr("The name of the currently active kit."),
[kit] { return kit->displayName(); },
false);
m_macroExpander.registerVariable("Kit:Name", m_macroExpander.registerVariable("Kit:Name",
tr("The name of the kit."), tr("The name of the kit."),
[kit] { return kit->displayName(); }); [kit] { return kit->displayName(); });
m_macroExpander.registerVariable("CurrentKit:FileSystemName",
tr("The name of the currently active kit in a filesystem-friendly version."),
[kit] { return kit->fileSystemFriendlyName(); },
false);
m_macroExpander.registerVariable("Kit:FileSystemName", m_macroExpander.registerVariable("Kit:FileSystemName",
tr("The name of the kit in a filesystem-friendly version."), tr("The name of the kit in a filesystem-friendly version."),
[kit] { return kit->fileSystemFriendlyName(); }); [kit] { return kit->fileSystemFriendlyName(); });
m_macroExpander.registerVariable("CurrentKit:Id",
tr("The ID of the currently active kit."),
[kit] { return kit->id().toString(); },
false);
m_macroExpander.registerVariable("Kit:Id", m_macroExpander.registerVariable("Kit:Id",
tr("The ID of the kit."), tr("The ID of the kit."),
[kit] { return kit->id().toString(); }); [kit] { return kit->id().toString(); });

View File

@@ -55,6 +55,7 @@
#include "projectexplorericons.h" #include "projectexplorericons.h"
#include "projectexplorersettings.h" #include "projectexplorersettings.h"
#include "projectexplorersettingspage.h" #include "projectexplorersettingspage.h"
#include "projectexplorertr.h"
#include "projectfilewizardextension.h" #include "projectfilewizardextension.h"
#include "projectmanager.h" #include "projectmanager.h"
#include "projectnodes.h" #include "projectnodes.h"
@@ -1943,19 +1944,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
dd->updateWelcomePage(); dd->updateWelcomePage();
// FIXME: These are mostly "legacy"/"convenience" entries, relying on
// the global entry point ProjectExplorer::currentProject(). They should
// not be used in the Run/Build configuration pages.
// TODO: Remove the CurrentProject versions in ~4.16
MacroExpander *expander = Utils::globalMacroExpander(); MacroExpander *expander = Utils::globalMacroExpander();
expander->registerFileVariables(Constants::VAR_CURRENTPROJECT_PREFIX,
tr("Current project's main file."),
[]() -> FilePath {
FilePath projectFilePath;
if (Project *project = ProjectTree::currentProject())
projectFilePath = project->projectFilePath();
return projectFilePath;
}, false);
expander->registerFileVariables("CurrentDocument:Project", expander->registerFileVariables("CurrentDocument:Project",
tr("Main file of the project the current document belongs to."), tr("Main file of the project the current document belongs to."),
[]() -> FilePath { []() -> FilePath {
@@ -1965,12 +1954,6 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
return projectFilePath; return projectFilePath;
}, false); }, false);
expander->registerVariable(Constants::VAR_CURRENTPROJECT_NAME,
tr("The name of the current project."),
[]() -> QString {
Project *project = ProjectTree::currentProject();
return project ? project->displayName() : QString();
}, false);
expander->registerVariable("CurrentDocument:Project:Name", expander->registerVariable("CurrentDocument:Project:Name",
tr("The name of the project the current document belongs to."), tr("The name of the project the current document belongs to."),
[]() -> QString { []() -> QString {
@@ -1978,13 +1961,6 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
return project ? project->displayName() : QString(); return project ? project->displayName() : QString();
}); });
expander->registerPrefix(Constants::VAR_CURRENTBUILD_ENV,
BuildConfiguration::tr("Variables in the current build environment."),
[](const QString &var) {
if (BuildConfiguration *bc = currentBuildConfiguration())
return bc->environment().expandedValueForKey(var);
return QString();
}, false);
const char currentBuildEnvVar[] = "CurrentDocument:Project:BuildConfig:Env"; const char currentBuildEnvVar[] = "CurrentDocument:Project:BuildConfig:Env";
expander->registerPrefix(currentBuildEnvVar, expander->registerPrefix(currentBuildEnvVar,
BuildConfiguration::tr( BuildConfiguration::tr(

View File

@@ -172,12 +172,6 @@ const char ANDROID_ABI_ARM64_V8A[] = "arm64-v8a";
const char ANDROID_ABI_X86[] = "x86"; const char ANDROID_ABI_X86[] = "x86";
const char ANDROID_ABI_X86_64[] = "x86_64"; const char ANDROID_ABI_X86_64[] = "x86_64";
// Variable Names:
const char VAR_CURRENTPROJECT_PREFIX[] = "CurrentProject";
const char VAR_CURRENTPROJECT_NAME[] = "CurrentProject:Name";
const char VAR_CURRENTBUILD_NAME[] = "CurrentBuild:Name";
const char VAR_CURRENTBUILD_ENV[] = "CurrentBuild:Env";
// JsonWizard: // JsonWizard:
const char PAGE_ID_PREFIX[] = "PE.Wizard.Page."; const char PAGE_ID_PREFIX[] = "PE.Wizard.Page.";
const char GENERATOR_ID_PREFIX[] = "PE.Wizard.Generator."; const char GENERATOR_ID_PREFIX[] = "PE.Wizard.Generator.";

View File

@@ -145,46 +145,9 @@ Target::Target(Project *project, Kit *k, _constructor_tag) :
return QString(); return QString();
}); });
// TODO: Remove in ~4.16.
d->m_macroExpander.registerVariable(Constants::VAR_CURRENTPROJECT_NAME,
QCoreApplication::translate("ProjectExplorer", "Name of current project"),
[project] { return project->displayName(); },
false);
d->m_macroExpander.registerVariable("Project:Name", d->m_macroExpander.registerVariable("Project:Name",
QCoreApplication::translate("ProjectExplorer", "Name of current project"), QCoreApplication::translate("ProjectExplorer", "Name of current project"),
[project] { return project->displayName(); }); [project] { return project->displayName(); });
d->m_macroExpander.registerVariable("CurrentRun:Name",
tr("The currently active run configuration's name."),
[this]() -> QString {
if (RunConfiguration * const rc = activeRunConfiguration())
return rc->displayName();
return QString();
}, false);
d->m_macroExpander.registerFileVariables("CurrentRun:Executable",
tr("The currently active run configuration's executable (if applicable)."),
[this]() -> FilePath {
if (RunConfiguration * const rc = activeRunConfiguration())
return rc->commandLine().executable();
return FilePath();
}, false);
d->m_macroExpander.registerPrefix("CurrentRun:Env", tr("Variables in the current run environment."),
[this](const QString &var) {
if (RunConfiguration * const rc = activeRunConfiguration()) {
if (const auto envAspect = rc->aspect<EnvironmentAspect>())
return envAspect->environment().expandedValueForKey(var);
}
return QString();
}, false);
d->m_macroExpander.registerVariable("CurrentRun:WorkingDir",
tr("The currently active run configuration's working directory."),
[this] {
if (RunConfiguration * const rc = activeRunConfiguration()) {
if (const auto wdAspect = rc->aspect<WorkingDirectoryAspect>())
return wdAspect->workingDirectory().toString();
}
return QString();
}, false);
} }
Target::~Target() Target::~Target()