forked from qt-creator/qt-creator
LanguageUtils: Add FakeMetaObject and ComponentVersion.
This commit is contained in:
@@ -34,9 +34,9 @@
|
||||
#ifndef QMLJS_INTERPRETER_H
|
||||
#define QMLJS_INTERPRETER_H
|
||||
|
||||
#include <languageutils/componentversion.h>
|
||||
#include <qmljs/qmljsdocument.h>
|
||||
#include <qmljs/qmljs_global.h>
|
||||
#include <qmljs/qmljscomponentversion.h>
|
||||
#include <qmljs/parser/qmljsastfwd_p.h>
|
||||
|
||||
#include <QtCore/QFileInfoList>
|
||||
@@ -46,6 +46,13 @@
|
||||
#include <QtCore/QSet>
|
||||
#include <QtCore/QMutex>
|
||||
|
||||
namespace LanguageUtils {
|
||||
class FakeMetaObject;
|
||||
class FakeMetaMethod;
|
||||
class FakeMetaProperty;
|
||||
class FakeMetaEnum;
|
||||
}
|
||||
|
||||
namespace QmlJS {
|
||||
|
||||
class NameId;
|
||||
@@ -75,11 +82,6 @@ class TypeEnvironment;
|
||||
|
||||
typedef QList<const Value *> ValueList;
|
||||
|
||||
class FakeMetaObject;
|
||||
class FakeMetaMethod;
|
||||
class FakeMetaProperty;
|
||||
class FakeMetaEnum;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Value visitor
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -450,16 +452,17 @@ private:
|
||||
class QMLJS_EXPORT QmlObjectValue: public ObjectValue
|
||||
{
|
||||
public:
|
||||
QmlObjectValue(const FakeMetaObject *metaObject, const QString &className,
|
||||
const QString &packageName, const ComponentVersion version, Engine *engine);
|
||||
QmlObjectValue(const LanguageUtils::FakeMetaObject *metaObject, const QString &className,
|
||||
const QString &packageName, const LanguageUtils::ComponentVersion version,
|
||||
Engine *engine);
|
||||
virtual ~QmlObjectValue();
|
||||
|
||||
virtual void processMembers(MemberProcessor *processor) const;
|
||||
const Value *propertyValue(const FakeMetaProperty &prop) const;
|
||||
const Value *propertyValue(const LanguageUtils::FakeMetaProperty &prop) const;
|
||||
|
||||
QString packageName() const;
|
||||
QString nameInPackage(const QString &packageName) const;
|
||||
ComponentVersion version() const;
|
||||
LanguageUtils::ComponentVersion version() const;
|
||||
QString defaultPropertyName() const;
|
||||
QString propertyType(const QString &propertyName) const;
|
||||
bool isListProperty(const QString &name) const;
|
||||
@@ -473,27 +476,28 @@ public:
|
||||
bool hasChildInPackage() const;
|
||||
|
||||
protected:
|
||||
const Value *findOrCreateSignature(int index, const FakeMetaMethod &method, QString *methodName) const;
|
||||
bool isDerivedFrom(const FakeMetaObject *base) const;
|
||||
const Value *findOrCreateSignature(int index, const LanguageUtils::FakeMetaMethod &method,
|
||||
QString *methodName) const;
|
||||
bool isDerivedFrom(const LanguageUtils::FakeMetaObject *base) const;
|
||||
|
||||
private:
|
||||
const FakeMetaObject *_metaObject;
|
||||
const LanguageUtils::FakeMetaObject *_metaObject;
|
||||
const QString _packageName;
|
||||
const ComponentVersion _componentVersion;
|
||||
const LanguageUtils::ComponentVersion _componentVersion;
|
||||
mutable QHash<int, const Value *> _metaSignature;
|
||||
};
|
||||
|
||||
class QMLJS_EXPORT QmlEnumValue: public NumberValue
|
||||
{
|
||||
public:
|
||||
QmlEnumValue(const FakeMetaEnum &metaEnum, Engine *engine);
|
||||
QmlEnumValue(const LanguageUtils::FakeMetaEnum &metaEnum, Engine *engine);
|
||||
virtual ~QmlEnumValue();
|
||||
|
||||
QString name() const;
|
||||
QStringList keys() const;
|
||||
|
||||
private:
|
||||
FakeMetaEnum *_metaEnum;
|
||||
LanguageUtils::FakeMetaEnum *_metaEnum;
|
||||
};
|
||||
|
||||
class QMLJS_EXPORT Activation
|
||||
@@ -588,34 +592,38 @@ class QMLJS_EXPORT CppQmlTypesLoader
|
||||
public:
|
||||
/** \return an empty list when successful, error messages otherwise. */
|
||||
static QStringList load(const QFileInfoList &xmlFiles);
|
||||
static QList<const FakeMetaObject *> builtinObjects;
|
||||
static QList<const LanguageUtils::FakeMetaObject *> builtinObjects;
|
||||
|
||||
// parses the xml string and fills the newObjects map
|
||||
static QString parseQmlTypeXml(const QByteArray &xml, QMap<QString, FakeMetaObject *> *newObjects);
|
||||
static QString parseQmlTypeXml(const QByteArray &xml,
|
||||
QMap<QString, LanguageUtils::FakeMetaObject *> *newObjects);
|
||||
private:
|
||||
static void setSuperClasses(QMap<QString, FakeMetaObject *> *newObjects);
|
||||
static void setSuperClasses(QMap<QString, LanguageUtils::FakeMetaObject *> *newObjects);
|
||||
};
|
||||
|
||||
class QMLJS_EXPORT CppQmlTypes
|
||||
{
|
||||
public:
|
||||
void load(Interpreter::Engine *interpreter, const QList<const FakeMetaObject *> &objects);
|
||||
void load(Interpreter::Engine *interpreter, const QList<const LanguageUtils::FakeMetaObject *> &objects);
|
||||
|
||||
QList<Interpreter::QmlObjectValue *> typesForImport(const QString &prefix, ComponentVersion version) const;
|
||||
QList<Interpreter::QmlObjectValue *> typesForImport(const QString &prefix, LanguageUtils::ComponentVersion version) const;
|
||||
Interpreter::QmlObjectValue *typeForImport(const QString &qualifiedName,
|
||||
ComponentVersion version = ComponentVersion()) const;
|
||||
LanguageUtils::ComponentVersion version = LanguageUtils::ComponentVersion()) const;
|
||||
|
||||
bool hasPackage(const QString &package) const;
|
||||
|
||||
QHash<QString, QmlObjectValue *> types() const
|
||||
{ return _typesByFullyQualifiedName; }
|
||||
|
||||
static QString qualifiedName(const QString &package, const QString &type, ComponentVersion version);
|
||||
static QString qualifiedName(const QString &package, const QString &type, LanguageUtils::ComponentVersion version);
|
||||
QmlObjectValue *typeByQualifiedName(const QString &name) const;
|
||||
QmlObjectValue *typeByQualifiedName(const QString &package, const QString &type, ComponentVersion version) const;
|
||||
QmlObjectValue *typeByQualifiedName(const QString &package, const QString &type,
|
||||
LanguageUtils::ComponentVersion version) const;
|
||||
|
||||
private:
|
||||
QmlObjectValue *getOrCreate(const QString &package, const QString &cppName, const FakeMetaObject *metaObject, Engine *engine, bool *created);
|
||||
QmlObjectValue *getOrCreate(const QString &package, const QString &cppName,
|
||||
const LanguageUtils::FakeMetaObject *metaObject,
|
||||
Engine *engine, bool *created);
|
||||
|
||||
|
||||
QHash<QString, QList<QmlObjectValue *> > _typesByPackage;
|
||||
@@ -969,7 +977,7 @@ public:
|
||||
|
||||
ImportInfo();
|
||||
ImportInfo(Type type, const QString &name,
|
||||
ComponentVersion version = ComponentVersion(),
|
||||
LanguageUtils::ComponentVersion version = LanguageUtils::ComponentVersion(),
|
||||
AST::UiImport *ast = 0);
|
||||
|
||||
bool isValid() const;
|
||||
@@ -982,13 +990,13 @@ public:
|
||||
// null if the import has no 'as', otherwise the target id
|
||||
QString id() const;
|
||||
|
||||
ComponentVersion version() const;
|
||||
LanguageUtils::ComponentVersion version() const;
|
||||
AST::UiImport *ast() const;
|
||||
|
||||
private:
|
||||
Type _type;
|
||||
QString _name;
|
||||
ComponentVersion _version;
|
||||
LanguageUtils::ComponentVersion _version;
|
||||
AST::UiImport *_ast;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user