Commit b7964e6c authored by Alessandro Portale's avatar Alessandro Portale
Browse files

ProjectExplorer: Replace QScriptEngine with QJSEngine



Change-Id: Iccc14c2197a30a7e62b2d388d163d1f89a5d1e87
Reviewed-by: default avatarhjk <hjk@theqtcompany.com>
Reviewed-by: default avatarTobias Hunger <tobias.hunger@theqtcompany.com>
parent ad5c0261
......@@ -45,7 +45,7 @@
#include <QFile>
#include <QFileInfo>
#include <QIcon>
#include <QScriptEngine>
#include <QJSEngine>
#include <QTemporaryFile>
#include <QTime>
#include <QXmlStreamAttribute>
......@@ -177,7 +177,7 @@ bool CustomWizardValidationRule::validateRules(const QList<CustomWizardValidatio
errorMessage->clear();
if (rules.isEmpty())
return true;
QScriptEngine engine;
QJSEngine engine;
foreach (const CustomWizardValidationRule &rule, rules)
if (!rule.validate(engine, replacementMap)) {
*errorMessage = rule.message;
......@@ -187,7 +187,7 @@ bool CustomWizardValidationRule::validateRules(const QList<CustomWizardValidatio
return true;
}
bool CustomWizardValidationRule::validate(QScriptEngine &engine, const QMap<QString, QString> &replacementMap) const
bool CustomWizardValidationRule::validate(QJSEngine &engine, const QMap<QString, QString> &replacementMap) const
{
// Apply parameters and evaluate using JavaScript
QString cond = condition;
......
......@@ -41,7 +41,7 @@ QT_BEGIN_NAMESPACE
class QIODevice;
class QDebug;
class QTemporaryFile;
class QScriptEngine;
class QJSEngine;
QT_END_NAMESPACE
namespace ProjectExplorer {
......@@ -82,7 +82,7 @@ public:
static bool validateRules(const QList<CustomWizardValidationRule> &rules,
const QMap<QString, QString> &replacementMap,
QString *errorMessage);
bool validate(QScriptEngine &, const QMap<QString, QString> &replacementMap) const;
bool validate(QJSEngine &, const QMap<QString, QString> &replacementMap) const;
QString condition;
QString message;
};
......
......@@ -40,9 +40,7 @@
#include <QStack>
#include <QRegExp>
#include <QDebug>
#include <QScriptEngine>
#include <QScriptValue>
#include <QJSEngine>
namespace ProjectExplorer {
namespace Internal {
......@@ -94,7 +92,7 @@ private:
mutable QRegExp m_endifPattern;
QStack<PreprocessStackEntry> m_sectionStack;
QScriptEngine m_scriptEngine;
QJSEngine m_scriptEngine;
};
PreprocessContext::PreprocessContext() :
......@@ -137,16 +135,15 @@ PreprocessorSection PreprocessContext::preprocessorLine(const QString &in,
return OtherSection;
}
// Evaluate an expression within an 'if'/'elsif' to a bool via QScript
bool evaluateBooleanJavaScriptExpression(QScriptEngine &engine, const QString &expression, bool *result, QString *errorMessage)
// Evaluate an expression within an 'if'/'elsif' to a bool via QJSEngine
bool evaluateBooleanJavaScriptExpression(QJSEngine &engine, const QString &expression, bool *result, QString *errorMessage)
{
errorMessage->clear();
*result = false;
engine.clearExceptions();
const QScriptValue value = engine.evaluate(expression);
if (engine.hasUncaughtException()) {
const QJSValue value = engine.evaluate(expression);
if (value.isError()) {
*errorMessage = QString::fromLatin1("Error in \"%1\": %2").
arg(expression, engine.uncaughtException().toString());
arg(expression, value.toString());
return false;
}
// Try to convert to bool, be that an int or whatever.
......
......@@ -33,14 +33,14 @@
#include <QString>
QT_FORWARD_DECLARE_CLASS(QScriptEngine)
QT_FORWARD_DECLARE_CLASS(QJSEngine)
namespace ProjectExplorer {
namespace Internal {
bool customWizardPreprocess(const QString &in, QString *out, QString *errorMessage);
/* Helper to evaluate an expression. */
bool evaluateBooleanJavaScriptExpression(QScriptEngine &engine, const QString &expression, bool *result, QString *errorMessage);
bool evaluateBooleanJavaScriptExpression(QJSEngine &engine, const QString &expression, bool *result, QString *errorMessage);
} // namespace Internal
} // namespace ProjectExplorer
......
QT += quick script
QT += quick qml
include(../../qtcreatorplugin.pri)
include(customwizard/customwizard.pri)
......
......@@ -3,7 +3,7 @@ import qbs 1.0
QtcPlugin {
name: "ProjectExplorer"
Depends { name: "Qt"; submodules: ["widgets", "xml", "network", "script"] }
Depends { name: "Qt"; submodules: ["widgets", "xml", "network", "qml"] }
Depends { name: "Qt.quick" }
Depends { name: "Aggregation" }
Depends { name: "QtcSsh" }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment