forked from qt-creator/qt-creator
Utils: Move template file processing from projectexplorer to utils
I want to use it e.g. for snippets and the TextEditor plugin may not depend on the ProjectExplorer, so the code has to move. This adds a dependency on QtQml to Utils, but that does not really matter since that is loaded into QtCreator anyway. Change-Id: Iada9f40b2966a1fc41631ab33da09812ad67d967 Reviewed-by: Daniel Teske <daniel.teske@theqtcompany.com>
This commit is contained in:
@@ -34,7 +34,6 @@
|
||||
|
||||
#include "../project.h"
|
||||
#include "../projectexplorer.h"
|
||||
#include "../customwizard/customwizardpreprocessor.h"
|
||||
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/messagemanager.h>
|
||||
@@ -202,51 +201,6 @@ QHash<QString, QVariant> JsonWizard::variables() const
|
||||
return result;
|
||||
}
|
||||
|
||||
QString JsonWizard::processText(Utils::MacroExpander *expander, const QString &input,
|
||||
QString *errorMessage)
|
||||
{
|
||||
errorMessage->clear();
|
||||
|
||||
if (input.isEmpty())
|
||||
return input;
|
||||
|
||||
// Recursively expand macros:
|
||||
QString in = input;
|
||||
QString oldIn;
|
||||
for (int i = 0; i < 5 && in != oldIn; ++i) {
|
||||
oldIn = in;
|
||||
in = expander->expand(oldIn);
|
||||
}
|
||||
|
||||
QString out;
|
||||
if (!Internal::customWizardPreprocess(in, &out, errorMessage))
|
||||
return QString();
|
||||
|
||||
// Expand \n, \t and handle line continuation:
|
||||
QString result;
|
||||
result.reserve(out.count());
|
||||
bool isEscaped = false;
|
||||
for (int i = 0; i < out.count(); ++i) {
|
||||
const QChar c = out.at(i);
|
||||
|
||||
if (isEscaped) {
|
||||
if (c == QLatin1Char('n'))
|
||||
result.append(QLatin1Char('\n'));
|
||||
else if (c == QLatin1Char('t'))
|
||||
result.append(QLatin1Char('\t'));
|
||||
else if (c != QLatin1Char('\n'))
|
||||
result.append(c);
|
||||
isEscaped = false;
|
||||
} else {
|
||||
if (c == QLatin1Char('\\'))
|
||||
isEscaped = true;
|
||||
else
|
||||
result.append(c);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void JsonWizard::accept()
|
||||
{
|
||||
auto page = qobject_cast<Utils::WizardPage *>(currentPage());
|
||||
|
||||
Reference in New Issue
Block a user