forked from qt-creator/qt-creator
QmlJS: Speed up Link significantly, provide more info on imports.
Link now caches imports. That means importing the same library (say, Qt) from more than one file no longer creates an importing namespace for each one. Instead, a single one is created for the instance of Link. To make this work, the type environment in ScopeChain has been given its own type: Interpreter::TypeEnvironment. That has the added benefit of being able to carry meta-information about imports. You can use TypeEnvironment::importInfo(qmlComponentName) to get information about the import node that caused the import of the component.
This commit is contained in:
@@ -42,12 +42,14 @@
|
||||
namespace QmlJS {
|
||||
|
||||
class NameId;
|
||||
class LinkPrivate;
|
||||
|
||||
/*
|
||||
Helper for building a context.
|
||||
*/
|
||||
class QMLJS_EXPORT Link
|
||||
{
|
||||
Q_DECLARE_PRIVATE(Link)
|
||||
Q_DECLARE_TR_FUNCTIONS(QmlJS::Link)
|
||||
|
||||
public:
|
||||
@@ -73,22 +75,15 @@ private:
|
||||
void linkImports();
|
||||
void initializeScopeChain();
|
||||
|
||||
void populateImportedTypes(Interpreter::ObjectValue *typeEnv, Document::Ptr doc);
|
||||
void importFile(Interpreter::ObjectValue *typeEnv, Document::Ptr doc,
|
||||
AST::UiImport *import);
|
||||
void importNonFile(Interpreter::ObjectValue *typeEnv, Document::Ptr doc,
|
||||
AST::UiImport *import);
|
||||
void populateImportedTypes(Interpreter::TypeEnvironment *typeEnv, Document::Ptr doc);
|
||||
Interpreter::ObjectValue *importFile(Document::Ptr doc, const Interpreter::ImportInfo &importInfo);
|
||||
Interpreter::ObjectValue *importNonFile(Document::Ptr doc, const Interpreter::ImportInfo &importInfo);
|
||||
void importObject(Bind *bind, const QString &name, Interpreter::ObjectValue *object, NameId *targetNamespace);
|
||||
|
||||
void error(const Document::Ptr &doc, const AST::SourceLocation &loc, const QString &message);
|
||||
|
||||
private:
|
||||
Document::Ptr _doc;
|
||||
Snapshot _snapshot;
|
||||
Interpreter::Context *_context;
|
||||
const QStringList _importPaths;
|
||||
|
||||
QList<DiagnosticMessage> _diagnosticMessages;
|
||||
QScopedPointer<LinkPrivate> d_ptr;
|
||||
};
|
||||
|
||||
} // namespace QmlJS
|
||||
|
||||
Reference in New Issue
Block a user