MacroExpander: Fall back to global expander

... and use that all over the place.

Change-Id: Ie6e0ed0f0d9eaba9b4466761e6b455f33a905086
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
hjk
2014-10-15 14:45:31 +02:00
parent 89602419c4
commit ef563d8085
30 changed files with 154 additions and 155 deletions

View File

@@ -221,9 +221,17 @@ QString MacroExpander::value(const QByteArray &variable, bool *found)
* \sa MacroExpander * \sa MacroExpander
* \sa macroExpander() * \sa macroExpander()
*/ */
QString MacroExpander::expandedString(const QString &stringWithVariables) QString MacroExpander::expand(const QString &stringWithVariables)
{ {
return Utils::expandMacros(stringWithVariables, this); QString res = Utils::expandMacros(stringWithVariables, this);
if (this != globalMacroExpander())
res = Utils::expandMacros(res, this);
return res;
}
QByteArray MacroExpander::expand(const QByteArray &stringWithVariables)
{
return expand(QString::fromLatin1(stringWithVariables)).toLatin1();
} }
/*! /*!

View File

@@ -49,7 +49,8 @@ public:
QString value(const QByteArray &variable, bool *found = 0); QString value(const QByteArray &variable, bool *found = 0);
QString expandedString(const QString &stringWithVariables); QString expand(const QString &stringWithVariables);
QByteArray expand(const QByteArray &stringWithVariables);
typedef std::function<QString(QString)> PrefixFunction; typedef std::function<QString(QString)> PrefixFunction;
typedef std::function<QString()> StringFunction; typedef std::function<QString()> StringFunction;

View File

@@ -186,7 +186,7 @@ QString CMakeProject::shadowBuildDirectory(const QString &projectFilePath, const
const QString projectName = QFileInfo(info.absolutePath()).fileName(); const QString projectName = QFileInfo(info.absolutePath()).fileName();
ProjectExplorer::ProjectMacroExpander expander(projectFilePath, projectName, k, bcName); ProjectExplorer::ProjectMacroExpander expander(projectFilePath, projectName, k, bcName);
QDir projectDir = QDir(projectDirectory(Utils::FileName::fromString(projectFilePath)).toString()); QDir projectDir = QDir(projectDirectory(Utils::FileName::fromString(projectFilePath)).toString());
QString buildPath = Utils::expandMacros(Core::DocumentManager::buildDirectory(), &expander); QString buildPath = expander.expand(Core::DocumentManager::buildDirectory());
return QDir::cleanPath(projectDir.absoluteFilePath(buildPath)); return QDir::cleanPath(projectDir.absoluteFilePath(buildPath));
} }

View File

@@ -123,7 +123,7 @@ QString CMakeRunConfiguration::workingDirectory() const
EnvironmentAspect *aspect = extraAspect<EnvironmentAspect>(); EnvironmentAspect *aspect = extraAspect<EnvironmentAspect>();
QTC_ASSERT(aspect, return QString()); QTC_ASSERT(aspect, return QString());
return QDir::cleanPath(aspect->environment().expandVariables( return QDir::cleanPath(aspect->environment().expandVariables(
Utils::expandMacros(baseWorkingDirectory(), macroExpander()))); macroExpander()->expand(baseWorkingDirectory())));
} }
QString CMakeRunConfiguration::baseWorkingDirectory() const QString CMakeRunConfiguration::baseWorkingDirectory() const

View File

@@ -556,8 +556,8 @@ bool ExternalToolRunner::resolve()
{ // executable { // executable
QStringList expandedExecutables; /* for error message */ QStringList expandedExecutables; /* for error message */
foreach (const QString &executable, m_tool->executables()) { foreach (const QString &executable, m_tool->executables()) {
QString expanded = expander->expandedString(executable); QString expanded = expander->expand(executable);
expandedExecutables << expanded; expandedExecutables.append(expanded);
m_resolvedExecutable = Environment::systemEnvironment().searchInPath(expanded); m_resolvedExecutable = Environment::systemEnvironment().searchInPath(expanded);
if (!m_resolvedExecutable.isEmpty()) if (!m_resolvedExecutable.isEmpty())
break; break;
@@ -575,15 +575,11 @@ bool ExternalToolRunner::resolve()
return false; return false;
} }
} }
{ // arguments
m_resolvedArguments = QtcProcess::expandMacros(m_tool->arguments(), expander); m_resolvedArguments = QtcProcess::expandMacros(m_tool->arguments(), expander);
} m_resolvedInput = expander->expand(m_tool->input());
{ // input m_resolvedWorkingDirectory = expander->expand(m_tool->workingDirectory());
m_resolvedInput = expander->expandedString(m_tool->input());
}
{ // working directory
m_resolvedWorkingDirectory = expander->expandedString(m_tool->workingDirectory());
}
return true; return true;
} }

View File

@@ -1836,7 +1836,7 @@ void DebuggerEngine::validateExecutable(DebuggerStartParameters *sp)
SourcePathRegExpMap globalRegExpSourceMap; SourcePathRegExpMap globalRegExpSourceMap;
globalRegExpSourceMap.reserve(options->sourcePathRegExpMap.size()); globalRegExpSourceMap.reserve(options->sourcePathRegExpMap.size());
foreach (auto entry, options->sourcePathRegExpMap) { foreach (auto entry, options->sourcePathRegExpMap) {
const QString expanded = Utils::globalMacroExpander()->expandedString(entry.second); const QString expanded = Utils::globalMacroExpander()->expand(entry.second);
if (!expanded.isEmpty()) if (!expanded.isEmpty())
globalRegExpSourceMap.push_back(qMakePair(entry.first, expanded)); globalRegExpSourceMap.push_back(qMakePair(entry.first, expanded));
} }

View File

@@ -3334,7 +3334,7 @@ bool boolSetting(int code)
QString stringSetting(int code) QString stringSetting(int code)
{ {
QString raw = theDebuggerCore->m_debuggerSettings->item(code)->value().toString(); QString raw = theDebuggerCore->m_debuggerSettings->item(code)->value().toString();
return globalMacroExpander()->expandedString(raw); return globalMacroExpander()->expand(raw);
} }
QStringList stringListSetting(int code) QStringList stringListSetting(int code)

View File

