2010-01-28 14:53:53 +01:00
|
|
|
#ifndef QMLJSLINK_H
|
|
|
|
|
#define QMLJSLINK_H
|
|
|
|
|
|
2010-02-02 15:55:17 +01:00
|
|
|
#include <qmljs/qmljsdocument.h>
|
|
|
|
|
#include <qmljs/qmljsbind.h>
|
2010-01-28 14:53:53 +01:00
|
|
|
#include <qmljs/qmljsinterpreter.h>
|
|
|
|
|
#include <qmljs/parser/qmljsastfwd_p.h>
|
|
|
|
|
#include <qmljs/parser/qmljsengine_p.h>
|
|
|
|
|
|
|
|
|
|
#include <QtCore/QList>
|
2010-02-02 15:55:17 +01:00
|
|
|
#include <QtCore/QHash>
|
2010-01-28 14:53:53 +01:00
|
|
|
|
|
|
|
|
namespace QmlJS {
|
|
|
|
|
|
2010-02-02 15:55:17 +01:00
|
|
|
/*
|
|
|
|
|
Temporarily links a set of bound documents together to allow resolving cross-document
|
|
|
|
|
dependencies. The link is undone when this object is destoyed.
|
|
|
|
|
*/
|
|
|
|
|
class QMLJS_EXPORT Link
|
2010-01-28 14:53:53 +01:00
|
|
|
{
|
|
|
|
|
public:
|
2010-02-02 15:55:17 +01:00
|
|
|
// Link all documents in snapshot reachable from doc.
|
|
|
|
|
Link(Document::Ptr doc, const Snapshot &snapshot, Interpreter::Engine *interp);
|
|
|
|
|
~Link();
|
|
|
|
|
|
|
|
|
|
// Get the scope chain for the currentObject inside doc.
|
2010-02-02 16:36:14 +01:00
|
|
|
Interpreter::ObjectValue *scopeChainAt(Document::Ptr doc, AST::Node *currentObject);
|
2010-02-02 15:55:17 +01:00
|
|
|
|
2010-01-28 14:53:53 +01:00
|
|
|
private:
|
2010-02-02 15:55:17 +01:00
|
|
|
static QList<Document::Ptr> reachableDocuments(Document::Ptr startDoc, const Snapshot &snapshot);
|
|
|
|
|
static const Interpreter::ObjectValue *lookupType(Interpreter::ObjectValue *env, AST::UiQualifiedId *id);
|
2010-02-02 17:06:48 +01:00
|
|
|
static AST::UiQualifiedId *qualifiedTypeNameId(AST::Node *node);
|
2010-01-28 14:53:53 +01:00
|
|
|
|
2010-02-02 15:55:17 +01:00
|
|
|
void linkImports();
|
|
|
|
|
|
|
|
|
|
void populateImportedTypes(Interpreter::ObjectValue *typeEnv, Document::Ptr doc);
|
|
|
|
|
void importFile(Interpreter::ObjectValue *typeEnv, Document::Ptr doc,
|
|
|
|
|
AST::UiImport *import, const QString &startPath);
|
|
|
|
|
void importNonFile(Interpreter::ObjectValue *typeEnv, Document::Ptr doc,
|
|
|
|
|
AST::UiImport *import);
|
2010-02-02 17:06:48 +01:00
|
|
|
void importObject(BindPtr bind, const QString &name, Interpreter::ObjectValue *object, NameId* targetNamespace);
|
2010-02-02 15:55:17 +01:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
Snapshot _snapshot;
|
|
|
|
|
Interpreter::Engine *_interp;
|
|
|
|
|
QList<Document::Ptr> _docs;
|
|
|
|
|
QHash<Document *, Interpreter::ObjectValue *> _typeEnvironments;
|
2010-01-28 14:53:53 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace QmlJS
|
|
|
|
|
|
|
|
|
|
#endif // QMLJSLINK_H
|