Commit e279c7e0 authored by hjk's avatar hjk

MacroExpander: Allow registering local expansions

This allows a MacroExpander also to describe an expansion it can
do which was restricted to the global VariableManager only.

The global is now just a thin (unneeded) wrapper about new "standard"
functionality.

Change-Id: Ida7ca70cf3d319eae4220ea8d12f3dd1c0d4042c
Reviewed-by: default avatarTobias Hunger <tobias.hunger@theqtcompany.com>
parent e43af30f
This diff is collapsed.
......@@ -37,17 +37,44 @@
namespace Utils {
namespace Internal { class MacroExpanderPrivate; }
class QTCREATOR_UTILS_EXPORT MacroExpander : public AbstractMacroExpander
{
public:
typedef std::function<bool(const QString &name, QString *ret)> Resolver;
explicit MacroExpander(const Resolver &resolver);
explicit MacroExpander();
~MacroExpander();
bool resolveMacro(const QString &name, QString *ret);
QString value(const QByteArray &variable, bool *found = 0);
QString expandedString(const QString &stringWithVariables);
typedef std::function<QString(QString)> PrefixFunction;
typedef std::function<QString()> StringFunction;
typedef std::function<int()> IntFunction;
void registerPrefix(const QByteArray &prefix,
const QString &description, const PrefixFunction &value);
void registerVariable(const QByteArray &variable,
const QString &description, const StringFunction &value);
void registerIntVariable(const QByteArray &variable,
const QString &description, const IntFunction &value);
void registerFileVariables(const QByteArray &prefix,
const QString &heading, const StringFunction &value);
QList<QByteArray> variables();
QString variableDescription(const QByteArray &variable);
private:
Resolver m_resolver;
MacroExpander(const MacroExpander &) Q_DECL_EQ_DELETE;
void operator=(const MacroExpander &) Q_DECL_EQ_DELETE;
Internal::MacroExpanderPrivate *d;
};
} // namespace Utils
......
......@@ -595,5 +595,5 @@ void ExternalToolConfig::addCategory()
void ExternalToolConfig::updateEffectiveArguments()
{
ui->arguments->setToolTip(Utils::QtcProcess::expandMacros(ui->arguments->text(),
Core::VariableManager::macroExpander()));
globalMacroExpander()));
}
......@@ -483,20 +483,20 @@ void EditorManagerPrivate::init()
d->m_openEditorsFactory = new OpenEditorsViewFactory();
ExtensionSystem::PluginManager::addObject(d->m_openEditorsFactory);
VariableManager::registerFileVariables(kCurrentDocumentPrefix, tr("Current document"),
globalMacroExpander()->registerFileVariables(kCurrentDocumentPrefix, tr("Current document"),
[]() -> QString {
IDocument *document = EditorManager::currentDocument();
return document ? document->filePath() : QString();
});
VariableManager::registerIntVariable(kCurrentDocumentXPos,
globalMacroExpander()->registerIntVariable(kCurrentDocumentXPos,
tr("X-coordinate of the current editor's upper left corner, relative to screen."),
[]() -> int {
IEditor *editor = EditorManager::currentEditor();
return editor ? editor->widget()->mapToGlobal(QPoint(0, 0)).x() : 0;
});
VariableManager::registerIntVariable(kCurrentDocumentYPos,
globalMacroExpander()->registerIntVariable(kCurrentDocumentYPos,
tr("Y-coordinate of the current editor's upper left corner, relative to screen."),
[]() -> int {
IEditor *editor = EditorManager::currentEditor();
......
......@@ -550,10 +550,12 @@ bool ExternalToolRunner::resolve()
m_resolvedExecutable.clear();
m_resolvedArguments.clear();
m_resolvedWorkingDirectory.clear();
Utils::MacroExpander *expander = globalMacroExpander();
{ // executable
QStringList expandedExecutables; /* for error message */
foreach (const QString &executable, m_tool->executables()) {
QString expanded = Core::VariableManager::expandedString(executable);
QString expanded = expander->expandedString(executable);
expandedExecutables << expanded;
m_resolvedExecutable =
Utils::Environment::systemEnvironment().searchInPath(expanded);
......@@ -574,14 +576,13 @@ bool ExternalToolRunner::resolve()
}
}
{ // arguments
m_resolvedArguments = Utils::QtcProcess::expandMacros(m_tool->arguments(),
Core::VariableManager::macroExpander());
m_resolvedArguments = Utils::QtcProcess::expandMacros(m_tool->arguments(), expander);
}
{ // input
m_resolvedInput = Core::VariableManager::expandedString(m_tool->input());
m_resolvedInput = expander->expandedString(m_tool->input());
}
{ // working directory
m_resolvedWorkingDirectory = Core::VariableManager::expandedString(m_tool->workingDirectory());
m_resolvedWorkingDirectory = expander->expandedString(m_tool->workingDirectory());
}
return true;
}
......
......@@ -90,7 +90,7 @@ QString JsExpander::evaluate(const QString &expression, QString *errorMessage)
JsExpander::JsExpander()
{
d = new Internal::JsExpanderPrivate;
VariableManager::registerPrefix("JS",
globalMacroExpander()->registerPrefix("JS",
QCoreApplication::translate("Core::JsExpander",
"Evaluate simple Javascript statements.\n"
"The statements may not contain '{' nor '}' characters."),
......
......@@ -91,9 +91,9 @@ void ExecuteFilter::accept(LocatorFilterEntry selection) const
p->m_commandHistory.prepend(value);
bool found;
QString workingDirectory = Core::VariableManager::value("CurrentDocument:Path", &found);
QString workingDirectory = globalMacroExpander()->value("CurrentDocument:Path", &found);
if (!found || workingDirectory.isEmpty())
workingDirectory = Core::VariableManager::value("CurrentProject:Path", &found);
workingDirectory = globalMacroExpander()->value("CurrentProject:Path", &found);
ExecuteData d;
d.workingDirectory = workingDirectory;
......
......@@ -120,8 +120,7 @@ MainWindow::MainWindow() :
m_editorManager(0),
m_externalToolManager(0),
m_progressManager(new ProgressManagerPrivate),
m_variableManager(new VariableManager),
m_jsExpander(new JsExpander), // must be initialized after the VariableManager
m_jsExpander(new JsExpander),
m_vcsManager(new VcsManager),
m_statusBarManager(0),
m_modeManager(0),
......@@ -305,8 +304,6 @@ MainWindow::~MainWindow()
delete m_helpManager;
m_helpManager = 0;
delete m_variableManager;
m_variableManager = 0;
delete m_jsExpander;
m_jsExpander = 0;
}
......
......@@ -65,7 +65,6 @@ class ProgressManager;
class NavigationWidget;
class RightPaneWidget;
class SettingsDatabase;
class VariableManager;
class VcsManager;
namespace Internal {
......@@ -174,7 +173,6 @@ private:
ExternalToolManager *m_externalToolManager;
MessageManager *m_messageManager;
ProgressManagerPrivate *m_progressManager;
VariableManager *m_variableManager;
JsExpander *m_jsExpander;
VcsManager *m_vcsManager;
StatusBarManager *m_statusBarManager;
......
......@@ -67,7 +67,7 @@ public:
m_variableList = new QListWidget(q);
m_variableList->setAttribute(Qt::WA_MacSmallSize);
m_variableList->setAttribute(Qt::WA_MacShowFocusRect, false);
foreach (const QByteArray &variable, VariableManager::variables())
foreach (const QByteArray &variable, globalMacroExpander()->variables())
m_variableList->addItem(QString::fromLatin1(variable));
m_variableDescription = new QLabel(q);
......@@ -209,8 +209,8 @@ void VariableChooserPrivate::updateDescription(const QString &variable)
if (variable.isNull())
m_variableDescription->setText(m_defaultDescription);
else
m_variableDescription->setText(VariableManager::variableDescription(variable.toUtf8())
+ QLatin1String("<p>") + tr("Current Value: %1").arg(VariableManager::value(variable.toUtf8())));
m_variableDescription->setText(globalMacroExpander()->variableDescription(variable.toUtf8())
+ QLatin1String("<p>") + tr("Current Value: %1").arg(globalMacroExpander()->value(variable.toUtf8())));
}
/*!
......
This diff is collapsed.
......@@ -33,50 +33,11 @@
#include "core_global.h"
#include <functional>
#include <QFileInfo>
#include <QString>
namespace Utils { class AbstractMacroExpander; }
#include <utils/macroexpander.h>
namespace Core {
namespace Internal { class MainWindow; }
class CORE_EXPORT VariableManager
{
public:
static QString value(const QByteArray &variable, bool *found = 0);
static QString expandedString(const QString &stringWithVariables);
static Utils::AbstractMacroExpander *macroExpander();
typedef std::function<QString(QString)> PrefixFunction;
typedef std::function<QString()> StringFunction;
typedef std::function<int()> IntFunction;
static void registerPrefix(const QByteArray &prefix,
const QString &description, const PrefixFunction &value);
static void registerVariable(const QByteArray &variable,
const QString &description, const StringFunction &value);
static void registerIntVariable(const QByteArray &variable,
const QString &description, const IntFunction &value);
static void registerFileVariables(const QByteArray &prefix,
const QString &heading, const StringFunction &value);
static QList<QByteArray> variables();
static QString variableDescription(const QByteArray &variable);
private:
VariableManager();
~VariableManager();
friend class Core::Internal::MainWindow;
};
CORE_EXPORT Utils::MacroExpander *globalMacroExpander();
} // namespace Core
......
......@@ -191,12 +191,13 @@ bool CppToolsPlugin::initialize(const QStringList &arguments, QString *error)
mcpptools->addAction(command);
connect(openInNextSplitAction, SIGNAL(triggered()), this, SLOT(switchHeaderSourceInNextSplit()));
Core::VariableManager::registerVariable("Cpp:LicenseTemplate",
tr("The license template."),
[this]() { return CppToolsPlugin::licenseTemplate(); });
Core::VariableManager::registerFileVariables("Cpp:LicenseTemplatePath",
tr("The configured path to the license template"),
[this]() { return CppToolsPlugin::licenseTemplatePath().toString(); });
Utils::MacroExpander *expander = globalMacroExpander();
expander->registerVariable("Cpp:LicenseTemplate",
tr("The license template."),
[this]() { return CppToolsPlugin::licenseTemplate(); });
expander->registerFileVariables("Cpp:LicenseTemplatePath",
tr("The configured path to the license template"),
[this]() { return CppToolsPlugin::licenseTemplatePath().toString(); });
return true;
}
......
......@@ -178,7 +178,7 @@ public:
connect(action(IntelFlavor), SIGNAL(valueChanged(QVariant)),
SLOT(reloadDisassembly()));
VariableManager::registerFileVariables(PrefixDebugExecutable,
globalMacroExpander()->registerFileVariables(PrefixDebugExecutable,
tr("Debugged executable"),
[this]() { return m_startParameters.executable; });
}
......@@ -1835,7 +1835,7 @@ void DebuggerEngine::validateExecutable(DebuggerStartParameters *sp)
SourcePathRegExpMap globalRegExpSourceMap;
globalRegExpSourceMap.reserve(options->sourcePathRegExpMap.size());
foreach (auto entry, options->sourcePathRegExpMap) {
const QString expanded = VariableManager::expandedString(entry.second);
const QString expanded = globalMacroExpander()->expandedString(entry.second);
if (!expanded.isEmpty())
globalRegExpSourceMap.push_back(qMakePair(entry.first, expanded));
}
......
......@@ -37,6 +37,7 @@
#include <projectexplorer/abi.h>
#include <utils/fileutils.h>
#include <utils/macroexpander.h>
#include <QList>
#include <QVariant>
......
......@@ -302,18 +302,15 @@ KitConfigWidget *DebuggerKitInformation::createConfigWidget(Kit *k) const
return new Internal::DebuggerKitConfigWidget(k, this);
}
AbstractMacroExpander *DebuggerKitInformation::createMacroExpander(const Kit *k) const
bool DebuggerKitInformation::resolveMacro(const Kit *kit, const QString &name, QString *ret) const
{
return new MacroExpander([k, this](const QString &name, QString *ret) -> bool {
const DebuggerItem *item = DebuggerKitInformation::debugger(k);
if (name == QLatin1String("Debugger:engineType")) {
*ret = item ? item->engineTypeName() : tr("none");
return true;
}
const DebuggerItem *item = debugger(kit);
if (name == QLatin1String("Debugger:engineType")) {
*ret = item ? item->engineTypeName() : tr("none");
return true;
}
return false;
});
return false;
}
KitInformation::ItemList DebuggerKitInformation::toUserOutput(const Kit *k) const
......
......@@ -63,7 +63,7 @@ public:
static bool isValidDebugger(const ProjectExplorer::Kit *k);
ProjectExplorer::KitConfigWidget *createConfigWidget(ProjectExplorer::Kit *k) const;
Utils::AbstractMacroExpander *createMacroExpander(const ProjectExplorer::Kit *k) const;
bool resolveMacro(const ProjectExplorer::Kit *kit, const QString &name, QString *ret) const;
ItemList toUserOutput(const ProjectExplorer::Kit *k) const;
......
......@@ -3334,7 +3334,7 @@ bool boolSetting(int code)
QString stringSetting(int code)
{
QString raw = theDebuggerCore->m_debuggerSettings->item(code)->value().toString();
return VariableManager::expandedString(raw);
return globalMacroExpander()->expandedString(raw);
}
QStringList stringListSetting(int code)
......
......@@ -4402,7 +4402,7 @@ void GdbEngine::abortDebugger()
void GdbEngine::resetInferior()
{
if (!startParameters().commandsForReset.isEmpty()) {
QByteArray substitutedCommands = VariableManager::expandedString(
QByteArray substitutedCommands = globalMacroExpander()->expandedString(
QString::fromLatin1(startParameters().commandsForReset)).toLatin1();
foreach (QByteArray command, substitutedCommands.split('\n')) {
command = command.trimmed();
......@@ -4453,7 +4453,7 @@ void GdbEngine::handleInferiorPrepared()
QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
if (!sp.commandsAfterConnect.isEmpty()) {
QByteArray substitutedCommands = VariableManager::expandedString(QString::fromLatin1(sp.commandsAfterConnect)).toLatin1();
QByteArray substitutedCommands = globalMacroExpander()->expandedString(QString::fromLatin1(sp.commandsAfterConnect)).toLatin1();
foreach (QByteArray command, substitutedCommands.split('\n')) {
postCommand(command);
}
......
......@@ -59,7 +59,7 @@ bool JsonWizardExpander::resolveMacro(const QString &name, QString *ret)
return true;
}
return Core::VariableManager::macroExpander()->resolveMacro(name, ret);
return Core::globalMacroExpander()->resolveMacro(name, ret);
}
} // namespace Internal
......
......@@ -36,8 +36,8 @@
#include <utils/algorithm.h>
#include <utils/fileutils.h>
#include <utils/macroexpander.h>
#include <utils/qtcassert.h>
#include <utils/stringutils.h>
#include <QApplication>
#include <QFileInfo>
......@@ -66,29 +66,24 @@ namespace ProjectExplorer {
// KitMacroExpander:
// --------------------------------------------------------------------
class KitMacroExpander : public AbstractMacroExpander
class KitMacroExpander : public MacroExpander
{
public:
KitMacroExpander(const QList<AbstractMacroExpander *> &children) :
m_childExpanders(children)
{ }
~KitMacroExpander() { qDeleteAll(m_childExpanders); }
KitMacroExpander(Kit *kit) : m_kit(kit) {}
bool resolveMacro(const QString &name, QString *ret);
bool resolveMacro(const QString &name, QString *ret)
{
foreach (KitInformation *ki, KitManager::kitInformation())
if (ki->resolveMacro(m_kit, name, ret))
return true;
return false;
}
private:
QList<AbstractMacroExpander *> m_childExpanders;
Kit *m_kit;
};
bool KitMacroExpander::resolveMacro(const QString &name, QString *ret)
{
foreach (AbstractMacroExpander *expander, m_childExpanders) {
if (expander->resolveMacro(name, ret))
return true;
}
return false;
}
// -------------------------------------------------------------------------
// KitPrivate
// -------------------------------------------------------------------------
......@@ -107,27 +102,15 @@ public:
m_hasWarning(false),
m_hasValidityInfo(false),
m_mustNotify(false),
m_macroExpander(0)
m_macroExpander(k)
{
if (!id.isValid())
m_id = Id::fromString(QUuid::createUuid().toString());
m_unexpandedDisplayName = QCoreApplication::translate("ProjectExplorer::Kit", "Unnamed");
m_iconPath = FileName::fromLatin1(":///DESKTOP///");
QList<AbstractMacroExpander *> expanders;
foreach (const KitInformation *ki, KitManager::kitInformation()) {
AbstractMacroExpander *tmp = ki->createMacroExpander(k);
if (tmp)
expanders.append(tmp);
}
m_macroExpander = new KitMacroExpander(expanders);
}
~KitPrivate()
{ delete m_macroExpander; }
QString m_unexpandedDisplayName;
QString m_fileSystemFriendlyName;
QString m_autoDetectionSource;
......@@ -145,7 +128,7 @@ public:
QHash<Core::Id, QVariant> m_data;
QSet<Core::Id> m_sticky;
QSet<Core::Id> m_mutable;
AbstractMacroExpander *m_macroExpander;
KitMacroExpander m_macroExpander;
};
} // namespace Internal
......@@ -317,7 +300,7 @@ QString Kit::unexpandedDisplayName() const
QString Kit::displayName() const
{
return Utils::expandMacros(unexpandedDisplayName(), macroExpander());
return Utils::expandMacros(d->m_unexpandedDisplayName, &d->m_macroExpander);
}
static QString candidateName(const QString &name, const QString &postfix)
......@@ -682,8 +665,7 @@ bool Kit::hasFeatures(const FeatureSet &features) const
AbstractMacroExpander *Kit::macroExpander() const
{
QTC_CHECK(d->m_macroExpander);
return d->m_macroExpander;
return &d->m_macroExpander;
}
void Kit::kitUpdated()
......
......@@ -129,9 +129,8 @@ public:
Core::FeatureSet availableFeatures() const;
bool hasFeatures(const Core::FeatureSet &features) const;
Utils::AbstractMacroExpander *macroExpander() const;
private:
Utils::AbstractMacroExpander *macroExpander() const;
void setSdkProvided(bool sdkProvided);
~Kit();
......
......@@ -589,6 +589,14 @@ Core::FeatureSet KitInformation::availableFeatures(const Kit *k) const
return Core::FeatureSet();
}
bool KitInformation::resolveMacro(const Kit *kit, const QString &name, QString *ret) const
{
Q_UNUSED(kit);
Q_UNUSED(name);
Q_UNUSED(ret);
return false;
}
void KitInformation::notifyAboutUpdate(Kit *k)
{
if (k)
......
......@@ -99,8 +99,7 @@ public:
virtual QString displayNameForPlatform(const Kit *k, const QString &platform) const;
virtual Core::FeatureSet availableFeatures(const Kit *k) const;
virtual Utils::AbstractMacroExpander *createMacroExpander(const Kit *k) const
{ Q_UNUSED(k); return 0; }
virtual bool resolveMacro(const Kit *kit, const QString &name, QString *ret) const;
protected:
void setId(Core::Id id) { m_id = id; }
......
......@@ -40,7 +40,6 @@
#include <QDir>
namespace ProjectExplorer {
namespace Internal {
class FallBackMacroExpander : public Utils::AbstractMacroExpander
......@@ -59,7 +58,7 @@ bool FallBackMacroExpander::resolveMacro(const QString &name, QString *ret)
return true;
}
bool found;
*ret = Core::VariableManager::value(name.toUtf8(), &found);
*ret = Core::globalMacroExpander()->value(name.toUtf8(), &found);
return found;
}
} // namespace Internal
......
......@@ -82,7 +82,7 @@ bool ProcessStep::init()
if (!bc)
bc = target()->activeBuildConfiguration();
ProcessParameters *pp = processParameters();
pp->setMacroExpander(bc ? bc->macroExpander() : Core::VariableManager::macroExpander());
pp->setMacroExpander(bc ? bc->macroExpander() : Core::globalMacroExpander());
pp->setEnvironment(bc ? bc->environment() : Utils::Environment::systemEnvironment());
pp->setWorkingDirectory(workingDirectory());
pp->setCommand(m_command);
......@@ -272,7 +272,7 @@ void ProcessStepConfigWidget::updateDetails()
BuildConfiguration *bc = m_step->buildConfiguration();
if (!bc) // iff the step is actually in the deploy list
bc = m_step->target()->activeBuildConfiguration();
param.setMacroExpander(bc ? bc->macroExpander() : Core::VariableManager::macroExpander());
param.setMacroExpander(bc ? bc->macroExpander() : Core::globalMacroExpander());
param.setEnvironment(bc ? bc->environment() : Utils::Environment::systemEnvironment());
param.setWorkingDirectory(m_step->workingDirectory());
......
......@@ -1135,7 +1135,8 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
updateWelcomePage();
VariableManager::registerFileVariables(Constants::VAR_CURRENTPROJECT_PREFIX,
Utils::MacroExpander *expander = globalMacroExpander();
expander->registerFileVariables(Constants::VAR_CURRENTPROJECT_PREFIX,
tr("Current project's main file"),
[this]() -> QString {
QString projectFilePath;
......@@ -1145,51 +1146,51 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
return projectFilePath;
});
VariableManager::registerVariable(Constants::VAR_CURRENTPROJECT_BUILDPATH,
expander->registerVariable(Constants::VAR_CURRENTPROJECT_BUILDPATH,
tr("Full build path of the current project's active build configuration."),
[]() -> QString {
BuildConfiguration *bc = activeBuildConfiguration();
return bc ? bc->buildDirectory().toUserOutput() : QString();
});
VariableManager::registerVariable(Constants::VAR_CURRENTPROJECT_NAME,
expander->registerVariable(Constants::VAR_CURRENTPROJECT_NAME,
tr("The current project's name."),
[]() { return variableValue(Constants::VAR_CURRENTPROJECT_NAME); });
VariableManager::registerVariable(Constants::VAR_CURRENTKIT_NAME,
expander->registerVariable(Constants::VAR_CURRENTKIT_NAME,
tr("The currently active kit's name."),
[]() { return variableValue(Constants::VAR_CURRENTKIT_NAME); });
VariableManager::registerVariable(Constants::VAR_CURRENTKIT_FILESYSTEMNAME,
expander->registerVariable(Constants::VAR_CURRENTKIT_FILESYSTEMNAME,
tr("The currently active kit's name in a filesystem friendly version."),
[]() { return variableValue(Constants::VAR_CURRENTKIT_FILESYSTEMNAME); });
VariableManager::registerVariable(Constants::VAR_CURRENTKIT_ID,
expander->registerVariable(Constants::VAR_CURRENTKIT_ID,
tr("The currently active kit's id."),
[]() { return variableValue(Constants::VAR_CURRENTKIT_ID); });
VariableManager::registerVariable(Constants::VAR_CURRENTDEVICE_HOSTADDRESS,
expander->registerVariable(Constants::VAR_CURRENTDEVICE_HOSTADDRESS,
tr("The host address of the device in the currently active kit."),
[]() { return variableValue(Constants::VAR_CURRENTDEVICE_HOSTADDRESS); });
VariableManager::registerVariable(Constants::VAR_CURRENTDEVICE_SSHPORT,
expander->registerVariable(Constants::VAR_CURRENTDEVICE_SSHPORT,
tr("The SSH port of the device in the currently active kit."),
[]() { return variableValue(Constants::VAR_CURRENTDEVICE_SSHPORT); });
VariableManager::registerVariable(Constants::VAR_CURRENTDEVICE_USERNAME,
expander->registerVariable(Constants::VAR_CURRENTDEVICE_USERNAME,
tr("The username with which to log into the device in the currently active kit."),
[]() { return variableValue(Constants::VAR_CURRENTDEVICE_USERNAME); });
VariableManager::registerVariable(Constants::VAR_CURRENTDEVICE_PRIVATEKEYFILE,
expander->registerVariable(Constants::VAR_CURRENTDEVICE_PRIVATEKEYFILE,
tr("The private key file with which to authenticate when logging into the device "
"in the currently active kit."),
[]() { return variableValue(Constants::VAR_CURRENTDEVICE_PRIVATEKEYFILE); });
VariableManager::registerVariable(Constants::VAR_CURRENTBUILD_NAME,
expander->registerVariable(Constants::VAR_CURRENTBUILD_NAME,
tr("The currently active build configuration's name."),
[]() { return variableValue(Constants::VAR_CURRENTBUILD_NAME); });
VariableManager::registerVariable(Constants::VAR_CURRENTBUILD_TYPE,
expander->registerVariable(Constants::VAR_CURRENTBUILD_TYPE,
tr("The currently active build configuration's type."),
[&]() -> QString {
if (BuildConfiguration *bc = activeBuildConfiguration()) {
......@@ -1202,11 +1203,11 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
return tr("unknown");
});
VariableManager::registerFileVariables(Constants::VAR_CURRENTSESSION_PREFIX,
expander->registerFileVariables(Constants::VAR_CURRENTSESSION_PREFIX,
tr("File where current session is saved."),
[]() { return SessionManager::sessionNameToFileName(SessionManager::activeSession()).toString(); });
VariableManager::registerVariable(Constants::VAR_CURRENTSESSION_NAME,
expander->registerVariable(Constants::VAR_CURRENTSESSION_NAME,
tr("Name of current session."),
[]() { return SessionManager::activeSession(); });
......
......@@ -99,7 +99,7 @@ bool ProjectMacroExpander::resolveMacro(const QString &name, QString *ret)
{
bool found = resolveProjectMacro(name, ret);
if (!found) {
QString result = Core::VariableManager::value(name.toUtf8(), &found);
QString result = Core::globalMacroExpander()->value(name.toUtf8(), &found);
if (ret)
*ret = result;
}
......
......@@ -192,9 +192,10 @@ BaseQtVersion::BaseQtVersion(const BaseQtVersion &other) :
m_linguistCommand(other.m_linguistCommand),
m_qmlsceneCommand(other.m_qmlsceneCommand),
m_qmlviewerCommand(other.m_qmlviewerCommand),
m_qtAbis(other.m_qtAbis),
m_expander(0)
{ }
m_qtAbis(other.m_qtAbis)
{
setupExpander();
}
BaseQtVersion::BaseQtVersion()
: m_id(-1), m_isAutodetected(false),
......@@ -228,12 +229,31 @@ void BaseQtVersion::ctor(const FileName &qmakePath)
m_hasQtAbis = false;
m_qtVersionString.clear();
m_sourcePath.clear();
m_expander = 0;
setupExpander();
}
void BaseQtVersion::setupExpander()
{
m_expander.registerVariable("Qt:version",
QCoreApplication::translate("QtSupport::QtKitInformation", "The version string of the current Qt version."),