diff options
author | Christian Kamm <christian.d.kamm@nokia.com> | 2011-08-08 12:47:49 +0200 |
---|---|---|
committer | Christian Kamm <christian.d.kamm@nokia.com> | 2011-08-08 13:21:28 +0200 |
commit | 0e54183d4d31dc34fc742503c6e0956dd1737133 (patch) | |
tree | 5afeed4c2c52fa17314369e59cdcf034139c43a7 /src/plugins | |
parent | ff092f79b33e48847c7a475eb7362ffb9649aa49 (diff) | |
download | qt-creator-0e54183d4d31dc34fc742503c6e0956dd1737133.tar.gz |
QmlJS: Remove Interpreter namespace.
The distinction between QmlJS and QmlJS::Interpreter has always been
weak and the extra namespace just added an unnecessary complication.
Change-Id: I4db8ef4bd91b5f6bf610a9d23fdbf55bd60250fc
Reviewed-on: http://codereview.qt.nokia.com/2743
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@nokia.com>
Diffstat (limited to 'src/plugins')
22 files changed, 209 insertions, 220 deletions
diff --git a/src/plugins/qmldesigner/designercore/include/rewriterview.h b/src/plugins/qmldesigner/designercore/include/rewriterview.h index 88ac534c1e..d4ee5cccb2 100644 --- a/src/plugins/qmldesigner/designercore/include/rewriterview.h +++ b/src/plugins/qmldesigner/designercore/include/rewriterview.h @@ -51,10 +51,8 @@ namespace QmlJS { class DiagnosticMessage; class LookupContext; class Document; -namespace Interpreter { class ScopeChain; } -} namespace QmlDesigner { @@ -189,7 +187,7 @@ public: bool renameId(const QString& oldId, const QString& newId); - const QmlJS::Interpreter::ScopeChain &scopeChain() const; + const QmlJS::ScopeChain &scopeChain() const; QmlJS::Document *document() const; QString convertTypeToImportAlias(const QString &type) const; diff --git a/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp b/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp index 561b4e782c..5f348bb204 100644 --- a/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp +++ b/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp @@ -91,23 +91,23 @@ using namespace QmlJS; typedef QPair<QString, QString> PropertyInfo; -class PropertyMemberProcessor : public Interpreter::MemberProcessor +class PropertyMemberProcessor : public MemberProcessor { public: - virtual bool processProperty(const QString &name, const Interpreter::Value *value) + virtual bool processProperty(const QString &name, const Value *value) { - const Interpreter::ASTPropertyReference *ref = dynamic_cast<const Interpreter::ASTPropertyReference*>(value); + const ASTPropertyReference *ref = dynamic_cast<const ASTPropertyReference*>(value); if (ref) { QString type = "unknown"; if (ref->ast()->memberType) type = ref->ast()->memberType->asString(); m_properties.append(qMakePair(name, type)); } else { - if (const Interpreter::QmlObjectValue * ov = dynamic_cast<const Interpreter::QmlObjectValue *>(value)) { + if (const QmlObjectValue * ov = dynamic_cast<const QmlObjectValue *>(value)) { QString qualifiedTypeName = ov->packageName().isEmpty() ? ov->className() : ov->packageName() + '.' + ov->className(); m_properties.append(qMakePair(name, qualifiedTypeName)); } else { - Interpreter::TypeId typeId; + TypeId typeId; QString typeName = typeId(value); if (typeName == QLatin1String("number")) { if (value->asRealValue()) { @@ -135,26 +135,26 @@ static inline bool isValueType(const QString &type) return objectValuesList.contains(type); } -const Interpreter::QmlObjectValue *findQmlPrototype(const Interpreter::ObjectValue *ov, const Interpreter::ContextPtr &context) +const QmlObjectValue *findQmlPrototype(const ObjectValue *ov, const ContextPtr &context) { if (!ov) return 0; - const Interpreter::QmlObjectValue * qmlValue = dynamic_cast<const Interpreter::QmlObjectValue *>(ov); + const QmlObjectValue * qmlValue = dynamic_cast<const QmlObjectValue *>(ov); if (qmlValue) return qmlValue; return findQmlPrototype(ov->prototype(context), context); } -QStringList prototypes(const Interpreter::ObjectValue *ov, const Interpreter::ContextPtr &context, bool versions = false) +QStringList prototypes(const ObjectValue *ov, const ContextPtr &context, bool versions = false) { QStringList list; if (!ov) return list; ov = ov->prototype(context); while (ov) { - const Interpreter::QmlObjectValue * qmlValue = dynamic_cast<const Interpreter::QmlObjectValue *>(ov); + const QmlObjectValue * qmlValue = dynamic_cast<const QmlObjectValue *>(ov); if (qmlValue) { if (versions) { list << qmlValue->packageName() + '.' + qmlValue->className() + @@ -175,9 +175,9 @@ QStringList prototypes(const Interpreter::ObjectValue *ov, const Interpreter::Co return list; } -QList<PropertyInfo> getObjectTypes(const Interpreter::ObjectValue *ov, const Interpreter::ContextPtr &context, bool local = false); +QList<PropertyInfo> getObjectTypes(const ObjectValue *ov, const ContextPtr &context, bool local = false); -QList<PropertyInfo> getQmlTypes(const Interpreter::QmlObjectValue *ov, const Interpreter::ContextPtr &context, bool local = false) +QList<PropertyInfo> getQmlTypes(const QmlObjectValue *ov, const ContextPtr &context, bool local = false) { QList<PropertyInfo> list; if (!ov) @@ -192,7 +192,7 @@ QList<PropertyInfo> getQmlTypes(const Interpreter::QmlObjectValue *ov, const Int QString name = property.first; if (!ov->isWritable(name) && ov->isPointer(name)) { //dot property - const Interpreter::QmlObjectValue * qmlValue = dynamic_cast<const Interpreter::QmlObjectValue *>(ov->lookupMember(name, context)); + const QmlObjectValue * qmlValue = dynamic_cast<const QmlObjectValue *>(ov->lookupMember(name, context)); if (qmlValue) { QList<PropertyInfo> dotProperties = getQmlTypes(qmlValue, context); foreach (const PropertyInfo &propertyInfo, dotProperties) { @@ -204,7 +204,7 @@ QList<PropertyInfo> getQmlTypes(const Interpreter::QmlObjectValue *ov, const Int } } if (isValueType(ov->propertyType(name))) { - const Interpreter::ObjectValue *dotObjectValue = dynamic_cast<const Interpreter::ObjectValue *>(ov->lookupMember(name, context)); + const ObjectValue *dotObjectValue = dynamic_cast<const ObjectValue *>(ov->lookupMember(name, context)); if (dotObjectValue) { QList<PropertyInfo> dotProperties = getObjectTypes(dotObjectValue, context); foreach (const PropertyInfo &propertyInfo, dotProperties) { @@ -222,9 +222,9 @@ QList<PropertyInfo> getQmlTypes(const Interpreter::QmlObjectValue *ov, const Int } if (!local) { - const Interpreter::ObjectValue* prototype = ov->prototype(context); + const ObjectValue* prototype = ov->prototype(context); - const Interpreter::QmlObjectValue * qmlObjectValue = dynamic_cast<const Interpreter::QmlObjectValue *>(prototype); + const QmlObjectValue * qmlObjectValue = dynamic_cast<const QmlObjectValue *>(prototype); if (qmlObjectValue) { list << getQmlTypes(qmlObjectValue, context); @@ -236,11 +236,11 @@ QList<PropertyInfo> getQmlTypes(const Interpreter::QmlObjectValue *ov, const Int return list; } -QList<PropertyInfo> getTypes(const Interpreter::ObjectValue *ov, const Interpreter::ContextPtr &context, bool local = false) +QList<PropertyInfo> getTypes(const ObjectValue *ov, const ContextPtr &context, bool local = false) { QList<PropertyInfo> list; - const Interpreter::QmlObjectValue * qmlObjectValue = dynamic_cast<const Interpreter::QmlObjectValue *>(ov); + const QmlObjectValue * qmlObjectValue = dynamic_cast<const QmlObjectValue *>(ov); if (qmlObjectValue) { list << getQmlTypes(qmlObjectValue, context, local); @@ -251,7 +251,7 @@ QList<PropertyInfo> getTypes(const Interpreter::ObjectValue *ov, const Interpret return list; } -QList<PropertyInfo> getObjectTypes(const Interpreter::ObjectValue *ov, const Interpreter::ContextPtr &context, bool local) +QList<PropertyInfo> getObjectTypes(const ObjectValue *ov, const ContextPtr &context, bool local) { QList<PropertyInfo> list; if (!ov) @@ -262,9 +262,9 @@ QList<PropertyInfo> getObjectTypes(const Interpreter::ObjectValue *ov, const Int list << processor.properties(); if (!local) { - const Interpreter::ObjectValue* prototype = ov->prototype(context); + const ObjectValue* prototype = ov->prototype(context); - const Interpreter::QmlObjectValue * qmlObjectValue = dynamic_cast<const Interpreter::QmlObjectValue *>(prototype); + const QmlObjectValue * qmlObjectValue = dynamic_cast<const QmlObjectValue *>(prototype); if (qmlObjectValue) { list << getQmlTypes(qmlObjectValue, context); @@ -358,13 +358,13 @@ public: private: NodeMetaInfoPrivate(Model *model, QString type, int maj = -1, int min = -1); - const QmlJS::Interpreter::QmlObjectValue *getQmlObjectValue() const; - const QmlJS::Interpreter::ObjectValue *getObjectValue() const; + const QmlJS::QmlObjectValue *getQmlObjectValue() const; + const QmlJS::ObjectValue *getObjectValue() const; void setupPropertyInfo(QList<PropertyInfo> propertyInfos); void setupLocalPropertyInfo(QList<PropertyInfo> propertyInfos); QString lookupName() const; QStringList lookupNameComponent() const; - const QmlJS::Interpreter::QmlObjectValue *getNearestQmlObjectValue() const; + const QmlJS::QmlObjectValue *getNearestQmlObjectValue() const; QString fullQualifiedImportAliasType() const; QString m_qualfiedTypeName; @@ -381,7 +381,7 @@ private: QSet<QString> m_prototypeCacheNegatives; //storing the pointer would not be save - QmlJS::Interpreter::ContextPtr context() const; + QmlJS::ContextPtr context() const; QmlJS::Document *document() const; QPointer<Model> m_model; @@ -424,7 +424,7 @@ NodeMetaInfoPrivate::NodeMetaInfoPrivate(Model *model, QString type, int maj, in m_model(model) { if (context()) { - const Interpreter::QmlObjectValue *objectValue = getQmlObjectValue(); + const QmlObjectValue *objectValue = getQmlObjectValue(); if (objectValue) { setupPropertyInfo(getTypes(objectValue, context())); setupLocalPropertyInfo(getTypes(objectValue, context(), true)); @@ -432,9 +432,9 @@ NodeMetaInfoPrivate::NodeMetaInfoPrivate(Model *model, QString type, int maj, in setupPrototypes(); m_isValid = true; } else { - const Interpreter::ObjectValue *objectValue = getObjectValue(); + const ObjectValue *objectValue = getObjectValue(); if (objectValue) { - const Interpreter::QmlObjectValue *qmlValue = dynamic_cast<const Interpreter::QmlObjectValue *>(objectValue); + const QmlObjectValue *qmlValue = dynamic_cast<const QmlObjectValue *>(objectValue); if (qmlValue) { m_majorVersion = qmlValue->version().majorVersion(); m_minorVersion = qmlValue->version().minorVersion(); @@ -464,9 +464,9 @@ static inline QString getUrlFromType(const QString& typeName) return result; } -const QmlJS::Interpreter::QmlObjectValue *NodeMetaInfoPrivate::getQmlObjectValue() const +const QmlJS::QmlObjectValue *NodeMetaInfoPrivate::getQmlObjectValue() const { - QmlJS::Interpreter::QmlObjectValue * value = context()->valueOwner()->cppQmlTypes().typeByQualifiedName(lookupName()); + QmlJS::QmlObjectValue * value = context()->valueOwner()->cppQmlTypes().typeByQualifiedName(lookupName()); if (value) return value; @@ -490,14 +490,14 @@ const QmlJS::Interpreter::QmlObjectValue *NodeMetaInfoPrivate::getQmlObjectValue LanguageUtils::ComponentVersion version(9999, 9999); //get the correct version - Interpreter::ImportInfo importInfo = context()->imports(document())->info(fullQualifiedImportAliasType(), context().data()); + ImportInfo importInfo = context()->imports(document())->info(fullQualifiedImportAliasType(), context().data()); if (importInfo.isValid()) version = importInfo.version(); - QList<Interpreter::QmlObjectValue *> qmlObjectValues = context()->valueOwner()->cppQmlTypes().typesForImport(package, version); - const Interpreter::QmlObjectValue *qmlValue = 0; - foreach (Interpreter::QmlObjectValue *value, qmlObjectValues) { + QList<QmlObjectValue *> qmlObjectValues = context()->valueOwner()->cppQmlTypes().typesForImport(package, version); + const QmlObjectValue *qmlValue = 0; + foreach (QmlObjectValue *value, qmlObjectValues) { if (value->className() == type) qmlValue = value; } @@ -521,17 +521,17 @@ const QmlJS::Interpreter::QmlObjectValue *NodeMetaInfoPrivate::getQmlObjectValue return qmlValue; } -const QmlJS::Interpreter::ObjectValue *NodeMetaInfoPrivate::getObjectValue() const +const QmlJS::ObjectValue *NodeMetaInfoPrivate::getObjectValue() const { return context()->lookupType(document(), lookupNameComponent()); } -QmlJS::Interpreter::ContextPtr NodeMetaInfoPrivate::context() const +QmlJS::ContextPtr NodeMetaInfoPrivate::context() const { if (m_model && m_model->rewriterView()) { return m_model->rewriterView()->scopeChain().context(); } - return QmlJS::Interpreter::ContextPtr(0); + return QmlJS::ContextPtr(0); } QmlJS::Document *NodeMetaInfoPrivate::document() const @@ -579,7 +579,7 @@ bool NodeMetaInfoPrivate::isPropertyWritable(const QString &propertyName) const return true; } - const QmlJS::Interpreter::QmlObjectValue *qmlObjectValue = getNearestQmlObjectValue(); + const QmlJS::QmlObjectValue *qmlObjectValue = getNearestQmlObjectValue(); if (!qmlObjectValue) return true; if (qmlObjectValue->hasProperty(propertyName)) @@ -611,7 +611,7 @@ bool NodeMetaInfoPrivate::isPropertyList(const QString &propertyName) const return true; } - const QmlJS::Interpreter::QmlObjectValue *qmlObjectValue = getNearestQmlObjectValue(); + const QmlJS::QmlObjectValue *qmlObjectValue = getNearestQmlObjectValue(); if (!qmlObjectValue) return false; return qmlObjectValue->isListProperty(propertyName); @@ -639,7 +639,7 @@ bool NodeMetaInfoPrivate::isPropertyPointer(const QString &propertyName) const return true; } - const QmlJS::Interpreter::QmlObjectValue *qmlObjectValue = getNearestQmlObjectValue(); + const QmlJS::QmlObjectValue *qmlObjectValue = getNearestQmlObjectValue(); if (!qmlObjectValue) return false; return qmlObjectValue->isPointer(propertyName); @@ -667,12 +667,12 @@ bool NodeMetaInfoPrivate::isPropertyEnum(const QString &propertyName) const return false; } - QList<const Interpreter::ObjectValue *> objects; - objects = Interpreter::PrototypeIterator(getNearestQmlObjectValue(), context()).all(); + QList<const ObjectValue *> objects; + objects = PrototypeIterator(getNearestQmlObjectValue(), context()).all(); //We have to run the prototype chain - foreach (const Interpreter::ObjectValue *ov, objects) { - if (const Interpreter::QmlObjectValue * qmlValue = dynamic_cast<const Interpreter::QmlObjectValue *>(ov)) { + foreach (const ObjectValue *ov, objects) { + if (const QmlObjectValue * qmlValue = dynamic_cast<const QmlObjectValue *>(ov)) { if (qmlValue->getEnum(propertyType(propertyName)).isValid()) return true; } @@ -703,12 +703,12 @@ QString NodeMetaInfoPrivate::propertyEnumScope(const QString &propertyName) cons return QString(); } - QList<const Interpreter::ObjectValue *> objects; - objects = Interpreter::PrototypeIterator(getNearestQmlObjectValue(), context()).all(); + QList<const ObjectValue *> objects; + objects = PrototypeIterator(getNearestQmlObjectValue(), context()).all(); //We have to run the prototype chain - foreach (const Interpreter::ObjectValue *ov, objects) { - if (const Interpreter::QmlObjectValue * qmlValue = dynamic_cast<const Interpreter::QmlObjectValue *>(ov)) { + foreach (const ObjectValue *ov, objects) { + if (const QmlObjectValue * qmlValue = dynamic_cast<const QmlObjectValue *>(ov)) { if (qmlValue->getEnum(propertyType(propertyName)).isValid()) return qmlValue->className(); } @@ -797,7 +797,7 @@ QString NodeMetaInfoPrivate::packageName() const QString NodeMetaInfoPrivate::componentSource() const { if (isComponent()) { - const Interpreter::ASTObjectValue * astObjectValue = dynamic_cast<const Interpreter::ASTObjectValue *>(getObjectValue()); + const ASTObjectValue * astObjectValue = dynamic_cast<const ASTObjectValue *>(getObjectValue()); if (astObjectValue) return astObjectValue->document()->source().mid(astObjectValue->typeName()->identifierToken.begin(), astObjectValue->initializer()->rbraceToken.end()); @@ -808,7 +808,7 @@ QString NodeMetaInfoPrivate::componentSource() const QString NodeMetaInfoPrivate::componentFileName() const { if (isComponent()) { - const Interpreter::ASTObjectValue * astObjectValue = dynamic_cast<const Interpreter::ASTObjectValue *>(getObjectValue()); + const ASTObjectValue * astObjectValue = dynamic_cast<const ASTObjectValue *>(getObjectValue()); if (astObjectValue) { QString fileName; int line; @@ -832,7 +832,7 @@ QString NodeMetaInfoPrivate::lookupName() const packageName = packageClassName.join(QLatin1String(".")); } - return Interpreter::CppQmlTypes::qualifiedName( + return CppQmlTypes::qualifiedName( packageName, className, LanguageUtils::ComponentVersion(m_majorVersion, m_minorVersion)); @@ -859,17 +859,17 @@ QString NodeMetaInfoPrivate::propertyType(const QString &propertyName) const void NodeMetaInfoPrivate::setupPrototypes() { - QList<const Interpreter::ObjectValue *> objects; + QList<const ObjectValue *> objects; if (m_isComponent) - objects = Interpreter::PrototypeIterator(getObjectValue(), context()).all(); + objects = PrototypeIterator(getObjectValue(), context()).all(); else - objects = Interpreter::PrototypeIterator(getQmlObjectValue(), context()).all(); - foreach (const Interpreter::ObjectValue *ov, objects) { + objects = PrototypeIterator(getQmlObjectValue(), context()).all(); + foreach (const ObjectValue *ov, objects) { TypeDescription description; description.className = ov->className(); description.minorVersion = -1; description.majorVersion = -1; - if (const Interpreter::QmlObjectValue * qmlValue = dynamic_cast<const Interpreter::QmlObjectValue *>(ov)) { + if (const QmlObjectValue * qmlValue = dynamic_cast<const QmlObjectValue *>(ov)) { description.minorVersion = qmlValue->version().minorVersion(); description.majorVersion = qmlValue->version().majorVersion(); if (!qmlValue->packageName().isEmpty()) @@ -888,7 +888,7 @@ QList<TypeDescription> NodeMetaInfoPrivate::prototypes() const return m_prototypes; } -const QmlJS::Interpreter::QmlObjectValue *NodeMetaInfoPrivate::getNearestQmlObjectValue() const +const QmlJS::QmlObjectValue *NodeMetaInfoPrivate::getNearestQmlObjectValue() const { if (m_isComponent) return findQmlPrototype(getObjectValue(), context()); diff --git a/src/plugins/qmldesigner/designercore/model/rewriterview.cpp b/src/plugins/qmldesigner/designercore/model/rewriterview.cpp index 095135a0f7..e3e5f7b6e1 100644 --- a/src/plugins/qmldesigner/designercore/model/rewriterview.cpp +++ b/src/plugins/qmldesigner/designercore/model/rewriterview.cpp @@ -624,7 +624,7 @@ bool RewriterView::renameId(const QString& oldId, const QString& newId) return false; } -const QmlJS::Interpreter::ScopeChain &RewriterView::scopeChain() const +const QmlJS::ScopeChain &RewriterView::scopeChain() const { return textToModelMerger()->scopeChain(); } diff --git a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp index eab0799b90..110cdd5fe0 100644 --- a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp +++ b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp @@ -357,10 +357,10 @@ public: void lookup(UiQualifiedId *astTypeNode, QString &typeName, int &majorVersion, int &minorVersion, QString &defaultPropertyName) { - const Interpreter::ObjectValue *value = m_context->lookupType(m_doc.data(), astTypeNode); + const ObjectValue *value = m_context->lookupType(m_doc.data(), astTypeNode); defaultPropertyName = m_context->defaultPropertyName(value); - const Interpreter::QmlObjectValue * qmlValue = dynamic_cast<const Interpreter::QmlObjectValue *>(value); + const QmlObjectValue * qmlValue = dynamic_cast<const QmlObjectValue *>(value); if (qmlValue) { typeName = fixUpPackeNameForQt(qmlValue->packageName()) + QLatin1String(".") + qmlValue->className(); @@ -383,14 +383,14 @@ public: majorVersion = ComponentVersion::NoVersion; minorVersion = ComponentVersion::NoVersion; - const Interpreter::Imports *imports = m_context->imports(m_doc.data()); - Interpreter::ImportInfo importInfo = imports->info(fullTypeName, m_context.data()); - if (importInfo.isValid() && importInfo.type() == Interpreter::ImportInfo::LibraryImport) { + const Imports *imports = m_context->imports(m_doc.data()); + ImportInfo importInfo = imports->info(fullTypeName, m_context.data()); + if (importInfo.isValid() && importInfo.type() == ImportInfo::LibraryImport) { QString name = importInfo.name().replace("\\", "."); majorVersion = importInfo.version().majorVersion(); minorVersion = importInfo.version().minorVersion(); typeName.prepend(name + "."); - } else if (importInfo.isValid() && importInfo.type() == Interpreter::ImportInfo::DirectoryImport) { + } else if (importInfo.isValid() && importInfo.type() == ImportInfo::DirectoryImport) { QString path = importInfo.name(); QDir dir(m_doc->path()); QString relativeDir = dir.relativeFilePath(path); @@ -404,9 +404,9 @@ public: /// When something is changed here, also change Check::checkScopeObjectMember in /// qmljscheck.cpp /// ### Maybe put this into the context as a helper method. - bool lookupProperty(const QString &prefix, const UiQualifiedId *id, const Interpreter::Value **property = 0, const Interpreter::ObjectValue **parentObject = 0, QString *name = 0) + bool lookupProperty(const QString &prefix, const UiQualifiedId *id, const Value **property = 0, const ObjectValue **parentObject = 0, QString *name = 0) { - QList<const Interpreter::ObjectValue *> scopeObjects = m_scopeChain.qmlScopeObjects(); + QList<const ObjectValue *> scopeObjects = m_scopeChain.qmlScopeObjects(); if (scopeObjects.isEmpty()) return false; @@ -432,7 +432,7 @@ public: bool isAttachedProperty = false; if (! propertyName.isEmpty() && propertyName[0].isUpper()) { isAttachedProperty = true; - if (const Interpreter::ObjectValue *qmlTypes = m_scopeChain.qmlTypes()) + if (const ObjectValue *qmlTypes = m_scopeChain.qmlTypes()) scopeObjects += qmlTypes; } @@ -440,8 +440,8 @@ public: return false; // global lookup for first part of id - const Interpreter::ObjectValue *objectValue = 0; - const Interpreter::Value *value = 0; + const ObjectValue *objectValue = 0; + const Value *value = 0; for (int i = scopeObjects.size() - 1; i >= 0; --i) { objectValue = scopeObjects[i]; value = objectValue->lookupMember(propertyName, m_context); @@ -460,7 +460,7 @@ public: return false; // resolve references - if (const Interpreter::Reference *ref = value->asReference()) + if (const Reference *ref = value->asReference()) value = m_context->lookupReference(ref); // member lookup @@ -468,7 +468,7 @@ public: if (prefix.isEmpty()) idPart = idPart->next; for (; idPart; idPart = idPart->next) { - objectValue = Interpreter::value_cast<const Interpreter::ObjectValue *>(value); + objectValue = value_cast<const ObjectValue *>(value); if (! objectValue) { // if (idPart->name) // qDebug() << idPart->name->asString() << "has no property named" @@ -503,20 +503,20 @@ public: return true; } - bool isArrayProperty(const Interpreter::Value *value, const Interpreter::ObjectValue *containingObject, const QString &name) + bool isArrayProperty(const Value *value, const ObjectValue *containingObject, const QString &name) { if (!value) return false; - const Interpreter::ObjectValue *objectValue = value->asObjectValue(); + const ObjectValue *objectValue = value->asObjectValue(); if (objectValue && objectValue->prototype(m_context) == m_context->valueOwner()->arrayPrototype()) return true; - Interpreter::PrototypeIterator iter(containingObject, m_context); + PrototypeIterator iter(containingObject, m_context); while (iter.hasNext()) { - const Interpreter::ObjectValue *proto = iter.next(); + const ObjectValue *proto = iter.next(); if (proto->lookupMember(name, m_context) == m_context->valueOwner()->arrayPrototype()) return true; - if (const Interpreter::QmlObjectValue *qmlIter = dynamic_cast<const Interpreter::QmlObjectValue *>(proto)) { + if (const QmlObjectValue *qmlIter = dynamic_cast<const QmlObjectValue *>(proto)) { if (qmlIter->isListProperty(name)) return true; } @@ -528,8 +528,8 @@ public: { const bool hasQuotes = astValue.trimmed().left(1) == QLatin1String("\"") && astValue.trimmed().right(1) == QLatin1String("\""); const QString cleanedValue = fixEscapedUnicodeChar(deEscape(stripQuotes(astValue.trimmed()))); - const Interpreter::Value *property = 0; - const Interpreter::ObjectValue *containingObject = 0; + const Value *property = 0; + const ObjectValue *containingObject = 0; QString name; if (!lookupProperty(propertyPrefix, propertyId, &property, &containingObject, &name)) { qWarning() << "Unknown property" << propertyPrefix + QLatin1Char('.') + flatten(propertyId) @@ -541,7 +541,7 @@ public: if (containingObject) containingObject->lookupMember(name, m_context, &containingObject); - if (const Interpreter::QmlObjectValue * qmlObject = dynamic_cast<const Interpreter::QmlObjectValue *>(containingObject)) { + if (const QmlObjectValue * qmlObject = dynamic_cast<const QmlObjectValue *>(containingObject)) { const QString typeName = qmlObject->propertyType(name); if (qmlObject->getEnum(typeName).isValid()) { return QVariant(cleanedValue); @@ -577,7 +577,7 @@ public: if (!eStmt || !eStmt->expression) return QVariant(); - const Interpreter::ObjectValue *containingObject = 0; + const ObjectValue *containingObject = 0; QString name; if (!lookupProperty(propertyPrefix, propertyId, 0, &containingObject, &name)) { return QVariant(); @@ -585,12 +585,12 @@ public: if (containingObject) containingObject->lookupMember(name, m_context, &containingObject); - const Interpreter::QmlObjectValue * lhsQmlObject = dynamic_cast<const Interpreter::QmlObjectValue *>(containingObject); + const QmlObjectValue * lhsQmlObject = dynamic_cast<const QmlObjectValue *>(containingObject); if (!lhsQmlObject) return QVariant(); const QString lhsPropertyTypeName = lhsQmlObject->propertyType(name); - const Interpreter::ObjectValue *rhsValueObject = 0; + const ObjectValue *rhsValueObject = 0; QString rhsValueName; if (IdentifierExpression *idExp = cast<IdentifierExpression *>(eStmt->expression)) { if (!m_scopeChain.qmlScopeObjects().isEmpty()) @@ -599,7 +599,7 @@ public: rhsValueName = idExp->name->asString(); } else if (FieldMemberExpression *memberExp = cast<FieldMemberExpression *>(eStmt->expression)) { Evaluate evaluate(&m_scopeChain); - const Interpreter::Value *result = evaluate(memberExp->base); + const Value *result = evaluate(memberExp->base); rhsValueObject = result->asObjectValue(); if (memberExp->name) @@ -609,7 +609,7 @@ public: if (rhsValueObject) rhsValueObject->lookupMember(rhsValueName, m_context, &rhsValueObject); - const Interpreter::QmlObjectValue *rhsQmlObjectValue = dynamic_cast<const Interpreter::QmlObjectValue *>(rhsValueObject); + const QmlObjectValue *rhsQmlObjectValue = dynamic_cast<const QmlObjectValue *>(rhsValueObject); if (!rhsQmlObjectValue) return QVariant(); @@ -620,7 +620,7 @@ public: } - const Interpreter::ScopeChain &scopeChain() const + const ScopeChain &scopeChain() const { return m_scopeChain; } QList<DiagnosticMessage> diagnosticLinkMessages() const @@ -631,8 +631,8 @@ private: Document::Ptr m_doc; Link m_link; QList<DiagnosticMessage> m_diagnosticLinkMessages; - Interpreter::ContextPtr m_context; - Interpreter::ScopeChain m_scopeChain; + ContextPtr m_context; + ScopeChain m_scopeChain; ScopeBuilder m_scopeBuilder; }; @@ -764,8 +764,8 @@ bool TextToModelMerger::load(const QString &data, DifferenceHandler &differenceH } snapshot.insert(doc); ReadingContext ctxt(snapshot, doc, importPaths); - m_scopeChain = QSharedPointer<const Interpreter::ScopeChain>( - new Interpreter::ScopeChain(ctxt.scopeChain())); + m_scopeChain = QSharedPointer<const ScopeChain>( + new ScopeChain(ctxt.scopeChain())); m_document = doc; QList<RewriterView::Error> errors; @@ -927,8 +927,8 @@ void TextToModelMerger::syncNode(ModelNode &modelNode, if (binding->hasOnToken) { // skip value sources } else { - const Interpreter::Value *propertyType = 0; - const Interpreter::ObjectValue *containingObject = 0; + const Value *propertyType = 0; + const ObjectValue *containingObject = 0; QString name; if (context->lookupProperty(QString(), binding->qualifiedId, &propertyType, &containingObject, &name) || isPropertyChangesType(typeName)) { AbstractProperty modelProperty = modelNode.property(astPropertyName); diff --git a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.h b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.h index 939825fb60..92b298dfd5 100644 --- a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.h +++ b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.h @@ -68,7 +68,7 @@ public: RewriterView *view() const { return m_rewriterView; } - const QmlJS::Interpreter::ScopeChain &scopeChain() const + const QmlJS::ScopeChain &scopeChain() const { return *m_scopeChain; } QmlJS::Document *document() const @@ -140,7 +140,7 @@ private: private: RewriterView *m_rewriterView; bool m_isActive; - QSharedPointer<const QmlJS::Interpreter::ScopeChain> m_scopeChain; + QSharedPointer<const QmlJS::ScopeChain> m_scopeChain; QmlJS::Document::Ptr m_document; QTimer m_setupTimer; QSet<ModelNode> m_setupComponentList; diff --git a/src/plugins/qmldesigner/qmlcontextpane.cpp b/src/plugins/qmldesigner/qmlcontextpane.cpp index 447a69fbe3..fa1122059f 100644 --- a/src/plugins/qmldesigner/qmlcontextpane.cpp +++ b/src/plugins/qmldesigner/qmlcontextpane.cpp @@ -116,7 +116,7 @@ void QmlContextPane::apply(TextEditor::BaseTextEditorEditable *editor, Document: m_blockWriting = true; LookupContext::Ptr lookupContext = LookupContext::create(doc, snapshot, QList<Node*>()); - const Interpreter::ObjectValue *scopeObject = doc->bind()->findQmlObject(node); + const ObjectValue *scopeObject = doc->bind()->findQmlObject(node); QStringList prototypes; while (scopeObject) { @@ -213,7 +213,7 @@ bool QmlContextPane::isAvailable(TextEditor::BaseTextEditorEditable *, Document: return false; LookupContext::Ptr lookupContext = LookupContext::create(doc, snapshot, QList<Node*>()); - const Interpreter::ObjectValue *scopeObject = doc->bind()->findQmlObject(node); + const ObjectValue *scopeObject = doc->bind()->findQmlObject(node); QStringList prototypes; diff --git a/src/plugins/qmljseditor/qmljscompletionassist.cpp b/src/plugins/qmljseditor/qmljscompletionassist.cpp index 8ce9da59a1..8a775699ff 100644 --- a/src/plugins/qmljseditor/qmljscompletionassist.cpp +++ b/src/plugins/qmljseditor/qmljscompletionassist.cpp @@ -79,18 +79,18 @@ enum CompletionOrder { TypeOrder = -30 }; -class EnumerateProperties: private Interpreter::MemberProcessor +class EnumerateProperties: private MemberProcessor { - QSet<const Interpreter::ObjectValue *> _processed; - QHash<QString, const Interpreter::Value *> _properties; + QSet<const ObjectValue *> _processed; + QHash<QString, const Value *> _properties; bool _globalCompletion; bool _enumerateGeneratedSlots; bool _enumerateSlots; - const Interpreter::ScopeChain *_scopeChain; - const Interpreter::ObjectValue *_currentObject; + const ScopeChain *_scopeChain; + const ObjectValue *_currentObject; public: - EnumerateProperties(const Interpreter::ScopeChain *scopeChain) + EnumerateProperties(const ScopeChain *scopeChain) : _globalCompletion(false), _enumerateGeneratedSlots(false), _enumerateSlots(true), @@ -114,61 +114,61 @@ public: _enumerateSlots = enumerate; } - QHash<QString, const Interpreter::Value *> operator ()(const Interpreter::Value *value) + QHash<QString, const Value *> operator ()(const Value *value) { _processed.clear(); _properties.clear(); - _currentObject = Interpreter::value_cast<const Interpreter::ObjectValue *>(value); + _currentObject = value_cast<const ObjectValue *>(value); enumerateProperties(value); return _properties; } - QHash<QString, const Interpreter::Value *> operator ()() + QHash<QString, const Value *> operator ()() { _processed.clear(); _properties.clear(); _currentObject = 0; - foreach (const Interpreter::ObjectValue *scope, _scopeChain->all()) + foreach (const ObjectValue *scope, _scopeChain->all()) enumerateProperties(scope); return _properties; } private: - void insertProperty(const QString &name, const Interpreter::Value *value) + void insertProperty(const QString &name, const Value *value) { _properties.insert(name, value); } - virtual bool processProperty(const QString &name, const Interpreter::Value *value) + virtual bool processProperty(const QString &name, const Value *value) { insertProperty(name, value); return true; } - virtual bool processEnumerator(const QString &name, const Interpreter::Value *value) + virtual bool processEnumerator(const QString &name, const Value *value) { if (! _globalCompletion) insertProperty(name, value); return true; } - virtual bool processSignal(const QString &, const Interpreter::Value *) + virtual bool processSignal(const QString &, const Value *) { return true; } - virtual bool processSlot(const QString &name, const Interpreter::Value *value) + virtual bool processSlot(const QString &name, const Value *value) { if (_enumerateSlots) insertProperty(name, value); return true; } - virtual bool processGeneratedSlot(const QString &name, const Interpreter::Value *value) + virtual bool processGeneratedSlot(const QString &name, const Value *value) { if (_enumerateGeneratedSlots || (_currentObject && _currentObject->className().endsWith(QLatin1String("Keys")))) { // ### FIXME: add support for attached properties. @@ -177,16 +177,16 @@ private: return true; } - void enumerateProperties(const Interpreter::Value *value) + void enumerateProperties(const Value *value) { if (! value) return; - else if (const Interpreter::ObjectValue *object = value->asObjectValue()) { + else if (const ObjectValue *object = value->asObjectValue()) { enumerateProperties(object); } } - void enumerateProperties(const Interpreter::ObjectValue *object) + void enumerateProperties(const ObjectValue *object) { if (! object || _processed.contains(object)) return; @@ -198,16 +198,16 @@ private: } }; -const Interpreter::Value *getPropertyValue(const Interpreter::ObjectValue *object, +const Value *getPropertyValue(const ObjectValue *object, const QStringList &propertyNames, - const Interpreter::ContextPtr &context) + const ContextPtr &context) { if (propertyNames.isEmpty() || !object) return 0; - const Interpreter::Value *value = object; + const Value *value = object; foreach (const QString &name, propertyNames) { - if (const Interpreter::ObjectValue *objectValue = value->asObjectValue()) { + if (const ObjectValue *objectValue = value->asObjectValue()) { value = objectValue->lookupMember(name, context); if (!value) return 0; @@ -420,8 +420,8 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const IAssistInterface isQmlFile = true; const QList<AST::Node *> path = semanticInfo.rangePath(m_interface->position()); - const Interpreter::ContextPtr &context = semanticInfo.context; - const Interpreter::ScopeChain &scopeChain = semanticInfo.scopeChain(path); + const ContextPtr &context = semanticInfo.context; + const ScopeChain &scopeChain = semanticInfo.scopeChain(path); // Search for the operator that triggered the completion. QChar completionOperator; @@ -432,7 +432,7 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const IAssistInterface startPositionCursor.setPosition(m_startPosition); CompletionContextFinder contextFinder(startPositionCursor); - const Interpreter::ObjectValue *qmlScopeType = 0; + const ObjectValue *qmlScopeType = 0; if (contextFinder.isInQmlContext()) { // find the enclosing qml object // ### this should use semanticInfo.declaringMember instead, but that may also return functions @@ -450,15 +450,15 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const IAssistInterface AST::UiObjectDefinition *objDef = AST::cast<AST::UiObjectDefinition *>(path[i]); if (!objDef || !document->bind()->isGroupedPropertyBinding(objDef)) break; - const Interpreter::ObjectValue *newScopeType = qmlScopeType; + const ObjectValue *newScopeType = qmlScopeType; for (AST::UiQualifiedId *it = objDef->qualifiedTypeNameId; it; it = it->next) { if (!newScopeType || !it->name) { newScopeType = 0; break; } - const Interpreter::Value *v = newScopeType->lookupMember(it->name->asString(), context); + const Value *v = newScopeType->lookupMember(it->name->asString(), context); v = context->lookupReference(v); - newScopeType = Interpreter::value_cast<const Interpreter::ObjectValue *>(v); + newScopeType = value_cast<const ObjectValue *>(v); } if (!newScopeType) break; @@ -490,7 +490,7 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const IAssistInterface return 0; } - const Interpreter::Value *value = + const Value *value = getPropertyValue(qmlScopeType, contextFinder.bindingPropertyName(), context); if (!value) { // do nothing @@ -550,10 +550,10 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const IAssistInterface doQmlKeywordCompletion = false; // complete enum values for enum properties - const Interpreter::Value *value = + const Value *value = getPropertyValue(qmlScopeType, contextFinder.bindingPropertyName(), context); - if (const Interpreter::QmlEnumValue *enumValue = - dynamic_cast<const Interpreter::QmlEnumValue *>(value)) { + if (const QmlEnumValue *enumValue = + dynamic_cast<const QmlEnumValue *>(value)) { foreach (const QString &key, enumValue->keys()) addCompletion(key, m_interface->symbolIcon(), EnumValueOrder, QString("\"%1\"").arg(key)); @@ -564,7 +564,7 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const IAssistInterface doQmlTypeCompletion = true; if (doQmlTypeCompletion) { - if (const Interpreter::ObjectValue *qmlTypes = scopeChain.qmlTypes()) { + if (const ObjectValue *qmlTypes = scopeChain.qmlTypes()) { EnumerateProperties enumerateProperties(&scopeChain); addCompletions(enumerateProperties(qmlTypes), m_interface->symbolIcon(), TypeOrder); } @@ -613,8 +613,8 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const IAssistInterface if (expression != 0 && ! isLiteral(expression)) { // Evaluate the expression under cursor. - Interpreter::ValueOwner *interp = context->valueOwner(); - const Interpreter::Value *value = + ValueOwner *interp = context->valueOwner(); + const Value *value = interp->convertToObject(scopeChain.evaluate(expression)); //qDebug() << "type:" << interp->typeId(value); @@ -632,7 +632,7 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const IAssistInterface && completionOperator == QLatin1Char('(') && m_startPosition == m_interface->position()) { // function completion - if (const Interpreter::FunctionValue *f = value->asFunctionValue()) { + if (const FunctionValue *f = value->asFunctionValue()) { QString functionName = expressionUnderCursor.text(); int indexOfDot = functionName.lastIndexOf(QLatin1Char('.')); if (indexOfDot != -1) @@ -767,12 +767,12 @@ bool QmlJSCompletionAssistProcessor::completeUrl(const QString &relativeBasePath } void QmlJSCompletionAssistProcessor::addCompletionsPropertyLhs(const QHash<QString, - const QmlJS::Interpreter::Value *> &newCompletions, + const QmlJS::Value *> &newCompletions, const QIcon &icon, int order, bool afterOn) { - QHashIterator<QString, const Interpreter::Value *> it(newCompletions); + QHashIterator<QString, const Value *> it(newCompletions); while (it.hasNext()) { it.next(); @@ -782,8 +782,8 @@ void QmlJSCompletionAssistProcessor::addCompletionsPropertyLhs(const QHash<QStri postfix = QLatin1String(": "); if (afterOn) postfix = QLatin1String(" {"); - if (const Interpreter::QmlObjectValue *qmlValue = - dynamic_cast<const Interpreter::QmlObjectValue *>(it.value())) { + if (const QmlObjectValue *qmlValue = + dynamic_cast<const QmlObjectValue *>(it.value())) { // to distinguish "anchors." from "gradient:" we check if the right hand side // type is instantiatable or is the prototype of an instantiatable object if (qmlValue->hasChildInPackage()) @@ -815,11 +815,11 @@ void QmlJSCompletionAssistProcessor::addCompletion(const QString &text, } void QmlJSCompletionAssistProcessor::addCompletions(const QHash<QString, - const QmlJS::Interpreter::Value *> &newCompletions, + const QmlJS::Value *> &newCompletions, const QIcon &icon, int order) { - QHashIterator<QString, const Interpreter::Value *> it(newCompletions); + QHashIterator<QString, const Value *> it(newCompletions); while (it.hasNext()) { it.next(); addCompletion(it.key(), icon, order); diff --git a/src/plugins/qmljseditor/qmljscompletionassist.h b/src/plugins/qmljseditor/qmljscompletionassist.h index a56b674989..bf7ed02bda 100644 --- a/src/plugins/qmljseditor/qmljscompletionassist.h +++ b/src/plugins/qmljseditor/qmljscompletionassist.h @@ -48,10 +48,8 @@ #include <QtGui/QIcon> namespace QmlJS { -namespace Interpreter { class Value; } -} namespace QmlJSEditor { namespace Internal { @@ -115,12 +113,12 @@ private: const QIcon &icon, int order, const QVariant &data = QVariant()); - void addCompletions(const QHash<QString, const QmlJS::Interpreter::Value *> &newCompletions, + void addCompletions(const QHash<QString, const QmlJS::Value *> &newCompletions, const QIcon &icon, int order); void addCompletions(const QStringList &newCompletions, const QIcon &icon, int order); void addCompletionsPropertyLhs(const QHash<QString, - const QmlJS::Interpreter::Value *> &newCompletions, + const QmlJS::Value *> &newCompletions, const QIcon &icon, int order, bool afterOn); diff --git a/src/plugins/qmljseditor/qmljseditor.cpp b/src/plugins/qmljseditor/qmljseditor.cpp index 6ba4c67428..1476193d1f 100644 --- a/src/plugins/qmljseditor/qmljseditor.cpp +++ b/src/plugins/qmljseditor/qmljseditor.cpp @@ -547,14 +547,14 @@ QList<AST::Node *> SemanticInfo::rangePath(int cursorPosition) const return path; } -Interpreter::ScopeChain SemanticInfo::scopeChain(const QList<QmlJS::AST::Node *> &path) const +ScopeChain SemanticInfo::scopeChain(const QList<QmlJS::AST::Node *> &path) const { Q_ASSERT(m_rootScopeChain); if (path.isEmpty()) return *m_rootScopeChain; - Interpreter::ScopeChain scope = *m_rootScopeChain; + ScopeChain scope = *m_rootScopeChain; ScopeBuilder builder(&scope); builder.push(path); return scope; @@ -573,7 +573,7 @@ AST::Node *SemanticInfo::nodeUnderCursor(int pos) const const unsigned cursorPosition = pos; - foreach (const Interpreter::ImportInfo &import, document->bind()->imports()) { + foreach (const ImportInfo &import, document->bind()->imports()) { if (importContainsCursor(import.ast(), cursorPosition)) return import.ast(); } @@ -1249,8 +1249,8 @@ TextEditor::BaseTextEditorWidget::Link QmlJSTextEditorWidget::findLinkAt(const Q if (AST::UiImport *importAst = cast<AST::UiImport *>(node)) { // if it's a file import, link to the file - foreach (const Interpreter::ImportInfo &import, semanticInfo.document->bind()->imports()) { - if (import.ast() == importAst && import.type() == Interpreter::ImportInfo::FileImport) { + foreach (const ImportInfo &import, semanticInfo.document->bind()->imports()) { + if (import.ast() == importAst && import.type() == ImportInfo::FileImport) { BaseTextEditorWidget::Link link(import.name()); link.begin = importAst->firstSourceLocation().begin(); link.end = importAst->lastSourceLocation().end(); @@ -1260,9 +1260,9 @@ TextEditor::BaseTextEditorWidget::Link QmlJSTextEditorWidget::findLinkAt(const Q return Link(); } - const Interpreter::ScopeChain scopeChain = semanticInfo.scopeChain(semanticInfo.rangePath(cursorPosition)); + const ScopeChain scopeChain = semanticInfo.scopeChain(semanticInfo.rangePath(cursorPosition)); Evaluate evaluator(&scopeChain); - const Interpreter::Value *value = evaluator.reference(node); + const Value *value = evaluator.reference(node); QString fileName; int line = 0, column = 0; @@ -1317,7 +1317,7 @@ void QmlJSTextEditorWidget::showContextPane() { if (m_contextPane && m_semanticInfo.isValid()) { Node *newNode = m_semanticInfo.declaringMemberNoProperties(position()); - Interpreter::ScopeChain scopeChain = m_semanticInfo.scopeChain(m_semanticInfo.rangePath(position())); + ScopeChain scopeChain = m_semanticInfo.scopeChain(m_semanticInfo.rangePath(position())); m_contextPane->apply(editor(), m_semanticInfo.document, &scopeChain, newNode, false, true); diff --git a/src/plugins/qmljseditor/qmljseditor.h b/src/plugins/qmljseditor/qmljseditor.h index 1384f39caa..31206b4481 100644 --- a/src/plugins/qmljseditor/qmljseditor.h +++ b/src/plugins/qmljseditor/qmljseditor.h @@ -118,12 +118,12 @@ public: QList<QmlJS::AST::Node *> rangePath(int cursorPosition) const; // Returns a scopeChain for the given path - QmlJS::Interpreter::ScopeChain scopeChain(const QList<QmlJS::AST::Node *> &path = QList<QmlJS::AST::Node *>()) const; + QmlJS::ScopeChain scopeChain(const QList<QmlJS::AST::Node *> &path = QList<QmlJS::AST::Node *>()) const; public: // attributes QmlJS::Document::Ptr document; QmlJS::Snapshot snapshot; - QmlJS::Interpreter::ContextPtr context; + QmlJS::ContextPtr context; QList<Range> ranges; QHash<QString, QList<QmlJS::AST::SourceLocation> > idLocations; QList<Declaration> declarations; @@ -132,7 +132,7 @@ public: // attributes QList<QmlJS::DiagnosticMessage> semanticMessages; private: - QSharedPointer<const QmlJS::Interpreter::ScopeChain> m_rootScopeChain; + QSharedPointer<const QmlJS::ScopeChain> m_rootScopeChain; friend class Internal::SemanticHighlighter; }; diff --git a/src/plugins/qmljseditor/qmljsfindreferences.cpp b/src/plugins/qmljseditor/qmljsfindreferences.cpp index 6f08d7a38d..974ea39511 100644 --- a/src/plugins/qmljseditor/qmljsfindreferences.cpp +++ b/src/plugins/qmljseditor/qmljsfindreferences.cpp @@ -65,7 +65,6 @@ #include <functional> using namespace QmlJS; -using namespace QmlJS::Interpreter; using namespace QmlJS::AST; using namespace QmlJSEditor; diff --git a/src/plugins/qmljseditor/qmljshoverhandler.cpp b/src/plugins/qmljseditor/qmljshoverhandler.cpp index 70b9cbf6a5..085c4c031d 100644 --- a/src/plugins/qmljseditor/qmljshoverhandler.cpp +++ b/src/plugins/qmljseditor/qmljshoverhandler.cpp @@ -55,7 +55,6 @@ using namespace Core; using namespace QmlJS; -using namespace QmlJS::Interpreter; using namespace QmlJSEditor; using namespace QmlJSEditor::Internal; @@ -175,7 +174,7 @@ bool HoverHandler::matchColorItem(const ScopeChain &scopeChain, return false; QString color; - const Interpreter::Value *value = 0; + const Value *value = 0; if (const AST::UiScriptBinding *binding = AST::cast<const AST::UiScriptBinding *>(member)) { if (binding->qualifiedId && posIsInSource(pos, binding->statement)) { value = scopeChain.evaluate(binding->qualifiedId); @@ -189,7 +188,7 @@ bool HoverHandler::matchColorItem(const ScopeChain &scopeChain, AST::cast<const AST::UiPublicMember *>(member)) { if (publicMember->name && posIsInSource(pos, publicMember->statement)) { value = scopeChain.lookup(publicMember->name->asString()); - if (const Interpreter::Reference *ref = value->asReference()) + if (const Reference *ref = value->asReference()) value = scopeChain.context()->lookupReference(ref); color = textAt(qmlDocument, publicMember->statement->firstSourceLocation(), @@ -215,20 +214,20 @@ void HoverHandler::handleOrdinaryMatch(const ScopeChain &scopeChain, AST::Node * { if (node && !(AST::cast<AST::StringLiteral *>(node) != 0 || AST::cast<AST::NumericLiteral *>(node) != 0)) { - const Interpreter::Value *value = scopeChain.evaluate(node); + const Value *value = scopeChain.evaluate(node); prettyPrintTooltip(value, scopeChain.context()); } } void HoverHandler::handleImport(const ScopeChain &scopeChain, AST::UiImport *node) { - const Interpreter::Imports *imports = scopeChain.context()->imports(scopeChain.document().data()); + const Imports *imports = scopeChain.context()->imports(scopeChain.document().data()); if (!imports) return; - foreach (const Interpreter::Import &import, imports->all()) { + foreach (const Import &import, imports->all()) { if (import.info.ast() == node) { - if (import.info.type() == Interpreter::ImportInfo::LibraryImport + if (import.info.type() == ImportInfo::LibraryImport && !import.libraryPath.isEmpty()) { QString msg = tr("Library at %1").arg(import.libraryPath); const LibraryInfo &libraryInfo = scopeChain.context()->snapshot().libraryInfo(import.libraryPath); @@ -270,16 +269,16 @@ void HoverHandler::operateTooltip(TextEditor::ITextEditor *editor, const QPoint } } -void HoverHandler::prettyPrintTooltip(const QmlJS::Interpreter::Value *value, - const QmlJS::Interpreter::ContextPtr &context) +void HoverHandler::prettyPrintTooltip(const QmlJS::Value *value, + const QmlJS::ContextPtr &context) { if (! value) return; - if (const Interpreter::ObjectValue *objectValue = value->asObjectValue()) { - Interpreter::PrototypeIterator iter(objectValue, context); + if (const ObjectValue *objectValue = value->asObjectValue()) { + PrototypeIterator iter(objectValue, context); while (iter.hasNext()) { - const Interpreter::ObjectValue *prototype = iter.next(); + const ObjectValue *prototype = iter.next(); const QString className = prototype->className(); if (! className.isEmpty()) { @@ -287,8 +286,8 @@ void HoverHandler::prettyPrintTooltip(const QmlJS::Interpreter::Value *value, break; } } - } else if (const Interpreter::QmlEnumValue *enumValue = - dynamic_cast<const Interpreter::QmlEnumValue *>(value)) { + } else if (const QmlEnumValue *enumValue = + dynamic_cast<const QmlEnumValue *>(value)) { setToolTip(enumValue->name()); } @@ -300,10 +299,10 @@ void HoverHandler::prettyPrintTooltip(const QmlJS::Interpreter::Value *value, } // if node refers to a property, its name and defining object are returned - otherwise zero -static const Interpreter::ObjectValue *isMember(const ScopeChain &scopeChain, +static const ObjectValue *isMember(const ScopeChain &scopeChain, AST::Node *node, QString *name) { - const Interpreter::ObjectValue *owningObject = 0; + const ObjectValue *owningObject = 0; if (AST::IdentifierExpression *identExp = AST::cast<AST::IdentifierExpression *>(node)) { if (!identExp->name) return 0; @@ -313,7 +312,7 @@ static const Interpreter::ObjectValue *isMember(const ScopeChain &scopeChain, if (!fme->base || !fme->name) return 0; *name = fme->name->asString(); - const Interpreter::Value *base = scopeChain.evaluate(fme->base); + const Value *base = scopeChain.evaluate(fme->base); if (!base) return 0; owningObject = base->asObjectValue(); @@ -323,11 +322,11 @@ static const Interpreter::ObjectValue *isMember(const ScopeChain &scopeChain, if (!qid->name) return 0; *name = qid->name->asString(); - const Interpreter::Value *value = scopeChain.lookup(*name, &owningObject); + const Value *value = scopeChain.lookup(*name, &owningObject); for (AST::UiQualifiedId *it = qid->next; it; it = it->next) { if (!value) return 0; - const Interpreter::ObjectValue *next = value->asObjectValue(); + const ObjectValue *next = value->asObjectValue(); if (!next || !it->name) return 0; *name = it->name->asString(); @@ -341,7 +340,7 @@ TextEditor::HelpItem HoverHandler::qmlHelpItem(const ScopeChain &scopeChain, AST::Node *node) const { QString name; - if (const Interpreter::ObjectValue *scope = isMember(scopeChain, node, &name)) { + if (const ObjectValue *scope = isMember(scopeChain, node, &name)) { // maybe it's a type? if (!name.isEmpty() && name.at(0).isUpper()) { const QString maybeHelpId(QLatin1String("QML.") + name); @@ -350,11 +349,11 @@ TextEditor::HelpItem HoverHandler::qmlHelpItem(const ScopeChain &scopeChain, } // otherwise, it's probably a property - const Interpreter::ObjectValue *lastScope; + const ObjectValue *lastScope; scope->lookupMember(name, scopeChain.context(), &lastScope); - Interpreter::PrototypeIterator iter(scope, scopeChain.context()); + PrototypeIterator iter(scope, scopeChain.context()); while (iter.hasNext()) { - const Interpreter::ObjectValue *cur = iter.next(); + const ObjectValue *cur = iter.next(); const QString className = cur->className(); if (!className.isEmpty()) { diff --git a/src/plugins/qmljseditor/qmljshoverhandler.h b/src/plugins/qmljseditor/qmljshoverhandler.h index 789e443fab..b817eee700 100644 --- a/src/plugins/qmljseditor/qmljshoverhandler.h +++ b/src/plugins/qmljseditor/qmljshoverhandler.h @@ -51,13 +51,11 @@ class ITextEditor; } namespace QmlJS { -namespace Interpreter { class ScopeChain; class Context; typedef QSharedPointer<const Context> ContextPtr; class Value; } -} namespace QmlJSEditor { class QmlJSTextEditorWidget; @@ -78,19 +76,19 @@ private: virtual void operateTooltip(TextEditor::ITextEditor *editor, const QPoint &point); bool matchDiagnosticMessage(QmlJSEditor::QmlJSTextEditorWidget *qmlEditor, int pos); - bool matchColorItem(const QmlJS::Interpreter::ScopeChain &lookupContext, + bool matchColorItem(const QmlJS::ScopeChain &lookupContext, const QmlJS::Document::Ptr &qmlDocument, const QList<QmlJS::AST::Node *> &astPath, unsigned pos); - void handleOrdinaryMatch(const QmlJS::Interpreter::ScopeChain &lookupContext, + void handleOrdinaryMatch(const QmlJS::ScopeChain &lookupContext, QmlJS::AST::Node *node); - void handleImport(const QmlJS::Interpreter::ScopeChain &lookupContext, + void handleImport(const QmlJS::ScopeChain &lookupContext, QmlJS::AST::UiImport *node); - void prettyPrintTooltip(const QmlJS::Interpreter::Value *value, - const QmlJS::Interpreter::ContextPtr &context); + void prettyPrintTooltip(const QmlJS::Value *value, + const QmlJS::ContextPtr &context); - TextEditor::HelpItem qmlHelpItem(const QmlJS::Interpreter::ScopeChain &lookupContext, + TextEditor::HelpItem qmlHelpItem(const QmlJS::ScopeChain &lookupContext, QmlJS::AST::Node *node) const; QmlJS::ModelManagerInterface *m_modelManager; diff --git a/src/plugins/qmljseditor/qmljssemantichighlighter.cpp b/src/plugins/qmljseditor/qmljssemantichighlighter.cpp index 32544d9565..ce327575b5 100644 --- a/src/plugins/qmljseditor/qmljssemantichighlighter.cpp +++ b/src/plugins/qmljseditor/qmljssemantichighlighter.cpp @@ -137,8 +137,8 @@ SemanticInfo SemanticHighlighter::semanticInfo(const SemanticHighlighterSource & QmlJS::Link link(snapshot, modelManager->importPaths(), modelManager->builtins(doc)); semanticInfo.context = link(doc, &semanticInfo.semanticMessages); - QmlJS::Interpreter::ScopeChain *scopeChain = new QmlJS::Interpreter::ScopeChain(doc, semanticInfo.context); - semanticInfo.m_rootScopeChain = QSharedPointer<const QmlJS::Interpreter::ScopeChain>(scopeChain); + QmlJS::ScopeChain *scopeChain = new QmlJS::ScopeChain(doc, semanticInfo.context); + semanticInfo.m_rootScopeChain = QSharedPointer<const QmlJS::ScopeChain>(scopeChain); QmlJS::Check checker(doc, semanticInfo.context); semanticInfo.semanticMessages.append(checker()); diff --git a/src/plugins/qmljseditor/qmloutlinemodel.cpp b/src/plugins/qmljseditor/qmloutlinemodel.cpp index 56974af0d5..63569ec622 100644 --- a/src/plugins/qmljseditor/qmloutlinemodel.cpp +++ b/src/plugins/qmljseditor/qmloutlinemodel.cpp @@ -72,8 +72,8 @@ QVariant QmlOutlineItem::data(int role) const return QVariant(); QList<AST::Node *> astPath = m_outlineModel->m_semanticInfo.rangePath(location.begin()); - Interpreter::ScopeChain scopeChain = m_outlineModel->m_semanticInfo.scopeChain(astPath); - const Interpreter::Value *value = scopeChain.evaluate(uiQualifiedId); + ScopeChain scopeChain = m_outlineModel->m_semanticInfo.scopeChain(astPath); + const Value *value = scopeChain.evaluate(uiQualifiedId); return prettyPrint(value, scopeChain.context()); } @@ -99,12 +99,12 @@ void QmlOutlineItem::setItemData(const QMap<int, QVariant> &roles) } } -QString QmlOutlineItem::prettyPrint(const Interpreter::Value *value, const Interpreter::ContextPtr &context) const +QString QmlOutlineItem::prettyPrint(const Value *value, const ContextPtr &context) const { if (! value) return QString(); - if (const Interpreter::ObjectValue *objectValue = value->asObjectValue()) { + if (const ObjectValue *objectValue = value->asObjectValue()) { const QString className = objectValue->className(); if (!className.isEmpty()) { return className; diff --git a/src/plugins/qmljseditor/qmloutlinemodel.h b/src/plugins/qmljseditor/qmloutlinemodel.h index c0cd9331a8..5cb885218f 100644 --- a/src/plugins/qmljseditor/qmloutlinemodel.h +++ b/src/plugins/qmljseditor/qmloutlinemodel.h @@ -41,11 +41,9 @@ #include <QtGui/QStandardItemModel> namespace QmlJS { -namespace Interpreter { class Value; class Context; } -} namespace QmlJSEditor { namespace Internal { @@ -64,7 +62,7 @@ public: void setItemData(const QMap<int, QVariant> &roles); private: - QString prettyPrint(const QmlJS::Interpreter::Value *value, const QmlJS::Interpreter::ContextPtr &context) const; + QString prettyPrint(const QmlJS::Value *value, const QmlJS::ContextPtr &context) const; QmlOutlineModel *m_outlineModel; }; diff --git a/src/plugins/qmljseditor/qmltaskmanager.cpp b/src/plugins/qmljseditor/qmltaskmanager.cpp index 3606147f16..df48b6bc32 100644 --- a/src/plugins/qmljseditor/qmltaskmanager.cpp +++ b/src/plugins/qmljseditor/qmltaskmanager.cpp @@ -73,7 +73,7 @@ void QmlTaskManager::collectMessages(QFutureInterface<FileErrorMessages> &future Snapshot snapshot, QStringList files, QStringList /*importPaths*/) { // ### link and check error messages are disabled for now: too many false-positives! - //Interpreter::Context ctx(snapshot); + //Context ctx(snapshot); //QHash<QString, QList<DiagnosticMessage> > linkMessages; //Link link(&ctx, snapshot, importPaths); //link(&linkMessages); diff --git a/src/plugins/qmljseditor/quicktoolbar.cpp b/src/plugins/qmljseditor/quicktoolbar.cpp index c2cd62f2eb..b9daf07ce1 100644 --- a/src/plugins/qmljseditor/quicktoolbar.cpp +++ b/src/plugins/qmljseditor/quicktoolbar.cpp @@ -64,7 +64,7 @@ static inline QString textAt(const Document* doc, return doc->source().mid(from.offset, to.end() - from.begin()); } -static inline const Interpreter::ObjectValue * getPropertyChangesTarget(Node *node, const Interpreter::ScopeChain &scopeChain) +static inline const ObjectValue * getPropertyChangesTarget(Node *node, const ScopeChain &scopeChain) { UiObjectInitializer *initializer = 0; if (UiObjectDefinition *definition = cast<UiObjectDefinition *>(node)) @@ -78,8 +78,8 @@ static inline const Interpreter::ObjectValue * getPropertyChangesTarget(Node *no && scriptBinding->qualifiedId->name->asString() == QLatin1String("target") && ! scriptBinding->qualifiedId->next) { Evaluate evaluator(&scopeChain); - const Interpreter::Value *targetValue = evaluator(scriptBinding->statement); - if (const Interpreter::ObjectValue *targetObject = Interpreter::value_cast<const Interpreter::ObjectValue *>(targetValue)) { + const Value *targetValue = evaluator(scriptBinding->statement); + if (const ObjectValue *targetObject = value_cast<const ObjectValue *>(targetValue)) { return targetObject; } else { return 0; @@ -131,7 +131,7 @@ QuickToolBar::~QuickToolBar() m_widget.clear(); } -void QuickToolBar::apply(TextEditor::BaseTextEditor *editor, Document::Ptr document, const Interpreter::ScopeChain *scopeChain, AST::Node *node, bool update, bool force) +void QuickToolBar::apply(TextEditor::BaseTextEditor *editor, Document::Ptr document, const ScopeChain *scopeChain, AST::Node *node, bool update, bool force) { if (!QuickToolBarSettings::get().enableContextPane && !force && !update) { contextWidget()->hide(); @@ -146,24 +146,24 @@ void QuickToolBar::apply(TextEditor::BaseTextEditor *editor, Document::Ptr docum m_blockWriting = true; - const Interpreter::ObjectValue *scopeObject = document->bind()->findQmlObject(node); + const ObjectValue *scopeObject = document->bind()->findQmlObject(node); bool isPropertyChanges = false; if (scopeChain && scopeObject) { m_prototypes.clear(); - foreach (const Interpreter::ObjectValue *object, - Interpreter::PrototypeIterator(scopeObject, scopeChain->context()).all()) { + foreach (const ObjectValue *object, + PrototypeIterator(scopeObject, scopeChain->context()).all()) { m_prototypes.append(object->className()); } if (m_prototypes.contains("PropertyChanges")) { isPropertyChanges = true; - const Interpreter::ObjectValue *targetObject = getPropertyChangesTarget(node, *scopeChain); + const ObjectValue *targetObject = getPropertyChangesTarget(node, *scopeChain); m_prototypes.clear(); if (targetObject) { - foreach (const Interpreter::ObjectValue *object, - Interpreter::PrototypeIterator(targetObject, scopeChain->context()).all()) { + foreach (const ObjectValue *object, + PrototypeIterator(targetObject, scopeChain->context()).all()) { m_prototypes.append(object->className()); } } diff --git a/src/plugins/qmljseditor/quicktoolbar.h b/src/plugins/qmljseditor/quicktoolbar.h index 11eeea81bc..a9e9a765db 100644 --- a/src/plugins/qmljseditor/quicktoolbar.h +++ b/src/plugins/qmljseditor/quicktoolbar.h @@ -52,7 +52,7 @@ class QuickToolBar : public QmlJS::IContextPane public: QuickToolBar(QObject *parent = 0); ~QuickToolBar(); - void apply(TextEditor::BaseTextEditor *editor, QmlJS::Document::Ptr document, const QmlJS::Interpreter::ScopeChain *scopeChain, QmlJS::AST::Node *node, bool update, bool force = false); + void apply(TextEditor::BaseTextEditor *editor, QmlJS::Document::Ptr document, const QmlJS::ScopeChain *scopeChain, QmlJS::AST::Node *node, bool update, bool force = false); bool isAvailable(TextEditor::BaseTextEditor *editor, QmlJS::Document::Ptr document, QmlJS::AST::Node *node); void setProperty(const QString &propertyName, const QVariant &value); void removeProperty(const QString &propertyName); diff --git a/src/plugins/qmljstools/qmljslocatordata.cpp b/src/plugins/qmljstools/qmljslocatordata.cpp index d21dc9dc21..a7f84c9319 100644 --- a/src/plugins/qmljstools/qmljslocatordata.cpp +++ b/src/plugins/qmljstools/qmljslocatordata.cpp @@ -39,7 +39,6 @@ using namespace QmlJSTools::Internal; using namespace QmlJS; -using namespace QmlJS::Interpreter; using namespace QmlJS::AST; LocatorData::LocatorData(QObject *parent) diff --git a/src/plugins/qmljstools/qmljsmodelmanager.cpp b/src/plugins/qmljstools/qmljsmodelmanager.cpp index 283e13e996..6ec07db623 100644 --- a/src/plugins/qmljstools/qmljsmodelmanager.cpp +++ b/src/plugins/qmljstools/qmljsmodelmanager.cpp @@ -128,16 +128,16 @@ void ModelManager::loadQmlTypeDescriptions(const QString &resourcePath) if (qmlTypesFiles.at(i).baseName() == QLatin1String("builtins")) { QFileInfoList list; list.append(qmlTypesFiles.at(i)); - Interpreter::CppQmlTypesLoader::defaultQtObjects = - Interpreter::CppQmlTypesLoader::loadQmlTypes(list, &errors, &warnings); + CppQmlTypesLoader::defaultQtObjects = + CppQmlTypesLoader::loadQmlTypes(list, &errors, &warnings); qmlTypesFiles.removeAt(i); break; } } // load the fallbacks for libraries - Interpreter::CppQmlTypesLoader::defaultLibraryObjects.unite( - Interpreter::CppQmlTypesLoader::loadQmlTypes(qmlTypesFiles, &errors, &warnings)); + CppQmlTypesLoader::defaultLibraryObjects.unite( + CppQmlTypesLoader::loadQmlTypes(qmlTypesFiles, &errors, &warnings)); Core::MessageManager *messageManager = Core::MessageManager::instance(); foreach (const QString &error, errors) @@ -362,12 +362,12 @@ static void findNewFileImports(const Document::Ptr &doc, const Snapshot &snapsho QStringList *importedFiles, QSet<QString> *scannedPaths) { // scan files and directories that are explicitly imported - foreach (const Interpreter::ImportInfo &import, doc->bind()->imports()) { + foreach (const ImportInfo &import, doc->bind()->imports()) { const QString &importName = import.name(); - if (import.type() == Interpreter::ImportInfo::FileImport) { + if (import.type() == ImportInfo::FileImport) { if (! snapshot.document(importName)) *importedFiles += importName; - } else if (import.type() == Interpreter::ImportInfo::DirectoryImport) { + } else if (import.type() == ImportInfo::DirectoryImport) { if (snapshot.documentsInDirectory(importName).isEmpty()) { if (! scannedPaths->contains(importName)) { *importedFiles += qmlFilesInDirectory(importName); @@ -473,14 +473,14 @@ static void findNewLibraryImports(const Document::Ptr &doc, const Snapshot &snap // scan dir and lib imports const QStringList importPaths = modelManager->importPaths(); - foreach (const Interpreter::ImportInfo &import, doc->bind()->imports()) { - if (import.type() == Interpreter::ImportInfo::DirectoryImport) { + foreach (const ImportInfo &import, doc->bind()->imports()) { + if (import.type() == ImportInfo::DirectoryImport) { const QString targetPath = import.name(); findNewQmlLibraryInPath(targetPath, snapshot, modelManager, importedFiles, scannedPaths, newLibraries); } - if (import.type() == Interpreter::ImportInfo::LibraryImport) { + if (import.type() == ImportInfo::LibraryImport) { if (!import.version().isValid()) continue; foreach (const QString &importPath, importPaths) { diff --git a/src/plugins/qmljstools/qmljsplugindumper.cpp b/src/plugins/qmljstools/qmljsplugindumper.cpp index 8fc3fa7962..2fcfdd5775 100644 --- a/src/plugins/qmljstools/qmljsplugindumper.cpp +++ b/src/plugins/qmljstools/qmljsplugindumper.cpp @@ -229,7 +229,7 @@ static QList<FakeMetaObject::ConstPtr> parseHelper(const QByteArray &qmlTypeDesc { QList<FakeMetaObject::ConstPtr> ret; QHash<QString, FakeMetaObject::ConstPtr> newObjects; - Interpreter::CppQmlTypesLoader::parseQmlTypeDescriptions(qmlTypeDescriptions, &newObjects, + CppQmlTypesLoader::parseQmlTypeDescriptions(qmlTypeDescriptions, &newObjects, error, warning); if (error->isEmpty()) { |