From c7b3e3c81c760bce7a15964a1b583b344e0db1b4 Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Thu, 16 Sep 2010 15:29:37 +0200 Subject: 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. --- src/plugins/qmljseditor/qmljsmodelmanager.cpp | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'src/plugins/qmljseditor/qmljsmodelmanager.cpp') diff --git a/src/plugins/qmljseditor/qmljsmodelmanager.cpp b/src/plugins/qmljseditor/qmljsmodelmanager.cpp index ae8e975241..2dd2b256c2 100644 --- a/src/plugins/qmljseditor/qmljsmodelmanager.cpp +++ b/src/plugins/qmljseditor/qmljsmodelmanager.cpp @@ -276,15 +276,16 @@ static void findNewFileImports(const Document::Ptr &doc, const Snapshot &snapsho QStringList *importedFiles, QSet *scannedPaths) { // scan files and directories that are explicitly imported - foreach (const Bind::ImportInfo &import, doc->bind()->imports()) { - if (import.type == Bind::ImportInfo::FileImport) { - if (! snapshot.document(import.name)) - *importedFiles += import.name; - } else if (import.type == Bind::ImportInfo::DirectoryImport) { - if (snapshot.documentsInDirectory(import.name).isEmpty()) { - if (! scannedPaths->contains(import.name)) { - *importedFiles += qmlFilesInDirectory(import.name); - scannedPaths->insert(import.name); + foreach (const Interpreter::ImportInfo &import, doc->bind()->imports()) { + const QString &importName = import.name(); + if (import.type() == Interpreter::ImportInfo::FileImport) { + if (! snapshot.document(importName)) + *importedFiles += importName; + } else if (import.type() == Interpreter::ImportInfo::DirectoryImport) { + if (snapshot.documentsInDirectory(importName).isEmpty()) { + if (! scannedPaths->contains(importName)) { + *importedFiles += qmlFilesInDirectory(importName); + scannedPaths->insert(importName); } } } @@ -297,12 +298,12 @@ static void findNewLibraryImports(const Document::Ptr &doc, const Snapshot &snap { // scan library imports const QStringList importPaths = modelManager->importPaths(); - foreach (const Bind::ImportInfo &import, doc->bind()->imports()) { - if (import.type != Bind::ImportInfo::LibraryImport) + foreach (const Interpreter::ImportInfo &import, doc->bind()->imports()) { + if (import.type() != Interpreter::ImportInfo::LibraryImport) continue; foreach (const QString &importPath, importPaths) { QDir dir(importPath); - dir.cd(import.name); + dir.cd(import.name()); const QString targetPath = dir.absolutePath(); // if we know there is a library, done -- cgit v1.2.1