diff options
author | Christian Kamm <christian.d.kamm@nokia.com> | 2010-09-16 15:29:37 +0200 |
---|---|---|
committer | Christian Kamm <christian.d.kamm@nokia.com> | 2010-09-16 15:51:21 +0200 |
commit | c7b3e3c81c760bce7a15964a1b583b344e0db1b4 (patch) | |
tree | bd2f0d2ed1b3e91c7797d43dba6d336bdda250bc /src/plugins/qmljseditor/qmljsmodelmanager.cpp | |
parent | 97c07292aa661754470d71af0774f247275cb9cb (diff) | |
download | qt-creator-c7b3e3c81c760bce7a15964a1b583b344e0db1b4.tar.gz |
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.
Diffstat (limited to 'src/plugins/qmljseditor/qmljsmodelmanager.cpp')
-rw-r--r-- | src/plugins/qmljseditor/qmljsmodelmanager.cpp | 25 |
1 files changed, 13 insertions, 12 deletions
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<QString> *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 |