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-03-16 16:34:33 +01:00
|
|
|
#include <QtCore/QStringList>
|
2010-05-19 13:32:11 +02:00
|
|
|
#include <QtCore/QCoreApplication>
|
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-03-31 10:03:18 +02:00
|
|
|
class QMLJS_EXPORT Link
|
2010-01-28 14:53:53 +01:00
|
|
|
{
|
2010-05-19 13:42:56 +02:00
|
|
|
Q_DECLARE_TR_FUNCTIONS(QmlJS::Link)
|
|
|
|
|
|
2010-01-28 14:53:53 +01:00
|
|
|
public:
|
2010-03-16 16:34:33 +01:00
|
|
|
// Link all documents in snapshot
|
2010-03-29 11:32:11 +02:00
|
|
|
Link(Interpreter::Context *context, const Document::Ptr &doc, const Snapshot &snapshot,
|
|
|
|
|
const QStringList &importPaths);
|
2010-02-02 15:55:17 +01:00
|
|
|
~Link();
|
|
|
|
|
|
2010-03-25 14:47:28 +01:00
|
|
|
QList<DiagnosticMessage> diagnosticMessages() const;
|
|
|
|
|
|
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-03-16 16:34:33 +01:00
|
|
|
static QList<Document::Ptr> reachableDocuments(Document::Ptr startDoc, const Snapshot &snapshot,
|
|
|
|
|
const QStringList &importPaths);
|
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();
|
2010-04-22 15:59:21 +02:00
|
|
|
void initializeScopeChain();
|
2010-02-02 15:55:17 +01:00
|
|
|
|
|
|
|
|
void populateImportedTypes(Interpreter::ObjectValue *typeEnv, Document::Ptr doc);
|
|
|
|
|
void importFile(Interpreter::ObjectValue *typeEnv, Document::Ptr doc,
|
2010-03-16 16:34:33 +01:00
|
|
|
AST::UiImport *import);
|
2010-02-02 15:55:17 +01:00
|
|
|
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
|
|
|
|
2010-03-29 11:32:11 +02:00
|
|
|
void error(const Document::Ptr &doc, const AST::SourceLocation &loc, const QString &message);
|
|
|
|
|
|
2010-02-02 15:55:17 +01:00
|
|
|
private:
|
2010-03-29 11:32:11 +02:00
|
|
|
Document::Ptr _doc;
|
2010-02-02 15:55:17 +01:00
|
|
|
Snapshot _snapshot;
|
2010-02-04 10:19:37 +01:00
|
|
|
Interpreter::Context *_context;
|
2010-03-16 16:34:33 +01:00
|
|
|
const QStringList _importPaths;
|
2010-03-25 14:47:28 +01:00
|
|
|
|
|
|
|
|
QList<DiagnosticMessage> _diagnosticMessages;
|
2010-01-28 14:53:53 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace QmlJS
|
|
|
|
|
|
|
|
|
|
#endif // QMLJSLINK_H
|