@@ -4404,9 +4404,8 @@ void GdbEngine::abortDebugger()
void GdbEngine::resetInferior() void GdbEngine::resetInferior()
{ {
if (!startParameters().commandsForReset.isEmpty()) { if (!startParameters().commandsForReset.isEmpty()) {
QByteArray substitutedCommands = globalMacroExpander()->expandedString( QByteArray commands = globalMacroExpander()->expand(startParameters().commandsForReset);
QString::fromLatin1(startParameters().commandsForReset)).toLatin1(); foreach (QByteArray command, commands.split('\n')) {
foreach (QByteArray command, substitutedCommands.split('\n')) {
command = command.trimmed(); command = command.trimmed();
if (!command.isEmpty()) { if (!command.isEmpty()) {
if (state() == InferiorStopOk) { if (state() == InferiorStopOk) {
@@ -4455,8 +4454,8 @@ void GdbEngine::handleInferiorPrepared()
QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state()); QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
if (!sp.commandsAfterConnect.isEmpty()) { if (!sp.commandsAfterConnect.isEmpty()) {
QByteArray substitutedCommands = globalMacroExpander()->expandedString(QString::fromLatin1(sp.commandsAfterConnect)).toLatin1(); QByteArray commands = globalMacroExpander()->expand(sp.commandsAfterConnect);
foreach (QByteArray command, substitutedCommands.split('\n')) { foreach (QByteArray command, commands.split('\n')) {
postCommand(command); postCommand(command);
} }
} }

View File

@@ -43,7 +43,7 @@
#include <coreplugin/idocument.h> #include <coreplugin/idocument.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <utils/stringutils.h> #include <utils/macroexpander.h>
#include <utils/algorithm.h> #include <utils/algorithm.h>
#include <QDebug> #include <QDebug>
@@ -155,7 +155,7 @@ QList<NamedWidget *> BuildConfiguration::createSubConfigWidgets()
return QList<NamedWidget *>() << new BuildEnvironmentWidget(this); return QList<NamedWidget *>() << new BuildEnvironmentWidget(this);
} }
Utils::AbstractMacroExpander *BuildConfiguration::macroExpander() Utils::MacroExpander *BuildConfiguration::macroExpander()
{ {
if (!m_macroExpander) if (!m_macroExpander)
m_macroExpander = new Internal::BuildConfigMacroExpander(this); m_macroExpander = new Internal::BuildConfigMacroExpander(this);

View File

@@ -37,7 +37,7 @@
#include <utils/environment.h> #include <utils/environment.h>
#include <utils/fileutils.h> #include <utils/fileutils.h>
namespace Utils { class AbstractMacroExpander; } namespace Utils { class MacroExpander; }
namespace ProjectExplorer { namespace ProjectExplorer {
@@ -83,7 +83,7 @@ public:
virtual bool isEnabled() const; virtual bool isEnabled() const;
virtual QString disabledReason() const; virtual QString disabledReason() const;
Utils::AbstractMacroExpander *macroExpander(); Utils::MacroExpander *macroExpander();
enum BuildType { enum BuildType {
Unknown, Unknown,
@@ -115,7 +115,7 @@ private:
bool m_clearSystemEnvironment; bool m_clearSystemEnvironment;
QList<Utils::EnvironmentItem> m_userEnvironmentChanges; QList<Utils::EnvironmentItem> m_userEnvironmentChanges;
QList<BuildStepList *> m_stepLists; QList<BuildStepList *> m_stepLists;
Utils::AbstractMacroExpander *m_macroExpander; Utils::MacroExpander *m_macroExpander;
Utils::FileName m_buildDirectory; Utils::FileName m_buildDirectory;
Utils::FileName m_lastEmmitedBuildDirectory; Utils::FileName m_lastEmmitedBuildDirectory;
mutable Utils::Environment m_cachedEnvironment; mutable Utils::Environment m_cachedEnvironment;

View File

@@ -53,15 +53,16 @@
#include <QVariantMap> #include <QVariantMap>
#include <QVBoxLayout> #include <QVBoxLayout>
static const char NAME_KEY[] = "name"; using namespace Utils;
static const char DISPLAY_NAME_KEY[] = "trDisplayName";
static const char MANDATORY_KEY[] = "mandatory";
static const char VISIBLE_KEY[] = "visible";
static const char ENABLED_KEY[] = "enabled";
static const char SPAN_KEY[] = "span";
static const char TYPE_KEY[] = "type";
static const char DATA_KEY[] = "data";
const char NAME_KEY[] = "name";
const char DISPLAY_NAME_KEY[] = "trDisplayName";
const char MANDATORY_KEY[] = "mandatory";
const char VISIBLE_KEY[] = "visible";
const char ENABLED_KEY[] = "enabled";
const char SPAN_KEY[] = "span";
const char TYPE_KEY[] = "type";
const char DATA_KEY[] = "data";
namespace ProjectExplorer { namespace ProjectExplorer {
@@ -158,13 +159,13 @@ void JsonFieldPage::Field::createWidget(JsonFieldPage *page)
setup(page, name); setup(page, name);
} }
void JsonFieldPage::Field::adjustState(Utils::AbstractMacroExpander *expander) void JsonFieldPage::Field::adjustState(MacroExpander *expander)
{ {
setVisible(JsonWizard::boolFromVariant(m_visibleExpression, expander)); setVisible(JsonWizard::boolFromVariant(m_visibleExpression, expander));
setEnabled(JsonWizard::boolFromVariant(m_enabledExpression, expander)); setEnabled(JsonWizard::boolFromVariant(m_enabledExpression, expander));
} }
void JsonFieldPage::Field::initialize(Utils::AbstractMacroExpander *expander) void JsonFieldPage::Field::initialize(MacroExpander *expander)
{ {
adjustState(expander); adjustState(expander);
initializeData(expander); initializeData(expander);
@@ -326,16 +327,16 @@ void JsonFieldPage::LineEditField::setup(JsonFieldPage *page, const QString &nam
connect(w, &QLineEdit::textChanged, page, [page](QString) { page->completeChanged(); }); connect(w, &QLineEdit::textChanged, page, [page](QString) { page->completeChanged(); });
} }
bool JsonFieldPage::LineEditField::validate(Utils::AbstractMacroExpander *expander, QString *message) bool JsonFieldPage::LineEditField::validate(MacroExpander *expander, QString *message)
{ {
Q_UNUSED(message); Q_UNUSED(message);
QLineEdit *w = static_cast<QLineEdit *>(m_widget); QLineEdit *w = static_cast<QLineEdit *>(m_widget);
if (!m_isModified) { if (!m_isModified) {
w->setText(Utils::expandMacros(m_defaultText, expander)); w->setText(expander->expand(m_defaultText));
} else if (!w->isEnabled() && !m_disabledText.isNull() && m_currentText.isNull()) { } else if (!w->isEnabled() && !m_disabledText.isNull() && m_currentText.isNull()) {
m_currentText = w->text(); m_currentText = w->text();
w->setText(Utils::expandMacros(m_disabledText, expander)); w->setText(expander->expand(m_disabledText));
} else if (w->isEnabled() && !m_currentText.isNull()) { } else if (w->isEnabled() && !m_currentText.isNull()) {
w->setText(m_currentText); w->setText(m_currentText);
m_currentText.clear(); m_currentText.clear();
@@ -345,14 +346,14 @@ bool JsonFieldPage::LineEditField::validate(Utils::AbstractMacroExpander *expand
return !w->text().isEmpty(); return !w->text().isEmpty();
} }
void JsonFieldPage::LineEditField::initializeData(Utils::AbstractMacroExpander *expander) void JsonFieldPage::LineEditField::initializeData(MacroExpander *expander)
{ {
QTC_ASSERT(m_widget, return); QTC_ASSERT(m_widget, return);
m_isModified = false; m_isModified = false;
QLineEdit *w = static_cast<QLineEdit *>(m_widget); QLineEdit *w = static_cast<QLineEdit *>(m_widget);
w->setText(Utils::expandMacros(m_defaultText, expander)); w->setText(expander->expand(m_defaultText));
w->setPlaceholderText(m_placeholderText); w->setPlaceholderText(m_placeholderText);
} }
@@ -403,7 +404,7 @@ void JsonFieldPage::TextEditField::setup(JsonFieldPage *page, const QString &nam
connect(w, &QTextEdit::textChanged, page, &QWizardPage::completeChanged); connect(w, &QTextEdit::textChanged, page, &QWizardPage::completeChanged);
} }
bool JsonFieldPage::TextEditField::validate(Utils::AbstractMacroExpander *expander, QString *message) bool JsonFieldPage::TextEditField::validate(MacroExpander *expander, QString *message)
{ {
Q_UNUSED(expander); Q_UNUSED(expander);
Q_UNUSED(message); Q_UNUSED(message);
@@ -412,7 +413,7 @@ bool JsonFieldPage::TextEditField::validate(Utils::AbstractMacroExpander *expand
if (!w->isEnabled() && !m_disabledText.isNull() && m_currentText.isNull()) { if (!w->isEnabled() && !m_disabledText.isNull() && m_currentText.isNull()) {
m_currentText = w->toHtml(); m_currentText = w->toHtml();
w->setPlainText(Utils::expandMacros(m_disabledText, expander)); w->setPlainText(expander->expand(m_disabledText));
} else if (w->isEnabled() && !m_currentText.isNull()) { } else if (w->isEnabled() && !m_currentText.isNull()) {
w->setText(m_currentText); w->setText(m_currentText);
m_currentText.clear(); m_currentText.clear();
@@ -421,10 +422,10 @@ bool JsonFieldPage::TextEditField::validate(Utils::AbstractMacroExpander *expand
return !w->toPlainText().isEmpty(); return !w->toPlainText().isEmpty();
} }
void JsonFieldPage::TextEditField::initializeData(Utils::AbstractMacroExpander *expander) void JsonFieldPage::TextEditField::initializeData(MacroExpander *expander)
{ {
QTextEdit *w = static_cast<QTextEdit *>(m_widget); QTextEdit *w = static_cast<QTextEdit *>(m_widget);
w->setPlainText(Utils::expandMacros(m_defaultText, expander)); w->setPlainText(expander->expand(m_defaultText));
} }
// -------------------------------------------------------------------- // --------------------------------------------------------------------
@@ -432,7 +433,7 @@ void JsonFieldPage::TextEditField::initializeData(Utils::AbstractMacroExpander *
// -------------------------------------------------------------------- // --------------------------------------------------------------------
JsonFieldPage::PathChooserField::PathChooserField() : JsonFieldPage::PathChooserField::PathChooserField() :
m_kind(Utils::PathChooser::ExistingDirectory) m_kind(PathChooser::ExistingDirectory)
{ } { }
bool JsonFieldPage::PathChooserField::parseData(const QVariant &data, QString *errorMessage) bool JsonFieldPage::PathChooserField::parseData(const QVariant &data, QString *errorMessage)
@@ -453,19 +454,19 @@ bool JsonFieldPage::PathChooserField::parseData(const QVariant &data, QString *e
QString kindStr = tmp.value(QLatin1String("kind"), QLatin1String("existingDirectory")).toString(); QString kindStr = tmp.value(QLatin1String("kind"), QLatin1String("existingDirectory")).toString();
if (kindStr == QLatin1String("existingDirectory")) { if (kindStr == QLatin1String("existingDirectory")) {
m_kind = Utils::PathChooser::ExistingDirectory; m_kind = PathChooser::ExistingDirectory;
} else if (kindStr == QLatin1String("directory")) { } else if (kindStr == QLatin1String("directory")) {
m_kind = Utils::PathChooser::Directory; m_kind = PathChooser::Directory;
} else if (kindStr == QLatin1String("file")) { } else if (kindStr == QLatin1String("file")) {
m_kind = Utils::PathChooser::File; m_kind = PathChooser::File;
} else if (kindStr == QLatin1String("saveFile")) { } else if (kindStr == QLatin1String("saveFile")) {
m_kind = Utils::PathChooser::SaveFile; m_kind = PathChooser::SaveFile;
} else if (kindStr == QLatin1String("existingCommand")) { } else if (kindStr == QLatin1String("existingCommand")) {
m_kind = Utils::PathChooser::ExistingCommand; m_kind = PathChooser::ExistingCommand;
} else if (kindStr == QLatin1String("command")) { } else if (kindStr == QLatin1String("command")) {
m_kind = Utils::PathChooser::Command; m_kind = PathChooser::Command;
} else if (kindStr == QLatin1String("any")) { } else if (kindStr == QLatin1String("any")) {
m_kind = Utils::PathChooser::Any; m_kind = PathChooser::Any;
} else { } else {
*errorMessage = QCoreApplication::translate("ProjectExplorer::JsonFieldPage", *errorMessage = QCoreApplication::translate("ProjectExplorer::JsonFieldPage",
"kind '%1' is not one of the supported 'existingDirectory', " "kind '%1' is not one of the supported 'existingDirectory', "
@@ -482,41 +483,41 @@ QWidget *JsonFieldPage::PathChooserField::widget(const QString &displayName)
{ {
Q_UNUSED(displayName); Q_UNUSED(displayName);
QTC_ASSERT(!m_widget, return m_widget); QTC_ASSERT(!m_widget, return m_widget);
m_widget = new Utils::PathChooser; m_widget = new PathChooser;
return m_widget; return m_widget;
} }
void JsonFieldPage::PathChooserField::setEnabled(bool e) void JsonFieldPage::PathChooserField::setEnabled(bool e)
{ {
QTC_ASSERT(m_widget, return); QTC_ASSERT(m_widget, return);
Utils::PathChooser *w = static_cast<Utils::PathChooser *>(m_widget); PathChooser *w = static_cast<PathChooser *>(m_widget);
w->setReadOnly(!e); w->setReadOnly(!e);
} }
void JsonFieldPage::PathChooserField::setup(JsonFieldPage *page, const QString &name) void JsonFieldPage::PathChooserField::setup(JsonFieldPage *page, const QString &name)
{ {
Utils::PathChooser *w = static_cast<Utils::PathChooser *>(m_widget); PathChooser *w = static_cast<PathChooser *>(m_widget);
page->registerFieldWithName(name, w, "path", SIGNAL(changed(QString))); page->registerFieldWithName(name, w, "path", SIGNAL(changed(QString)));
connect(w, &Utils::PathChooser::changed, page, [page](QString) { page->completeChanged(); }); connect(w, &PathChooser::changed, page, [page](QString) { page->completeChanged(); });
} }
bool JsonFieldPage::PathChooserField::validate(Utils::AbstractMacroExpander *expander, QString *message) bool JsonFieldPage::PathChooserField::validate(MacroExpander *expander, QString *message)
{ {
Q_UNUSED(expander); Q_UNUSED(expander);
Q_UNUSED(message); Q_UNUSED(message);
Utils::PathChooser *w = static_cast<Utils::PathChooser *>(m_widget); PathChooser *w = static_cast<PathChooser *>(m_widget);
return w->isValid(); return w->isValid();
} }
void JsonFieldPage::PathChooserField::initializeData(Utils::AbstractMacroExpander *expander) void JsonFieldPage::PathChooserField::initializeData(MacroExpander *expander)
{ {
QTC_ASSERT(m_widget, return); QTC_ASSERT(m_widget, return);
Utils::PathChooser *w = static_cast<Utils::PathChooser *>(m_widget); PathChooser *w = static_cast<PathChooser *>(m_widget);
w->setBaseDirectory(Utils::expandMacros(m_basePath, expander)); w->setBaseDirectory(expander->expand(m_basePath));
w->setExpectedKind(m_kind); w->setExpectedKind(m_kind);
if (m_currentPath.isNull()) if (m_currentPath.isNull())
w->setPath(Utils::expandMacros(m_path, expander)); w->setPath(expander->expand(m_path));
else else
w->setPath(m_currentPath); w->setPath(m_currentPath);
} }
@@ -559,35 +560,35 @@ bool JsonFieldPage::CheckBoxField::parseData(const QVariant &data, QString *erro
QWidget *JsonFieldPage::CheckBoxField::widget(const QString &displayName) QWidget *JsonFieldPage::CheckBoxField::widget(const QString &displayName)
{ {
QTC_ASSERT(!m_widget, return m_widget); QTC_ASSERT(!m_widget, return m_widget);
Utils::TextFieldCheckBox *w = new Utils::TextFieldCheckBox(displayName); TextFieldCheckBox *w = new TextFieldCheckBox(displayName);
m_widget = w; m_widget = w;
return m_widget; return m_widget;
} }
void JsonFieldPage::CheckBoxField::setup(JsonFieldPage *page, const QString &name) void JsonFieldPage::CheckBoxField::setup(JsonFieldPage *page, const QString &name)
{ {
Utils::TextFieldCheckBox *w = static_cast<Utils::TextFieldCheckBox *>(m_widget); TextFieldCheckBox *w = static_cast<TextFieldCheckBox *>(m_widget);
connect(w, &Utils::TextFieldCheckBox::clicked, [this]() { m_isModified = true; }); connect(w, &TextFieldCheckBox::clicked, [this]() { m_isModified = true; });
page->registerFieldWithName(name, w, "text", SIGNAL(textChanged(QString))); page->registerFieldWithName(name, w, "text", SIGNAL(textChanged(QString)));
} }
bool JsonFieldPage::CheckBoxField::validate(Utils::AbstractMacroExpander *expander, QString *message) bool JsonFieldPage::CheckBoxField::validate(MacroExpander *expander, QString *message)
{ {
Q_UNUSED(message); Q_UNUSED(message);
if (!m_isModified) { if (!m_isModified) {
Utils::TextFieldCheckBox *w = static_cast<Utils::TextFieldCheckBox *>(m_widget); TextFieldCheckBox *w = static_cast<TextFieldCheckBox *>(m_widget);
w->setChecked(JsonWizard::boolFromVariant(m_checkedExpression, expander)); w->setChecked(JsonWizard::boolFromVariant(m_checkedExpression, expander));
} }
return true; return true;
} }
void JsonFieldPage::CheckBoxField::initializeData(Utils::AbstractMacroExpander *expander) void JsonFieldPage::CheckBoxField::initializeData(MacroExpander *expander)
{ {
QTC_ASSERT(m_widget, return); QTC_ASSERT(m_widget, return);
Utils::TextFieldCheckBox *w = static_cast<Utils::TextFieldCheckBox *>(m_widget); TextFieldCheckBox *w = static_cast<TextFieldCheckBox *>(m_widget);
w->setTrueText(Utils::expandMacros(m_checkedValue, expander)); w->setTrueText(expander->expand(m_checkedValue));
w->setFalseText(Utils::expandMacros(m_uncheckedValue, expander)); w->setFalseText(expander->expand(m_uncheckedValue));
w->setChecked(JsonWizard::boolFromVariant(m_checkedExpression, expander)); w->setChecked(JsonWizard::boolFromVariant(m_checkedExpression, expander));
} }
@@ -675,23 +676,23 @@ QWidget *JsonFieldPage::ComboBoxField::widget(const QString &displayName)
{ {
Q_UNUSED(displayName); Q_UNUSED(displayName);
QTC_ASSERT(!m_widget, return m_widget); QTC_ASSERT(!m_widget, return m_widget);
m_widget = new Utils::TextFieldComboBox; m_widget = new TextFieldComboBox;
return m_widget; return m_widget;
} }
void JsonFieldPage::ComboBoxField::setup(JsonFieldPage *page, const QString &name) void JsonFieldPage::ComboBoxField::setup(JsonFieldPage *page, const QString &name)
{ {
Utils::TextFieldComboBox *w = static_cast<Utils::TextFieldComboBox *>(m_widget); TextFieldComboBox *w = static_cast<TextFieldComboBox *>(m_widget);
page->registerFieldWithName(name, w, "text", SIGNAL(text4Changed(QString))); page->registerFieldWithName(name, w, "text", SIGNAL(text4Changed(QString)));
connect(w, &Utils::TextFieldComboBox::text4Changed, page, [page](QString) { page->completeChanged(); }); connect(w, &TextFieldComboBox::text4Changed, page, [page](QString) { page->completeChanged(); });
} }
bool JsonFieldPage::ComboBoxField::validate(Utils::AbstractMacroExpander *expander, QString *message) bool JsonFieldPage::ComboBoxField::validate(MacroExpander *expander, QString *message)
{ {
Q_UNUSED(expander); Q_UNUSED(expander);
Q_UNUSED(message); Q_UNUSED(message);
Utils::TextFieldComboBox *w = static_cast<Utils::TextFieldComboBox *>(m_widget); TextFieldComboBox *w = static_cast<TextFieldComboBox *>(m_widget);
if (!w->isEnabled() && m_disabledIndex >= 0 && m_savedIndex < 0) { if (!w->isEnabled() && m_disabledIndex >= 0 && m_savedIndex < 0) {
m_savedIndex = w->currentIndex(); m_savedIndex = w->currentIndex();
w->setCurrentIndex(m_disabledIndex); w->setCurrentIndex(m_disabledIndex);
@@ -703,15 +704,15 @@ bool JsonFieldPage::ComboBoxField::validate(Utils::AbstractMacroExpander *expand
return true; return true;
} }
void JsonFieldPage::ComboBoxField::initializeData(Utils::AbstractMacroExpander *expander) void JsonFieldPage::ComboBoxField::initializeData(MacroExpander *expander)
{ {
Utils::TextFieldComboBox *w = static_cast<Utils::TextFieldComboBox *>(m_widget); TextFieldComboBox *w = static_cast<TextFieldComboBox *>(m_widget);
QStringList tmpItems QStringList tmpItems
= Utils::transform(m_itemList, = Utils::transform(m_itemList,
[expander](const QString &i) { return Utils::expandMacros(i, expander); }); [expander](const QString &i) { return expander->expand(i); });
QStringList tmpData QStringList tmpData
= Utils::transform(m_itemDataList, = Utils::transform(m_itemDataList,
[expander](const QString &i) { return Utils::expandMacros(i, expander); }); [expander](const QString &i) { return expander->expand(i); });
w->setItems(tmpItems, tmpData); w->setItems(tmpItems, tmpData);
w->setInsertPolicy(QComboBox::NoInsert); w->setInsertPolicy(QComboBox::NoInsert);
@@ -725,8 +726,8 @@ void JsonFieldPage::ComboBoxField::initializeData(Utils::AbstractMacroExpander *
// JsonFieldPage: // JsonFieldPage:
// -------------------------------------------------------------------- // --------------------------------------------------------------------
JsonFieldPage::JsonFieldPage(Utils::AbstractMacroExpander *expander, QWidget *parent) : JsonFieldPage::JsonFieldPage(MacroExpander *expander, QWidget *parent) :
Utils::WizardPage(parent), WizardPage(parent),
m_formLayout(new QFormLayout), m_formLayout(new QFormLayout),
m_errorLabel(new QLabel), m_errorLabel(new QLabel),
m_expander(expander) m_expander(expander)
@@ -812,7 +813,7 @@ void JsonFieldPage::clearError() const
m_errorLabel->setVisible(false); m_errorLabel->setVisible(false);
} }
Utils::AbstractMacroExpander *JsonFieldPage::expander() MacroExpander *JsonFieldPage::expander()
{ {
return m_expander; return m_expander;
} }

View File

@@ -45,7 +45,7 @@ class QTextEdit;
QT_END_NAMESPACE QT_END_NAMESPACE
namespace Utils { namespace Utils {
class AbstractMacroExpander; class MacroExpander;
class TextFieldCheckBox; class TextFieldCheckBox;
class TextFieldComboBox; class TextFieldComboBox;
} // namespace Utils } // namespace Utils
@@ -67,15 +67,15 @@ public:
static Field *parse(const QVariant &input, QString *errorMessage); static Field *parse(const QVariant &input, QString *errorMessage);
void createWidget(JsonFieldPage *page); void createWidget(JsonFieldPage *page);
void adjustState(Utils::AbstractMacroExpander *expander); void adjustState(Utils::MacroExpander *expander);
virtual void setEnabled(bool e) { m_widget->setEnabled(e); } virtual void setEnabled(bool e) { m_widget->setEnabled(e); }
void setVisible(bool v) { m_widget->setVisible(v); } void setVisible(bool v) { m_widget->setVisible(v); }
virtual bool validate(Utils::AbstractMacroExpander *expander, QString *message) virtual bool validate(Utils::MacroExpander *expander, QString *message)
{ Q_UNUSED(expander); Q_UNUSED(message); return true; } { Q_UNUSED(expander); Q_UNUSED(message); return true; }
void initialize(Utils::AbstractMacroExpander *expander); void initialize(Utils::MacroExpander *expander);
virtual void cleanup(Utils::AbstractMacroExpander *expander) { Q_UNUSED(expander); } virtual void cleanup(Utils::MacroExpander *expander) { Q_UNUSED(expander); }
virtual bool suppressName() const { return false; } virtual bool suppressName() const { return false; }
@@ -89,7 +89,7 @@ public:
QVariant m_enabledExpression; QVariant m_enabledExpression;
virtual bool parseData(const QVariant &data, QString *errorMessage) = 0; virtual bool parseData(const QVariant &data, QString *errorMessage) = 0;
virtual void initializeData(Utils::AbstractMacroExpander *expander) { Q_UNUSED(expander); } virtual void initializeData(Utils::MacroExpander *expander) { Q_UNUSED(expander); }
virtual QWidget *widget(const QString &displayName) = 0; virtual QWidget *widget(const QString &displayName) = 0;
virtual void setup(JsonFieldPage *page, const QString &name) virtual void setup(JsonFieldPage *page, const QString &name)
{ Q_UNUSED(page); Q_UNUSED(name); } { Q_UNUSED(page); Q_UNUSED(name); }
@@ -136,8 +136,8 @@ public:
void setup(JsonFieldPage *page, const QString &name); void setup(JsonFieldPage *page, const QString &name);
bool validate(Utils::AbstractMacroExpander *expander, QString *message); bool validate(Utils::MacroExpander *expander, QString *message);
void initializeData(Utils::AbstractMacroExpander *expander); void initializeData(Utils::MacroExpander *expander);
QString m_placeholderText; QString m_placeholderText;
QString m_defaultText; QString m_defaultText;
@@ -159,8 +159,8 @@ public:
void setup(JsonFieldPage *page, const QString &name); void setup(JsonFieldPage *page, const QString &name);
bool validate(Utils::AbstractMacroExpander *expander, QString *message); bool validate(Utils::MacroExpander *expander, QString *message);
void initializeData(Utils::AbstractMacroExpander *expander); void initializeData(Utils::MacroExpander *expander);
QString m_defaultText; QString m_defaultText;
bool m_acceptRichText; bool m_acceptRichText;
@@ -182,8 +182,8 @@ public:
void setup(JsonFieldPage *page, const QString &name); void setup(JsonFieldPage *page, const QString &name);
bool validate(Utils::AbstractMacroExpander *expander, QString *message); bool validate(Utils::MacroExpander *expander, QString *message);
void initializeData(Utils::AbstractMacroExpander *expander); void initializeData(Utils::MacroExpander *expander);
QString m_path; QString m_path;
QString m_basePath; QString m_basePath;
@@ -206,8 +206,8 @@ public:
void setup(JsonFieldPage *page, const QString &name); void setup(JsonFieldPage *page, const QString &name);
bool validate(Utils::AbstractMacroExpander *expander, QString *message); bool validate(Utils::MacroExpander *expander, QString *message);
void initializeData(Utils::AbstractMacroExpander *expander); void initializeData(Utils::MacroExpander *expander);
QString m_checkedValue; QString m_checkedValue;
QString m_uncheckedValue; QString m_uncheckedValue;
@@ -228,8 +228,8 @@ public:
void setup(JsonFieldPage *page, const QString &name); void setup(JsonFieldPage *page, const QString &name);
bool validate(Utils::AbstractMacroExpander *expander, QString *message); bool validate(Utils::MacroExpander *expander, QString *message);
void initializeData(Utils::AbstractMacroExpander *expander); void initializeData(Utils::MacroExpander *expander);
QStringList m_itemList; QStringList m_itemList;
QStringList m_itemDataList; QStringList m_itemDataList;
@@ -240,7 +240,7 @@ public:
int m_currentIndex; int m_currentIndex;
}; };
JsonFieldPage(Utils::AbstractMacroExpander *expander, QWidget *parent = 0); JsonFieldPage(Utils::MacroExpander *expander, QWidget *parent = 0);
~JsonFieldPage(); ~JsonFieldPage();
bool setup(const QVariant &data); bool setup(const QVariant &data);
@@ -254,7 +254,7 @@ public:
void showError(const QString &m) const; void showError(const QString &m) const;
void clearError() const; void clearError() const;
Utils::AbstractMacroExpander *expander(); Utils::MacroExpander *expander();
private: private:
QFormLayout *m_formLayout; QFormLayout *m_formLayout;
@@ -262,7 +262,7 @@ private:
QList<Field *> m_fields; QList<Field *> m_fields;
Utils::AbstractMacroExpander *m_expander; Utils::MacroExpander *m_expander;
}; };
} // namespace ProjectExplorer } // namespace ProjectExplorer

View File

@@ -61,7 +61,7 @@ void JsonWizard::addGenerator(JsonWizardGenerator *gen)
m_generators.append(gen); m_generators.append(gen);
} }
Utils::AbstractMacroExpander *JsonWizard::expander() const Utils::MacroExpander *JsonWizard::expander() const
{ {
return m_expander; return m_expander;
} }
@@ -114,7 +114,7 @@ QVariant JsonWizard::value(const QString &n) const
QVariant v = property(n.toUtf8()); QVariant v = property(n.toUtf8());
if (v.isValid()) { if (v.isValid()) {
if (v.type() == QVariant::String) if (v.type() == QVariant::String)
return Utils::expandMacros(v.toString(), m_expander); return m_expander->expand(v.toString());
else else
return v; return v;
} }
@@ -128,10 +128,10 @@ void JsonWizard::setValue(const QString &key, const QVariant &value)
setProperty(key.toUtf8(), value); setProperty(key.toUtf8(), value);
} }
bool JsonWizard::boolFromVariant(const QVariant &v, Utils::AbstractMacroExpander *expander) bool JsonWizard::boolFromVariant(const QVariant &v, Utils::MacroExpander *expander)
{ {
if (v.type() == QVariant::String) if (v.type() == QVariant::String)
return !Utils::expandMacros(v.toString(), expander).isEmpty(); return !expander->expand(v.toString()).isEmpty();
return v.toBool(); return v.toBool();
} }

View File

@@ -37,7 +37,7 @@
#include <utils/wizard.h> #include <utils/wizard.h>
namespace Utils { class AbstractMacroExpander; } namespace Utils { class MacroExpander; }
namespace ProjectExplorer { namespace ProjectExplorer {
@@ -71,7 +71,7 @@ public:
void addGenerator(JsonWizardGenerator *gen); void addGenerator(JsonWizardGenerator *gen);
Utils::AbstractMacroExpander *expander() const; Utils::MacroExpander *expander() const;
void resetFileList(); void resetFileList();
GeneratorFiles fileList(); GeneratorFiles fileList();
@@ -79,7 +79,7 @@ public:
QVariant value(const QString &n) const; QVariant value(const QString &n) const;
void setValue(const QString &key, const QVariant &value); void setValue(const QString &key, const QVariant &value);
static bool boolFromVariant(const QVariant &v, Utils::AbstractMacroExpander *expander); static bool boolFromVariant(const QVariant &v, Utils::MacroExpander *expander);
void removeAttributeFromAllFiles(Core::GeneratedFile::Attribute a); void removeAttributeFromAllFiles(Core::GeneratedFile::Attribute a);

View File

@@ -31,9 +31,7 @@
#ifndef JSONWIZARDEXPANDER_H #ifndef JSONWIZARDEXPANDER_H
#define JSONWIZARDEXPANDER_H #define JSONWIZARDEXPANDER_H
#include <utils/stringutils.h> #include <utils/macroexpander.h>
#include <QString>
namespace ProjectExplorer { namespace ProjectExplorer {
@@ -42,7 +40,7 @@ class JsonWizard;
namespace Internal { namespace Internal {
// Documentation inside. // Documentation inside.
class JsonWizardExpander : public Utils::AbstractMacroExpander class JsonWizardExpander : public Utils::MacroExpander
{ {
public: public:
explicit JsonWizardExpander(JsonWizard *wizard); explicit JsonWizardExpander(JsonWizard *wizard);

View File

@@ -39,7 +39,7 @@
#include <utils/fileutils.h> #include <utils/fileutils.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <utils/stringutils.h> #include <utils/macroexpander.h>
#include <QCoreApplication> #include <QCoreApplication>
#include <QDir> #include <QDir>
@@ -48,7 +48,7 @@
namespace ProjectExplorer { namespace ProjectExplorer {
namespace Internal { namespace Internal {
static QString processTextFileContents(Utils::AbstractMacroExpander *expander, static QString processTextFileContents(Utils::MacroExpander *expander,
const QString &input, QString *errorMessage) const QString &input, QString *errorMessage)
{ {
errorMessage->clear(); errorMessage->clear();
@@ -57,7 +57,7 @@ static QString processTextFileContents(Utils::AbstractMacroExpander *expander,
return input; return input;
QString tmp; QString tmp;
if (!customWizardPreprocess(Utils::expandMacros(input, expander), &tmp, errorMessage)) if (!customWizardPreprocess(expander->expand(input), &tmp, errorMessage))
return QString(); return QString();
// Expand \n, \t and handle line continuation: // Expand \n, \t and handle line continuation:
@@ -124,7 +124,7 @@ bool JsonWizardFileGenerator::setup(const QVariant &data, QString *errorMessage)
return true; return true;
} }
Core::GeneratedFiles JsonWizardFileGenerator::fileList(Utils::AbstractMacroExpander *expander, Core::GeneratedFiles JsonWizardFileGenerator::fileList(Utils::MacroExpander *expander,
const QString &wizardDir, const QString &projectDir, const QString &wizardDir, const QString &projectDir,
QString *errorMessage) QString *errorMessage)
{ {
@@ -140,7 +140,7 @@ Core::GeneratedFiles JsonWizardFileGenerator::fileList(Utils::AbstractMacroExpan
continue; continue;
// Read contents of source file // Read contents of source file
const QString src = wizard.absoluteFilePath(Utils::expandMacros(f.source, expander)); const QString src = wizard.absoluteFilePath(expander->expand(f.source));
const QFile::OpenMode openMode const QFile::OpenMode openMode
= JsonWizard::boolFromVariant(f.isBinary, expander) = JsonWizard::boolFromVariant(f.isBinary, expander)
? QIODevice::ReadOnly : (QIODevice::ReadOnly|QIODevice::Text); ? QIODevice::ReadOnly : (QIODevice::ReadOnly|QIODevice::Text);
@@ -151,7 +151,7 @@ Core::GeneratedFiles JsonWizardFileGenerator::fileList(Utils::AbstractMacroExpan
// Generate file information: // Generate file information:
Core::GeneratedFile gf; Core::GeneratedFile gf;
gf.setPath(project.absoluteFilePath(Utils::expandMacros(f.target, expander))); gf.setPath(project.absoluteFilePath(expander->expand(f.target)));
if (JsonWizard::boolFromVariant(f.isBinary, expander)) { if (JsonWizard::boolFromVariant(f.isBinary, expander)) {
gf.setBinary(true); gf.setBinary(true);

View File

@@ -44,7 +44,7 @@ class JsonWizardFileGenerator : public JsonWizardGenerator
public: public:
bool setup(const QVariant &data, QString *errorMessage); bool setup(const QVariant &data, QString *errorMessage);
Core::GeneratedFiles fileList(Utils::AbstractMacroExpander *expander, Core::GeneratedFiles fileList(Utils::MacroExpander *expander,
const QString &wizardDir, const QString &projectDir, const QString &wizardDir, const QString &projectDir,
QString *errorMessage); QString *errorMessage);

View File

@@ -40,7 +40,7 @@
#include <QList> #include <QList>
#include <QObject> #include <QObject>
namespace Utils { class AbstractMacroExpander; } namespace Utils { class MacroExpander; }
namespace ProjectExplorer { namespace ProjectExplorer {
@@ -49,7 +49,7 @@ class JsonWizardGenerator
public: public:
virtual ~JsonWizardGenerator() { } virtual ~JsonWizardGenerator() { }
virtual Core::GeneratedFiles fileList(Utils::AbstractMacroExpander *expander, virtual Core::GeneratedFiles fileList(Utils::MacroExpander *expander,
const QString &baseDir, const QString &projectDir, const QString &baseDir, const QString &projectDir,
QString *errorMessage) = 0; QString *errorMessage) = 0;
virtual bool formatFile(const JsonWizard *wizard, Core::GeneratedFile *file, QString *errorMessage); virtual bool formatFile(const JsonWizard *wizard, Core::GeneratedFile *file, QString *errorMessage);

View File

@@ -300,7 +300,7 @@ QString Kit::unexpandedDisplayName() const
QString Kit::displayName() const QString Kit::displayName() const
{ {
return Utils::expandMacros(d->m_unexpandedDisplayName, &d->m_macroExpander); return d->m_macroExpander.expand(d->m_unexpandedDisplayName);
} }
static QString candidateName(const QString &name, const QString &postfix) static QString candidateName(const QString &name, const QString &postfix)

View File

@@ -33,7 +33,6 @@
#include "buildconfiguration.h" #include "buildconfiguration.h"
#include <utils/macroexpander.h> #include <utils/macroexpander.h>
#include <utils/stringutils.h>
#include <projectexplorer/target.h> #include <projectexplorer/target.h>
#include <projectexplorer/project.h> #include <projectexplorer/project.h>
@@ -43,7 +42,7 @@
namespace ProjectExplorer { namespace ProjectExplorer {
namespace Internal { namespace Internal {
class FallBackMacroExpander : public Utils::AbstractMacroExpander class FallBackMacroExpander : public Utils::MacroExpander
{ {
public: public:
explicit FallBackMacroExpander(const Target *target) : m_target(target) {} explicit FallBackMacroExpander(const Target *target) : m_target(target) {}
@@ -58,9 +57,7 @@ bool FallBackMacroExpander::resolveMacro(const QString &name, QString *ret)
*ret = m_target->project()->projectDirectory().toUserOutput(); *ret = m_target->project()->projectDirectory().toUserOutput();
return true; return true;
} }
bool found; return false;
*ret = Utils::globalMacroExpander()->value(name.toUtf8(), &found);
return found;
} }
} // namespace Internal } // namespace Internal
@@ -84,7 +81,7 @@ void LocalApplicationRunConfiguration::addToBaseEnvironment(Utils::Environment &
Q_UNUSED(env); Q_UNUSED(env);
} }
Utils::AbstractMacroExpander *LocalApplicationRunConfiguration::macroExpander() const Utils::MacroExpander *LocalApplicationRunConfiguration::macroExpander() const
{ {
if (BuildConfiguration *bc = activeBuildConfiguration()) if (BuildConfiguration *bc = activeBuildConfiguration())
return bc->macroExpander(); return bc->macroExpander();

View File

@@ -35,7 +35,7 @@
#include "applicationlauncher.h" #include "applicationlauncher.h"
namespace Utils { namespace Utils {
class AbstractMacroExpander; class MacroExpander;
class Environment; class Environment;
} }
@@ -58,10 +58,10 @@ protected:
explicit LocalApplicationRunConfiguration(Target *target, Core::Id id); explicit LocalApplicationRunConfiguration(Target *target, Core::Id id);
explicit LocalApplicationRunConfiguration(Target *target, LocalApplicationRunConfiguration *rc); explicit LocalApplicationRunConfiguration(Target *target, LocalApplicationRunConfiguration *rc);
Utils::AbstractMacroExpander *macroExpander() const; Utils::MacroExpander *macroExpander() const;
private: private:
mutable Utils::AbstractMacroExpander *m_macroExpander; mutable Utils::MacroExpander *m_macroExpander;
}; };
} // namespace ProjectExplorer } // namespace ProjectExplorer

View File

@@ -30,7 +30,7 @@
#include "processparameters.h" #include "processparameters.h"
#include <utils/stringutils.h> #include <utils/macroexpander.h>
#include <utils/qtcprocess.h> #include <utils/qtcprocess.h>
#include <QFileInfo> #include <QFileInfo>
@@ -97,7 +97,7 @@ void ProcessParameters::setWorkingDirectory(const QString &workingDirectory)
*/ */
/*! /*!
\fn void ProjectExplorer::ProcessParameters::setMacroExpander(Utils::AbstractMacroExpander *mx) \fn void ProjectExplorer::ProcessParameters::setMacroExpander(Utils::MacroExpander *mx)
Sets the macro expander \a mx to use on the command, arguments, and working Sets the macro expander \a mx to use on the command, arguments, and working
dir. dir.
@@ -113,7 +113,7 @@ QString ProcessParameters::effectiveWorkingDirectory() const
if (m_effectiveWorkingDirectory.isEmpty()) { if (m_effectiveWorkingDirectory.isEmpty()) {
QString wds = m_workingDirectory; QString wds = m_workingDirectory;
if (m_macroExpander) if (m_macroExpander)
Utils::expandMacros(&wds, m_macroExpander); wds = m_macroExpander->expand(wds);
m_effectiveWorkingDirectory = QDir::cleanPath(m_environment.expandVariables(wds)); m_effectiveWorkingDirectory = QDir::cleanPath(m_environment.expandVariables(wds));
} }
return m_effectiveWorkingDirectory; return m_effectiveWorkingDirectory;
@@ -128,7 +128,7 @@ QString ProcessParameters::effectiveCommand() const
if (m_effectiveCommand.isEmpty()) { if (m_effectiveCommand.isEmpty()) {
QString cmd = m_command; QString cmd = m_command;
if (m_macroExpander) if (m_macroExpander)
Utils::expandMacros(&cmd, m_macroExpander); cmd = m_macroExpander->expand(cmd);
m_effectiveCommand = m_effectiveCommand =
m_environment.searchInPath(cmd, QStringList(effectiveWorkingDirectory())).toString(); m_environment.searchInPath(cmd, QStringList(effectiveWorkingDirectory())).toString();
m_commandMissing = m_effectiveCommand.isEmpty(); m_commandMissing = m_effectiveCommand.isEmpty();
@@ -153,7 +153,7 @@ QString ProcessParameters::effectiveArguments() const
if (m_effectiveArguments.isEmpty()) { if (m_effectiveArguments.isEmpty()) {
m_effectiveArguments = m_arguments; m_effectiveArguments = m_arguments;
if (m_macroExpander) if (m_macroExpander)
Utils::expandMacros(&m_effectiveArguments, m_macroExpander); m_effectiveArguments = m_macroExpander->expand(m_effectiveArguments);
} }
return m_effectiveArguments; return m_effectiveArguments;
} }
@@ -162,7 +162,7 @@ QString ProcessParameters::prettyCommand() const
{ {
QString cmd = m_command; QString cmd = m_command;
if (m_macroExpander) if (m_macroExpander)
Utils::expandMacros(&cmd, m_macroExpander); cmd = m_macroExpander->expand(cmd);
return QFileInfo(cmd).fileName(); return QFileInfo(cmd).fileName();
} }

View File

@@ -35,7 +35,7 @@
#include <utils/environment.h> #include <utils/environment.h>
namespace Utils { class AbstractMacroExpander; } namespace Utils { class MacroExpander; }
namespace ProjectExplorer { namespace ProjectExplorer {
@@ -57,8 +57,8 @@ public:
void setEnvironment(const Utils::Environment &env) { m_environment = env; } void setEnvironment(const Utils::Environment &env) { m_environment = env; }
Utils::Environment environment() const { return m_environment; } Utils::Environment environment() const { return m_environment; }
void setMacroExpander(Utils::AbstractMacroExpander *mx) { m_macroExpander = mx; } void setMacroExpander(Utils::MacroExpander *mx) { m_macroExpander = mx; }
Utils::AbstractMacroExpander *macroExpander() const { return m_macroExpander; } Utils::MacroExpander *macroExpander() const { return m_macroExpander; }
/// Get the fully expanded working directory: /// Get the fully expanded working directory:
QString effectiveWorkingDirectory() const; QString effectiveWorkingDirectory() const;
@@ -81,7 +81,7 @@ private:
QString m_command; QString m_command;
QString m_arguments; QString m_arguments;
Utils::Environment m_environment; Utils::Environment m_environment;
Utils::AbstractMacroExpander *m_macroExpander; Utils::MacroExpander *m_macroExpander;
mutable QString m_effectiveWorkingDirectory; mutable QString m_effectiveWorkingDirectory;
mutable QString m_effectiveCommand; mutable QString m_effectiveCommand;

View File

@@ -32,13 +32,13 @@
#define PROJECTMACROEXPANDER_H #define PROJECTMACROEXPANDER_H
#include "projectexplorer_export.h" #include "projectexplorer_export.h"
#include <utils/stringutils.h> #include <utils/macroexpander.h>
#include <QFileInfo> #include <QFileInfo>
namespace ProjectExplorer { namespace ProjectExplorer {
class Kit; class Kit;
class PROJECTEXPLORER_EXPORT ProjectMacroExpander : public Utils::AbstractMacroExpander class PROJECTEXPLORER_EXPORT ProjectMacroExpander : public Utils::MacroExpander
{ {
public: public:
ProjectMacroExpander(const QString &projectFilePath, const QString &projectName, const Kit *k, const QString &bcName); ProjectMacroExpander(const QString &projectFilePath, const QString &projectName, const Kit *k, const QString &bcName);

View File

@@ -372,7 +372,7 @@ Utils::FileName QbsProject::defaultBuildDirectory(const QString &projectFilePath
const QString projectName = QFileInfo(projectFilePath).completeBaseName(); const QString projectName = QFileInfo(projectFilePath).completeBaseName();
ProjectExplorer::ProjectMacroExpander expander(projectFilePath, projectName, k, bcName); ProjectExplorer::ProjectMacroExpander expander(projectFilePath, projectName, k, bcName);
QString projectDir = projectDirectory(Utils::FileName::fromString(projectFilePath)).toString(); QString projectDir = projectDirectory(Utils::FileName::fromString(projectFilePath)).toString();
QString buildPath = Utils::expandMacros(Core::DocumentManager::buildDirectory(), &expander); QString buildPath = expander.expand(Core::DocumentManager::buildDirectory());
return Utils::FileName::fromString(Utils::FileUtils::resolvePath(projectDir, buildPath)); return Utils::FileName::fromString(Utils::FileUtils::resolvePath(projectDir, buildPath));
} }

View File

@@ -264,7 +264,7 @@ QString QbsRunConfiguration::workingDirectory() const
EnvironmentAspect *aspect = extraAspect<EnvironmentAspect>(); EnvironmentAspect *aspect = extraAspect<EnvironmentAspect>();
QTC_ASSERT(aspect, baseWorkingDirectory()); QTC_ASSERT(aspect, baseWorkingDirectory());
return QDir::cleanPath(aspect->environment().expandVariables( return QDir::cleanPath(aspect->environment().expandVariables(
Utils::expandMacros(baseWorkingDirectory(), macroExpander()))); macroExpander()->expand(baseWorkingDirectory())));
} }
QString QbsRunConfiguration::baseWorkingDirectory() const QString QbsRunConfiguration::baseWorkingDirectory() const

View File

@@ -479,7 +479,7 @@ QString DesktopQmakeRunConfiguration::workingDirectory() const
EnvironmentAspect *aspect = extraAspect<EnvironmentAspect>(); EnvironmentAspect *aspect = extraAspect<EnvironmentAspect>();
QTC_ASSERT(aspect, return baseWorkingDirectory()); QTC_ASSERT(aspect, return baseWorkingDirectory());
return QDir::cleanPath(aspect->environment().expandVariables( return QDir::cleanPath(aspect->environment().expandVariables(
Utils::expandMacros(baseWorkingDirectory(), macroExpander()))); macroExpander()->expand(baseWorkingDirectory())));
} }
QString DesktopQmakeRunConfiguration::baseWorkingDirectory() const QString DesktopQmakeRunConfiguration::baseWorkingDirectory() const

View File

@@ -1455,7 +1455,7 @@ QString QmakeProject::shadowBuildDirectory(const QString &proFilePath, const Kit
const QString projectName = QFileInfo(proFilePath).completeBaseName(); const QString projectName = QFileInfo(proFilePath).completeBaseName();
ProjectExplorer::ProjectMacroExpander expander(proFilePath, projectName, k, suffix); ProjectExplorer::ProjectMacroExpander expander(proFilePath, projectName, k, suffix);
QString projectDir = projectDirectory(Utils::FileName::fromString(proFilePath)).toString(); QString projectDir = projectDirectory(Utils::FileName::fromString(proFilePath)).toString();
QString buildPath = Utils::expandMacros(Core::DocumentManager::buildDirectory(), &expander); QString buildPath = expander.expand(Core::DocumentManager::buildDirectory());
return Utils::FileUtils::resolvePath(projectDir, buildPath); return Utils::FileUtils::resolvePath(projectDir, buildPath);
} }

View File

@@ -609,8 +609,7 @@ void BaseQtVersion::setAutoDetectionSource(const QString &autodetectionSource)
QString BaseQtVersion::displayName() const QString BaseQtVersion::displayName() const
{ {
QString ret = Utils::expandMacros(m_unexpandedDisplayName, &m_expander); return m_expander.expand(m_unexpandedDisplayName);
return Utils::expandMacros(ret, Utils::globalMacroExpander());
} }
QString BaseQtVersion::unexpandedDisplayName() const QString BaseQtVersion::unexpandedDisplayName() const

View File

@@ -200,7 +200,7 @@ bool CustomExecutableRunConfiguration::validateExecutable(QString *executable, Q
EnvironmentAspect *aspect = extraAspect<EnvironmentAspect>(); EnvironmentAspect *aspect = extraAspect<EnvironmentAspect>();
if (aspect) if (aspect)
env = aspect->environment(); env = aspect->environment();
const Utils::FileName exec = env.searchInPath(Utils::expandMacros(m_executable, macroExpander()), const Utils::FileName exec = env.searchInPath(macroExpander()->expand(m_executable),
QStringList(workingDirectory())); QStringList(workingDirectory()));
if (exec.isEmpty()) { if (exec.isEmpty()) {
if (errorMessage) if (errorMessage)
@@ -240,7 +240,7 @@ QString CustomExecutableRunConfiguration::workingDirectory() const
EnvironmentAspect *aspect = extraAspect<EnvironmentAspect>(); EnvironmentAspect *aspect = extraAspect<EnvironmentAspect>();
QTC_ASSERT(aspect, return baseWorkingDirectory()); QTC_ASSERT(aspect, return baseWorkingDirectory());
return QDir::cleanPath(aspect->environment().expandVariables( return QDir::cleanPath(aspect->environment().expandVariables(
Utils::expandMacros(baseWorkingDirectory(), macroExpander()))); macroExpander()->expand(baseWorkingDirectory())));
} }
QString CustomExecutableRunConfiguration::baseWorkingDirectory() const QString CustomExecutableRunConfiguration::baseWorkingDirectory() const