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>
|
2010-01-28 14:53:53 +01:00
|
|
|
#include <qmljs/qmljsinterpreter.h>
|
|
|
|
|
#include <qmljs/parser/qmljsastfwd_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-04 10:19:37 +01:00
|
|
|
class NameId;
|
|
|
|
|
|
2010-02-02 15:55:17 +01:00
|
|
|
/*
|
2010-02-04 10:19:37 +01:00
|
|
|
Helper for building a context.
|
2010-02-02 15:55:17 +01:00
|
|
|
*/
|
2010-02-04 10:19:37 +01:00
|
|
|
class 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.
|
2010-02-04 10:19:37 +01:00
|
|
|
Link(Interpreter::Context *context, Document::Ptr doc, const Snapshot &snapshot);
|
2010-02-02 15:55:17 +01:00
|
|
|
~Link();
|
|
|
|
|
|
|
|
|
|
// Get the scope chain for the currentObject inside doc.
|
2010-02-19 12:25:26 +01:00
|
|
|
void scopeChainAt(Document::Ptr doc, const QList<AST::Node *> &astPath = QList<AST::Node *>());
|
2010-02-03 10:59:52 +01:00
|
|
|
|
2010-01-28 14:53:53 +01:00
|
|
|
private:
|
2010-02-04 10:19:37 +01:00
|
|
|
Interpreter::Engine *engine();
|
|
|
|
|
|
2010-02-19 10:14:34 +01:00
|
|
|
void makeComponentChain(
|
|
|
|
|
Document::Ptr doc,
|
|
|
|
|
Interpreter::ScopeChain::QmlComponentChain *target,
|
|
|
|
|
QHash<Document *, Interpreter::ScopeChain::QmlComponentChain *> *components);
|
2010-02-11 18:58:17 +01:00
|
|
|
|
2010-02-02 15:55:17 +01:00
|
|
|
static QList<Document::Ptr> reachableDocuments(Document::Ptr startDoc, const Snapshot &snapshot);
|
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-03 15:59:15 +01:00
|
|
|
void importObject(Bind *bind, const QString &name, Interpreter::ObjectValue *object, NameId *targetNamespace);
|
2010-02-02 15:55:17 +01:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
Snapshot _snapshot;
|
2010-02-04 10:19:37 +01:00
|
|
|
Interpreter::Context *_context;
|
2010-02-02 15:55:17 +01:00
|
|
|
QList<Document::Ptr> _docs;
|
2010-01-28 14:53:53 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace QmlJS
|
|
|
|
|
|
|
|
|
|
#endif // QMLJSLINK_H
|