Adjust ProjectMacroExpander to not use resolveMacro

This can rely on subexpander and the global expander now.

Change-Id: I994c7f930322f45cdb57799b0d03ab822cd73bd3
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
hjk
2014-10-22 17:09:58 +02:00
parent 84dd24e243
commit eb64f214cf
2 changed files with 14 additions and 66 deletions

View File

@@ -30,66 +30,22 @@
#include "projectmacroexpander.h" #include "projectmacroexpander.h"
#include "kit.h" #include "kit.h"
#include "kitinformation.h"
#include "projectexplorerconstants.h" #include "projectexplorerconstants.h"
#include <utils/macroexpander.h> namespace ProjectExplorer {
#include <ssh/sshconnection.h>
using namespace ProjectExplorer;
ProjectMacroExpander::ProjectMacroExpander(const QString &projectName, ProjectMacroExpander::ProjectMacroExpander(const QString &projectName,
const Kit *k, const QString &bcName) const Kit *kit, const QString &bcName)
: m_projectName(projectName), m_kit(k), m_bcName(bcName)
{ }
bool ProjectMacroExpander::resolveMacro(const QString &name, QString *ret) const
{ {
QString result; registerVariable(Constants::VAR_CURRENTPROJECT_NAME,
bool found = false; QCoreApplication::translate("ProjectExplorer", "Name of current project"),
if (name == QLatin1String(Constants::VAR_CURRENTPROJECT_NAME)) { [projectName] { return projectName; });
if (!m_projectName.isEmpty()) {
result = m_projectName; registerVariable(Constants::VAR_CURRENTBUILD_NAME,
found = true; QCoreApplication::translate("ProjectExplorer", "Name of current build"),
} [bcName] { return bcName; });
} else if (m_kit && name == QLatin1String(Constants::VAR_CURRENTKIT_NAME)) {
result = m_kit->displayName(); registerSubProvider([kit] { return kit->macroExpander(); });
found = true;
} else if (m_kit && name == QLatin1String(Constants::VAR_CURRENTKIT_FILESYSTEMNAME)) {
result = m_kit->fileSystemFriendlyName();
found = true;
} else if (m_kit && name == QLatin1String(Constants::VAR_CURRENTKIT_ID)) {
result = m_kit->id().toString();
found = true;
} else if (name == QLatin1String(Constants::VAR_CURRENTBUILD_NAME)) {
result = m_bcName;
found = true;
} else if (name == QLatin1String(Constants::VAR_CURRENTDEVICE_HOSTADDRESS)) {
const IDevice::ConstPtr device = DeviceKitInformation::device(m_kit);
if (device) {
result = device->sshParameters().host;
found = true;
}
} else if (name == QLatin1String(Constants::VAR_CURRENTDEVICE_SSHPORT)) {
const IDevice::ConstPtr device = DeviceKitInformation::device(m_kit);
if (device) {
result = QString::number(device->sshParameters().port);
found = true;
}
} else if (name == QLatin1String(Constants::VAR_CURRENTDEVICE_USERNAME)) {
const IDevice::ConstPtr device = DeviceKitInformation::device(m_kit);
if (device) {
result = device->sshParameters().userName;
found = true;
}
} else if (name == QLatin1String(Constants::VAR_CURRENTDEVICE_PRIVATEKEYFILE)) {
const IDevice::ConstPtr device = DeviceKitInformation::device(m_kit);
if (device) {
result = device->sshParameters().privateKeyFile;
found = true;
}
}
if (ret)
*ret = result;
return found;
} }
} // namespace ProjectExplorer

View File

@@ -33,7 +33,6 @@
#include "projectexplorer_export.h" #include "projectexplorer_export.h"
#include <utils/macroexpander.h> #include <utils/macroexpander.h>
#include <QFileInfo>
namespace ProjectExplorer { namespace ProjectExplorer {
class Kit; class Kit;
@@ -41,14 +40,7 @@ class Kit;
class PROJECTEXPLORER_EXPORT ProjectMacroExpander : public Utils::MacroExpander class PROJECTEXPLORER_EXPORT ProjectMacroExpander : public Utils::MacroExpander
{ {
public: public:
ProjectMacroExpander(const QString &projectName, const Kit *k, const QString &bcName); ProjectMacroExpander(const QString &projectName, const Kit *kit, const QString &bcName);
bool resolveMacro(const QString &name, QString *ret) const;
private:
QFileInfo m_projectFile;
QString m_projectName;
const Kit *m_kit;
QString m_bcName;
}; };
} // namespace ProjectExplorer } // namespace ProjectExplorer