diff options
author | Christian Kamm <christian.d.kamm@nokia.com> | 2011-01-12 13:58:24 +0100 |
---|---|---|
committer | Christian Kamm <christian.d.kamm@nokia.com> | 2011-01-12 14:03:01 +0100 |
commit | ef5dc8c699443b31c0806072bef025edb741404f (patch) | |
tree | ca06930711d1212c30dd427c757ec509afb80ac6 /src/plugins/qmljstools | |
parent | 033a0ff12e1b4a8eb143391d1e1d288c2b425566 (diff) | |
download | qt-creator-ef5dc8c699443b31c0806072bef025edb741404f.tar.gz |
QmlJS: Avoid frequent libraryInfoUpdated emissions.
Also don't require a rehighlight of every open document when the
signal is emitted.
Reviewed-by: Roberto Raggi
Diffstat (limited to 'src/plugins/qmljstools')
-rw-r--r-- | src/plugins/qmljstools/qmljsmodelmanager.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/plugins/qmljstools/qmljsmodelmanager.cpp b/src/plugins/qmljstools/qmljsmodelmanager.cpp index 4ec092fd17..d3da19329e 100644 --- a/src/plugins/qmljstools/qmljsmodelmanager.cpp +++ b/src/plugins/qmljstools/qmljsmodelmanager.cpp @@ -349,7 +349,7 @@ static void findNewFileImports(const Document::Ptr &doc, const Snapshot &snapsho static void findNewLibraryImports(const Document::Ptr &doc, const Snapshot &snapshot, ModelManager *modelManager, - QStringList *importedFiles, QSet<QString> *scannedPaths) + QStringList *importedFiles, QSet<QString> *scannedPaths, QSet<QString> *newLibraries) { // scan library imports const QStringList importPaths = modelManager->importPaths(); @@ -364,6 +364,8 @@ static void findNewLibraryImports(const Document::Ptr &doc, const Snapshot &snap // if we know there is a library, done if (snapshot.libraryInfo(targetPath).isValid()) break; + if (newLibraries->contains(targetPath)) + break; // if there is a qmldir file, we found a new library! if (dir.exists("qmldir")) { @@ -375,8 +377,10 @@ static void findNewLibraryImports(const Document::Ptr &doc, const Snapshot &snap qmldirParser.setSource(qmldirData); qmldirParser.parse(); - modelManager->updateLibraryInfo(QFileInfo(qmldirFile).absolutePath(), - LibraryInfo(qmldirParser)); + const QString libraryPath = QFileInfo(qmldirFile).absolutePath(); + newLibraries->insert(libraryPath); + modelManager->updateLibraryInfo(libraryPath, + LibraryInfo(qmldirParser)); // scan the qml files in the library foreach (const QmlDirParser::Component &component, qmldirParser.components()) { @@ -425,6 +429,8 @@ void ModelManager::parse(QFutureInterface<void> &future, // paths we have scanned for files and added to the files list QSet<QString> scannedPaths; + // libraries we've found while scanning imports + QSet<QString> newLibraries; for (int i = 0; i < files.size(); ++i) { future.setProgressValue(qreal(i) / files.size() * progressRange); @@ -471,7 +477,7 @@ void ModelManager::parse(QFutureInterface<void> &future, QStringList importedFiles; findNewImplicitImports(doc, snapshot, &importedFiles, &scannedPaths); findNewFileImports(doc, snapshot, &importedFiles, &scannedPaths); - findNewLibraryImports(doc, snapshot, modelManager, &importedFiles, &scannedPaths); + findNewLibraryImports(doc, snapshot, modelManager, &importedFiles, &scannedPaths, &newLibraries); // add new files to parse list foreach (const QString &file, importedFiles) { @@ -547,8 +553,9 @@ void ModelManager::updateImportPaths() Snapshot snapshot = _snapshot; QStringList importedFiles; QSet<QString> scannedPaths; + QSet<QString> newLibraries; foreach (const Document::Ptr &doc, snapshot) - findNewLibraryImports(doc, snapshot, this, &importedFiles, &scannedPaths); + findNewLibraryImports(doc, snapshot, this, &importedFiles, &scannedPaths, &newLibraries); updateSourceFiles(importedFiles, true); } |