diff --git a/src/plugins/coreplugin/documentmanager.cpp b/src/plugins/coreplugin/documentmanager.cpp index 72f4d0e077fb6fbc50d37f51a0ff88c36b055e15..59775c51871af5fb86bf35ba74ae12d8c9e3f409 100644 --- a/src/plugins/coreplugin/documentmanager.cpp +++ b/src/plugins/coreplugin/documentmanager.cpp @@ -228,7 +228,7 @@ DocumentManager::~DocumentManager() delete d; } -QObject *DocumentManager::instance() +DocumentManager *DocumentManager::instance() { return m_instance; } diff --git a/src/plugins/coreplugin/documentmanager.h b/src/plugins/coreplugin/documentmanager.h index 1fc72b24b75aa7d88934ea64f789e2f34e706624..9c361910fba2eb27172911fa48301665955c1a6d 100644 --- a/src/plugins/coreplugin/documentmanager.h +++ b/src/plugins/coreplugin/documentmanager.h @@ -60,7 +60,7 @@ public: typedef QPair RecentFile; - static QObject *instance(); + static DocumentManager *instance(); // file pool to monitor static void addDocuments(const QList &documents, bool addWatcher = true); diff --git a/src/plugins/cppeditor/cppincludehierarchy_test.cpp b/src/plugins/cppeditor/cppincludehierarchy_test.cpp index ac208778710a0463485c73e2884d926f6a34f6f1..8eaba08c0a854467b64ad1f5eeeadcc148dc7cae 100644 --- a/src/plugins/cppeditor/cppincludehierarchy_test.cpp +++ b/src/plugins/cppeditor/cppincludehierarchy_test.cpp @@ -79,7 +79,7 @@ public: { QVERIFY(succeededSoFar()); - QStringList filePaths; + QSet filePaths; const int sourceListSize = sourceList.size(); for (int i = 0; i < sourceListSize; ++i) { const QByteArray &source = sourceList.at(i); diff --git a/src/plugins/cppeditor/cppquickfix_test.cpp b/src/plugins/cppeditor/cppquickfix_test.cpp index 827e4362a0c5e389fe826611228c503b26771c83..b1b4c947ae9d95e7a28ae926ca1999b99dbdab7a 100644 --- a/src/plugins/cppeditor/cppquickfix_test.cpp +++ b/src/plugins/cppeditor/cppquickfix_test.cpp @@ -145,7 +145,7 @@ QuickFixTestCase::QuickFixTestCase(const QList &theTe } // Update Code Model - QStringList filePaths; + QSet filePaths; foreach (const QuickFixTestDocument::Ptr &testFile, m_testFiles) filePaths << testFile->filePath(); QVERIFY(parseFiles(filePaths)); diff --git a/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp b/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp index 87ea2fa0dbc3f60d97bca506e4eaf5346e0157dc..b3191ba031035877090db4d6d1fcbbddb5589203 100644 --- a/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp +++ b/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp @@ -268,7 +268,7 @@ F2TestCase::F2TestCase(CppEditorAction action, QVERIFY(testFile->writeToDisk()); // Update Code Model - QStringList filePaths; + QSet filePaths; foreach (const TestDocumentPtr &testFile, testFiles) filePaths << testFile->filePath(); QVERIFY(parseFiles(filePaths)); diff --git a/src/plugins/cpptools/abstracteditorsupport.cpp b/src/plugins/cpptools/abstracteditorsupport.cpp index bba88d4e95e2db39cfe7209ef9b8955cfd260223..d1abe0ff79e3e6ecad4e81e5fdf7cc0b1db5b6eb 100644 --- a/src/plugins/cpptools/abstracteditorsupport.cpp +++ b/src/plugins/cpptools/abstracteditorsupport.cpp @@ -49,7 +49,7 @@ AbstractEditorSupport::~AbstractEditorSupport() void AbstractEditorSupport::updateDocument() { ++m_revision; - m_modelmanager->updateSourceFiles(QStringList(fileName())); + m_modelmanager->updateSourceFiles(QSet() << fileName()); } QString AbstractEditorSupport::functionAt(const CppModelManagerInterface *modelManager, diff --git a/src/plugins/cpptools/baseeditordocumentprocessor.cpp b/src/plugins/cpptools/baseeditordocumentprocessor.cpp index e8992da58e4c574dbad1004fe43480d59e7dc90c..f8353707fbe7b9b233fbde9a4e4350062939a0df 100644 --- a/src/plugins/cpptools/baseeditordocumentprocessor.cpp +++ b/src/plugins/cpptools/baseeditordocumentprocessor.cpp @@ -127,7 +127,7 @@ void BaseEditorDocumentProcessor::runParser(QFutureInterface &future, parser->update(workingCopy); CppModelManagerInterface::instance() - ->finishedRefreshingSourceFiles(QStringList(parser->filePath())); + ->finishedRefreshingSourceFiles(QSet() << parser->filePath()); future.setProgressValue(1); } diff --git a/src/plugins/cpptools/builtinindexingsupport.cpp b/src/plugins/cpptools/builtinindexingsupport.cpp index 47b771a6b29e6972517d3c181ee9b29f1c806f17..cd2386a6bb059c6b5300238e9f4a295d3f96d239 100644 --- a/src/plugins/cpptools/builtinindexingsupport.cpp +++ b/src/plugins/cpptools/builtinindexingsupport.cpp @@ -68,7 +68,7 @@ public: int revision; ProjectPart::HeaderPaths headerPaths; WorkingCopy workingCopy; - QStringList sourceFiles; + QSet sourceFiles; }; class WriteTaskFileForDiagnostics @@ -133,7 +133,7 @@ private: int m_processedDiagnostics; }; -void classifyFiles(const QStringList &files, QStringList *headers, QStringList *sources) +void classifyFiles(const QSet &files, QStringList *headers, QStringList *sources) { foreach (const QString &file, files) { if (ProjectFile::isSource(ProjectFile::classify(file))) @@ -145,11 +145,11 @@ void classifyFiles(const QStringList &files, QStringList *headers, QStringList * void indexFindErrors(QFutureInterface &future, const ParseParams params) { - QStringList files = params.sourceFiles; - files.sort(); QStringList sources, headers; - classifyFiles(files, &headers, &sources); - files = sources + headers; + classifyFiles(params.sourceFiles, &headers, &sources); + sources.sort(); + headers.sort(); + QStringList files = sources + headers; WriteTaskFileForDiagnostics taskFileWriter; QElapsedTimer timer; @@ -196,20 +196,18 @@ void index(QFutureInterface &future, const ParseParams params) sourceProcessor->setHeaderPaths(params.headerPaths); sourceProcessor->setWorkingCopy(params.workingCopy); - QStringList files = params.sourceFiles; QStringList sources; QStringList headers; - classifyFiles(files, &headers, &sources); + classifyFiles(params.sourceFiles, &headers, &sources); - foreach (const QString &file, files) + foreach (const QString &file, params.sourceFiles) sourceProcessor->removeFromCache(file); const int sourceCount = sources.size(); - files = sources; - files += headers; + QStringList files = sources + headers; - sourceProcessor->setTodo(files); + sourceProcessor->setTodo(files.toSet()); const QString conf = CppModelManagerInterface::configurationFileName(); bool processingHeaders = false; @@ -250,7 +248,7 @@ void index(QFutureInterface &future, const ParseParams params) void parse(QFutureInterface &future, const ParseParams params) { - const QStringList files = params.sourceFiles; + const QSet &files = params.sourceFiles; if (files.isEmpty()) return; @@ -356,7 +354,7 @@ BuiltinIndexingSupport::BuiltinIndexingSupport() BuiltinIndexingSupport::~BuiltinIndexingSupport() {} -QFuture BuiltinIndexingSupport::refreshSourceFiles(const QStringList &sourceFiles, +QFuture BuiltinIndexingSupport::refreshSourceFiles(const QSet &sourceFiles, CppModelManagerInterface::ProgressNotificationMode mode) { CppModelManager *mgr = CppModelManager::instance(); diff --git a/src/plugins/cpptools/builtinindexingsupport.h b/src/plugins/cpptools/builtinindexingsupport.h index cf1e9beae76c0aab9f0a32691171cf2c8828cefb..a9a5d31d68d2979554aa625b2cfc6b76fbd36cad 100644 --- a/src/plugins/cpptools/builtinindexingsupport.h +++ b/src/plugins/cpptools/builtinindexingsupport.h @@ -43,7 +43,7 @@ public: BuiltinIndexingSupport(); ~BuiltinIndexingSupport(); - virtual QFuture refreshSourceFiles(const QStringList &sourceFiles, + virtual QFuture refreshSourceFiles(const QSet &sourceFiles, CppModelManagerInterface::ProgressNotificationMode mode); virtual SymbolSearcher *createSymbolSearcher(SymbolSearcher::Parameters parameters, QSet fileNames); diff --git a/src/plugins/cpptools/cppfindreferences.cpp b/src/plugins/cpptools/cppfindreferences.cpp index 27bd536a400e54fbbe184a025b39aefb3fc9d745..6e0ec85edee9033dc3ef6a7b307b1007a73a894b 100644 --- a/src/plugins/cpptools/cppfindreferences.cpp +++ b/src/plugins/cpptools/cppfindreferences.cpp @@ -385,7 +385,7 @@ void CppFindReferences::onReplaceButtonClicked(const QString &text, { const QStringList fileNames = TextEditor::BaseFileFind::replaceAll(text, items, preserveCase); if (!fileNames.isEmpty()) { - m_modelManager->updateSourceFiles(fileNames); + m_modelManager->updateSourceFiles(fileNames.toSet()); Core::SearchResultWindow::instance()->hide(); } } diff --git a/src/plugins/cpptools/cppindexingsupport.h b/src/plugins/cpptools/cppindexingsupport.h index bd50dfc6361d9b57c29a185f9f0450d3c7c5286e..b31e5072a2701a209e9603cd01ade89214f6cc5c 100644 --- a/src/plugins/cpptools/cppindexingsupport.h +++ b/src/plugins/cpptools/cppindexingsupport.h @@ -82,7 +82,7 @@ class CPPTOOLS_EXPORT CppIndexingSupport public: virtual ~CppIndexingSupport() = 0; - virtual QFuture refreshSourceFiles(const QStringList &sourceFiles, + virtual QFuture refreshSourceFiles(const QSet &sourceFiles, CppModelManagerInterface::ProgressNotificationMode mode) = 0; virtual SymbolSearcher *createSymbolSearcher(SymbolSearcher::Parameters parameters, QSet fileNames) = 0; diff --git a/src/plugins/cpptools/cppmodelmanager.cpp b/src/plugins/cpptools/cppmodelmanager.cpp index 3ca1f734d089f0f91bb6037671758867b6e6354d..84d05ca108fa4c441ee9a422201d58f08322309f 100644 --- a/src/plugins/cpptools/cppmodelmanager.cpp +++ b/src/plugins/cpptools/cppmodelmanager.cpp @@ -141,9 +141,9 @@ static const char pp_configuration[] = "#define __inline inline\n" "#define __forceinline inline\n"; -QStringList CppModelManager::timeStampModifiedFiles(const QList &documentsToCheck) +QSet CppModelManager::timeStampModifiedFiles(const QList &documentsToCheck) { - QStringList sourceFiles; + QSet sourceFiles; foreach (const Document::Ptr doc, documentsToCheck) { const QDateTime lastModified = doc->lastModified(); @@ -152,7 +152,7 @@ QStringList CppModelManager::timeStampModifiedFiles(const QList & QFileInfo fileInfo(doc->fileName()); if (fileInfo.exists() && fileInfo.lastModified() != lastModified) - sourceFiles.append(doc->fileName()); + sourceFiles.insert(doc->fileName()); } } @@ -184,8 +184,7 @@ void CppModelManager::updateModifiedSourceFiles() foreach (const Document::Ptr document, snapshot) documentsToCheck << document; - const QStringList filesToUpdate = timeStampModifiedFiles(documentsToCheck); - updateSourceFiles(filesToUpdate); + updateSourceFiles(timeStampModifiedFiles(documentsToCheck)); } /*! @@ -224,7 +223,7 @@ CppModelManager::CppModelManager(QObject *parent) this, SIGNAL(globalSnapshotChanged())); connect(this, SIGNAL(aboutToRemoveFiles(QStringList)), this, SIGNAL(globalSnapshotChanged())); - connect(this, SIGNAL(sourceFilesRefreshed(QStringList)), + connect(this, SIGNAL(sourceFilesRefreshed(QSet)), this, SLOT(onSourceFilesRefreshed())); m_findReferences = new CppFindReferences(this); @@ -505,7 +504,7 @@ QByteArray CppModelManager::codeModelConfiguration() const return QByteArray::fromRawData(pp_configuration, qstrlen(pp_configuration)); } -QFuture CppModelManager::updateSourceFiles(const QStringList &sourceFiles, +QFuture CppModelManager::updateSourceFiles(const QSet &sourceFiles, ProgressNotificationMode mode) { if (sourceFiles.isEmpty() || !m_indexerEnabled) @@ -565,9 +564,9 @@ public: ProjectInfoComparer(const ProjectInfo &oldProjectInfo, const ProjectInfo &newProjectInfo) : m_old(oldProjectInfo) - , m_oldSourceFiles(oldProjectInfo.sourceFiles().toSet()) + , m_oldSourceFiles(oldProjectInfo.sourceFiles()) , m_new(newProjectInfo) - , m_newSourceFiles(newProjectInfo.sourceFiles().toSet()) + , m_newSourceFiles(newProjectInfo.sourceFiles()) {} bool definesChanged() const @@ -614,7 +613,7 @@ public: documentsToCheck << document; } - return CppModelManager::timeStampModifiedFiles(documentsToCheck).toSet(); + return CppModelManager::timeStampModifiedFiles(documentsToCheck); } private: @@ -645,14 +644,14 @@ QFuture CppModelManager::updateProjectInfo(const ProjectInfo &newProjectIn if (!newProjectInfo.isValid()) return QFuture(); - QStringList filesToReindex; + QSet filesToReindex; bool filesRemoved = false; { // Only hold the mutex for a limited scope, so the dumping afterwards does not deadlock. QMutexLocker projectLocker(&m_projectMutex); ProjectExplorer::Project *project = newProjectInfo.project().data(); - const QStringList newSourceFiles = newProjectInfo.sourceFiles(); + const QSet newSourceFiles = newProjectInfo.sourceFiles(); // Check if we can avoid a full reindexing ProjectInfo oldProjectInfo = m_projectToProjectsInfo.value(project); @@ -664,7 +663,7 @@ QFuture CppModelManager::updateProjectInfo(const ProjectInfo &newProjectIn // If the project configuration changed, do a full reindexing if (comparer.configurationChanged()) { removeProjectInfoFilesAndIncludesFromSnapshot(oldProjectInfo); - filesToReindex << newSourceFiles; + filesToReindex.unite(newSourceFiles); // The "configuration file" includes all defines and therefore should be updated if (comparer.definesChanged()) { @@ -675,10 +674,10 @@ QFuture CppModelManager::updateProjectInfo(const ProjectInfo &newProjectIn // Otherwise check for added and modified files } else { const QSet addedFiles = comparer.addedFiles(); - filesToReindex << addedFiles.toList(); + filesToReindex.unite(addedFiles); const QSet modifiedFiles = comparer.timeStampModifiedFiles(snapshot()); - filesToReindex << modifiedFiles.toList(); + filesToReindex.unite(modifiedFiles); } // Announce and purge the removed files from the snapshot @@ -691,7 +690,7 @@ QFuture CppModelManager::updateProjectInfo(const ProjectInfo &newProjectIn // A new project was opened/created, do a full indexing } else { - filesToReindex << newSourceFiles; + filesToReindex.unite(newSourceFiles); } // Update Project/ProjectInfo and File/ProjectPart table @@ -872,7 +871,7 @@ void CppModelManager::GC() emit gcFinished(); } -void CppModelManager::finishedRefreshingSourceFiles(const QStringList &files) +void CppModelManager::finishedRefreshingSourceFiles(const QSet &files) { emit sourceFilesRefreshed(files); } diff --git a/src/plugins/cpptools/cppmodelmanager.h b/src/plugins/cpptools/cppmodelmanager.h index 490c9f803b216c1170887429edb1782a75933103..c748fe6e4253d67cc5e4bd074c811d2856d9e00a 100644 --- a/src/plugins/cpptools/cppmodelmanager.h +++ b/src/plugins/cpptools/cppmodelmanager.h @@ -62,7 +62,7 @@ public: static CppModelManager *instance(); - virtual QFuture updateSourceFiles(const QStringList &sourceFiles, + virtual QFuture updateSourceFiles(const QSet &sourceFiles, ProgressNotificationMode mode = ReservedProgressNotification); virtual WorkingCopy workingCopy() const; virtual QByteArray codeModelConfiguration() const; @@ -106,7 +106,7 @@ public: virtual void findMacroUsages(const CPlusPlus::Macro ¯o); virtual void renameMacroUsages(const CPlusPlus::Macro ¯o, const QString &replacement); - virtual void finishedRefreshingSourceFiles(const QStringList &files); + virtual void finishedRefreshingSourceFiles(const QSet &files); virtual void addModelManagerSupport(ModelManagerSupport *modelManagerSupport); virtual ModelManagerSupport *modelManagerSupportForMimeType(const QString &mimeType) const; @@ -143,7 +143,7 @@ public: void enableGarbageCollector(bool enable); - static QStringList timeStampModifiedFiles(const QList &documentsToCheck); + static QSet timeStampModifiedFiles(const QList &documentsToCheck); static CppSourceProcessor *createSourceProcessor(); diff --git a/src/plugins/cpptools/cppmodelmanager_test.cpp b/src/plugins/cpptools/cppmodelmanager_test.cpp index 0d91e6798b79a441d6d627c235bb24974b6a72e9..1cebc411a435597d27e8fb8c39917b87ce92dde3 100644 --- a/src/plugins/cpptools/cppmodelmanager_test.cpp +++ b/src/plugins/cpptools/cppmodelmanager_test.cpp @@ -194,7 +194,7 @@ private: const QString &m_filePath; }; -static QStringList updateProjectInfo(CppModelManager *modelManager, ModelManagerTestHelper *helper, +static QSet updateProjectInfo(CppModelManager *modelManager, ModelManagerTestHelper *helper, const ProjectInfo &projectInfo) { helper->resetRefreshedSourceFiles(); @@ -315,7 +315,7 @@ void CppToolsPlugin::test_modelmanager_refresh_also_includes_of_project_files() part->files.append(ProjectFile(testCpp, ProjectFile::CXXSource)); pi.appendProjectPart(part); - QStringList refreshedFiles = updateProjectInfo(mm, &helper, pi); + QSet refreshedFiles = updateProjectInfo(mm, &helper, pi); QCOMPARE(refreshedFiles.size(), 1); QVERIFY(refreshedFiles.contains(testCpp)); CPlusPlus::Snapshot snapshot = mm->snapshot(); @@ -375,7 +375,7 @@ void CppToolsPlugin::test_modelmanager_refresh_several_times() mm->updateProjectInfo(pi); CPlusPlus::Snapshot snapshot; - QStringList refreshedFiles; + QSet refreshedFiles; CPlusPlus::Document::Ptr document; QByteArray defines = "#define FIRST_DEFINE"; @@ -441,7 +441,7 @@ void CppToolsPlugin::test_modelmanager_refresh_test_for_changes() QFuture firstFuture = mm->updateProjectInfo(pi); QVERIFY(firstFuture.isStarted() || firstFuture.isRunning()); firstFuture.waitForFinished(); - const QStringList refreshedFiles = helper.waitForRefreshedSourceFiles(); + const QSet refreshedFiles = helper.waitForRefreshedSourceFiles(); QCOMPARE(refreshedFiles.size(), 1); QVERIFY(refreshedFiles.contains(testCpp)); @@ -475,7 +475,7 @@ void CppToolsPlugin::test_modelmanager_refresh_added_and_purge_removed() pi.appendProjectPart(part); CPlusPlus::Snapshot snapshot; - QStringList refreshedFiles; + QSet refreshedFiles; refreshedFiles = updateProjectInfo(mm, &helper, pi); @@ -533,7 +533,7 @@ void CppToolsPlugin::test_modelmanager_refresh_timeStampModified_if_sourcefiles_ Document::Ptr document; CPlusPlus::Snapshot snapshot; - QStringList refreshedFiles; + QSet refreshedFiles; refreshedFiles = updateProjectInfo(mm, &helper, pi); @@ -608,7 +608,7 @@ void CppToolsPlugin::test_modelmanager_refresh_timeStampModified_if_sourcefiles_ /// files of the first project. void CppToolsPlugin::test_modelmanager_snapshot_after_two_projects() { - QStringList refreshedFiles; + QSet refreshedFiles; ModelManagerTestHelper helper; ProjectCreator project1(&helper); ProjectCreator project2(&helper); @@ -622,7 +622,7 @@ void CppToolsPlugin::test_modelmanager_snapshot_after_two_projects() << _("main.cpp")); refreshedFiles = updateProjectInfo(mm, &helper, project1.projectInfo); - QCOMPARE(refreshedFiles.toSet(), project1.projectFiles.toSet()); + QCOMPARE(refreshedFiles, project1.projectFiles.toSet()); const int snapshotSizeAfterProject1 = mm->snapshot().size(); foreach (const QString &file, project1.projectFiles) @@ -636,7 +636,7 @@ void CppToolsPlugin::test_modelmanager_snapshot_after_two_projects() << _("main.cpp")); refreshedFiles = updateProjectInfo(mm, &helper, project2.projectInfo); - QCOMPARE(refreshedFiles.toSet(), project2.projectFiles.toSet()); + QCOMPARE(refreshedFiles, project2.projectFiles.toSet()); const int snapshotSizeAfterProject2 = mm->snapshot().size(); QVERIFY(snapshotSizeAfterProject2 > snapshotSizeAfterProject1); diff --git a/src/plugins/cpptools/cppmodelmanagerinterface.h b/src/plugins/cpptools/cppmodelmanagerinterface.h index f48950499fea95da70244be2dbe297a0fff471d9..e68caee78fc6523f6d5422fe7bbb7791615a105b 100644 --- a/src/plugins/cpptools/cppmodelmanagerinterface.h +++ b/src/plugins/cpptools/cppmodelmanagerinterface.h @@ -110,7 +110,7 @@ public: virtual void renameMacroUsages(const CPlusPlus::Macro ¯o, const QString &replacement = QString()) = 0; virtual void findMacroUsages(const CPlusPlus::Macro ¯o) = 0; - virtual void finishedRefreshingSourceFiles(const QStringList &files) = 0; + virtual void finishedRefreshingSourceFiles(const QSet &files) = 0; virtual void addModelManagerSupport(ModelManagerSupport *modelManagerSupport) = 0; virtual ModelManagerSupport *modelManagerSupportForMimeType(const QString &mimeType) const = 0; @@ -132,7 +132,7 @@ signals: void aboutToRemoveFiles(const QStringList &files); void documentUpdated(CPlusPlus::Document::Ptr doc); - void sourceFilesRefreshed(const QStringList &files); + void sourceFilesRefreshed(const QSet &files); /// \brief Emitted after updateProjectInfo function is called on the model-manager. /// @@ -143,7 +143,7 @@ signals: public slots: // Documented in source file. - virtual QFuture updateSourceFiles(const QStringList &sourceFiles, + virtual QFuture updateSourceFiles(const QSet &sourceFiles, ProgressNotificationMode mode = ReservedProgressNotification) = 0; virtual void updateModifiedSourceFiles() = 0; diff --git a/src/plugins/cpptools/cppprojects.cpp b/src/plugins/cpptools/cppprojects.cpp index 6554e4e66794091900885842dde92f0bd7eee258..eb99b11626d5ab3d57ae7b16dc6c68d072483124 100644 --- a/src/plugins/cpptools/cppprojects.cpp +++ b/src/plugins/cpptools/cppprojects.cpp @@ -183,10 +183,8 @@ void ProjectInfo::appendProjectPart(const ProjectPart::Ptr &part) } // Update source files - QSet srcs = QSet::fromList(m_sourceFiles); foreach (const ProjectFile &file, part->files) - srcs.insert(file.path); - m_sourceFiles = srcs.toList(); + m_sourceFiles.insert(file.path); // Update defines if (!m_defines.isEmpty()) @@ -213,7 +211,7 @@ const ProjectPart::HeaderPaths ProjectInfo::headerPaths() const return m_headerPaths; } -const QStringList ProjectInfo::sourceFiles() const +const QSet ProjectInfo::sourceFiles() const { return m_sourceFiles; } diff --git a/src/plugins/cpptools/cppprojects.h b/src/plugins/cpptools/cppprojects.h index 88f3241ce3bdfb6e38100ec823db67d42488d3bf..056790b113e78ed4c49ba740172cb05497308df9 100644 --- a/src/plugins/cpptools/cppprojects.h +++ b/src/plugins/cpptools/cppprojects.h @@ -38,6 +38,7 @@ #include #include +#include namespace CppTools { @@ -148,7 +149,7 @@ public: void clearProjectParts(); const ProjectPart::HeaderPaths headerPaths() const; - const QStringList sourceFiles() const; + const QSet sourceFiles() const; const QByteArray defines() const; private: @@ -156,7 +157,7 @@ private: QList m_projectParts; // The members below are (re)calculated from the project parts once a part is appended. ProjectPart::HeaderPaths m_headerPaths; - QStringList m_sourceFiles; + QSet m_sourceFiles; QByteArray m_defines; }; diff --git a/src/plugins/cpptools/cpprefactoringchanges.cpp b/src/plugins/cpptools/cpprefactoringchanges.cpp index 64d4a1f77dd499d07470255c597db10d30d2e4f9..3a1f06465a09b426a4f6f408e5c0bcc2daf0cec9 100644 --- a/src/plugins/cpptools/cpprefactoringchanges.cpp +++ b/src/plugins/cpptools/cpprefactoringchanges.cpp @@ -74,7 +74,7 @@ public: virtual void fileChanged(const QString &fileName) { - m_modelManager->updateSourceFiles(QStringList(fileName)); + m_modelManager->updateSourceFiles(QSet() << fileName); } Snapshot m_snapshot; diff --git a/src/plugins/cpptools/cppsourceprocessor.cpp b/src/plugins/cpptools/cppsourceprocessor.cpp index 92d0597a87854bd5fcd7f5c60e48187e57d0f17c..6e6f0147b4f8336e31ac3130357580cf8dfe15aa 100644 --- a/src/plugins/cpptools/cppsourceprocessor.cpp +++ b/src/plugins/cpptools/cppsourceprocessor.cpp @@ -174,8 +174,10 @@ void CppSourceProcessor::addFrameworkPath(const ProjectPart::HeaderPath &framewo } } -void CppSourceProcessor::setTodo(const QStringList &files) -{ m_todo = QSet::fromList(files); } +void CppSourceProcessor::setTodo(const QSet &files) +{ + m_todo = files; +} void CppSourceProcessor::run(const QString &fileName, const QStringList &initialIncludes) diff --git a/src/plugins/cpptools/cppsourceprocessor.h b/src/plugins/cpptools/cppsourceprocessor.h index d2312defa43f1bf822382e078f3e99e96365ac88..e503bd5b16ddeaad95bde554a26f9145690987ae 100644 --- a/src/plugins/cpptools/cppsourceprocessor.h +++ b/src/plugins/cpptools/cppsourceprocessor.h @@ -71,7 +71,7 @@ public: void setRevision(unsigned revision); void setWorkingCopy(const CppTools::WorkingCopy &workingCopy); void setHeaderPaths(const ProjectPart::HeaderPaths &headerPaths); - void setTodo(const QStringList &files); + void setTodo(const QSet &files); void run(const QString &fileName, const QStringList &initialIncludes = QStringList()); void removeFromCache(const QString &fileName); diff --git a/src/plugins/cpptools/cppsourceprocessor_test.cpp b/src/plugins/cpptools/cppsourceprocessor_test.cpp index 9b145949544642f173329d7e64403717d31827fc..9be1d9848be2f498009261554c8f44dd54f63093 100644 --- a/src/plugins/cpptools/cppsourceprocessor_test.cpp +++ b/src/plugins/cpptools/cppsourceprocessor_test.cpp @@ -129,7 +129,7 @@ void CppToolsPlugin::test_cppsourceprocessor_includes_cyclic() { const QString fileName1 = TestIncludePaths::testFilePath(QLatin1String("cyclic1.h")); const QString fileName2 = TestIncludePaths::testFilePath(QLatin1String("cyclic2.h")); - const QStringList sourceFiles = QStringList() << fileName1 << fileName2; + const QSet sourceFiles = QSet() << fileName1 << fileName2; // Create global snapshot (needed in BuiltinEditorDocumentParser) TestCase testCase; diff --git a/src/plugins/cpptools/cpptoolsplugin.cpp b/src/plugins/cpptools/cpptoolsplugin.cpp index 06007a345a731477d54209cd320f9dfed1d6eb32..debda7972c19dcdb984684b3e1bbf49adb8a8861 100644 --- a/src/plugins/cpptools/cpptoolsplugin.cpp +++ b/src/plugins/cpptools/cpptoolsplugin.cpp @@ -139,8 +139,10 @@ bool CppToolsPlugin::initialize(const QStringList &arguments, QString *error) CppModelManager *modelManager = CppModelManager::instance(); connect(VcsManager::instance(), SIGNAL(repositoryChanged(QString)), modelManager, SLOT(updateModifiedSourceFiles())); - connect(DocumentManager::instance(), SIGNAL(filesChangedInternally(QStringList)), - modelManager, SLOT(updateSourceFiles(QStringList))); + connect(DocumentManager::instance(), &DocumentManager::filesChangedInternally, + [=](const QStringList &files) { + modelManager->updateSourceFiles(files.toSet()); + }); CppLocatorData *locatorData = new CppLocatorData; connect(modelManager, SIGNAL(documentUpdated(CPlusPlus::Document::Ptr)), diff --git a/src/plugins/cpptools/cpptoolstestcase.cpp b/src/plugins/cpptools/cpptoolstestcase.cpp index 554a993596f4bc4ddec0d860ccb36831f5f82652..c91451d179b93a4254a9ce9a3804734929d9e1f8 100644 --- a/src/plugins/cpptools/cpptoolstestcase.cpp +++ b/src/plugins/cpptools/cpptoolstestcase.cpp @@ -45,7 +45,7 @@ static bool closeEditorsWithoutGarbageCollectorInvocation(const QList &filePaths) { foreach (const QString &filePath, filePaths) { if (!snapshot.contains(filePath)) { @@ -125,7 +125,7 @@ bool TestCase::garbageCollectGlobalSnapshot() return globalSnapshot().isEmpty(); } -bool TestCase::parseFiles(const QStringList &filePaths) +bool TestCase::parseFiles(const QSet &filePaths) { CppModelManagerInterface::instance()->updateSourceFiles(filePaths).waitForFinished(); QCoreApplication::processEvents(); @@ -143,7 +143,7 @@ bool TestCase::parseFiles(const QStringList &filePaths) bool TestCase::parseFiles(const QString &filePath) { - return parseFiles(QStringList(filePath)); + return parseFiles(QSet() << filePath); } void TestCase::closeEditorAtEndOfTestCase(Core::IEditor *editor) diff --git a/src/plugins/cpptools/cpptoolstestcase.h b/src/plugins/cpptools/cpptoolstestcase.h index c80438122dafb5dcfa3ac7f23cbe8a4e733cf6df..c222aa506c8c0587ce16c4a41eba51e6bdc0170e 100644 --- a/src/plugins/cpptools/cpptoolstestcase.h +++ b/src/plugins/cpptools/cpptoolstestcase.h @@ -76,7 +76,7 @@ public: static bool closeEditorWithoutGarbageCollectorInvocation(Core::IEditor *editor); static bool parseFiles(const QString &filePath); - static bool parseFiles(const QStringList &filePaths); + static bool parseFiles(const QSet &filePaths); static CPlusPlus::Snapshot globalSnapshot(); static bool garbageCollectGlobalSnapshot(); diff --git a/src/plugins/cpptools/modelmanagertesthelper.cpp b/src/plugins/cpptools/modelmanagertesthelper.cpp index 571a72c785b327690b40a663c693406c16007b46..43896781b17fa470d32b6572386886b670ac4fe9 100644 --- a/src/plugins/cpptools/modelmanagertesthelper.cpp +++ b/src/plugins/cpptools/modelmanagertesthelper.cpp @@ -55,9 +55,12 @@ ModelManagerTestHelper::ModelManagerTestHelper(QObject *parent) : CppModelManager *mm = CppModelManager::instance(); assert(mm); - connect(this, SIGNAL(aboutToRemoveProject(ProjectExplorer::Project*)), mm, SLOT(onAboutToRemoveProject(ProjectExplorer::Project*))); - connect(this, SIGNAL(projectAdded(ProjectExplorer::Project*)), mm, SLOT(onProjectAdded(ProjectExplorer::Project*))); - connect(mm, SIGNAL(sourceFilesRefreshed(QStringList)), this, SLOT(sourceFilesRefreshed(QStringList))); + connect(this, SIGNAL(aboutToRemoveProject(ProjectExplorer::Project*)), + mm, SLOT(onAboutToRemoveProject(ProjectExplorer::Project*))); + connect(this, SIGNAL(projectAdded(ProjectExplorer::Project*)), + mm, SLOT(onProjectAdded(ProjectExplorer::Project*))); + connect(mm, SIGNAL(sourceFilesRefreshed(QSet)), + this, SLOT(sourceFilesRefreshed(QSet))); connect(mm, SIGNAL(gcFinished()), this, SLOT(gcFinished())); cleanup(); @@ -110,7 +113,7 @@ void ModelManagerTestHelper::resetRefreshedSourceFiles() m_refreshHappened = false; } -QStringList ModelManagerTestHelper::waitForRefreshedSourceFiles() +QSet ModelManagerTestHelper::waitForRefreshedSourceFiles() { while (!m_refreshHappened) QCoreApplication::processEvents(); @@ -126,7 +129,7 @@ void ModelManagerTestHelper::waitForFinishedGc() QCoreApplication::processEvents(); } -void ModelManagerTestHelper::sourceFilesRefreshed(const QStringList &files) +void ModelManagerTestHelper::sourceFilesRefreshed(const QSet &files) { m_lastRefreshedSourceFiles = files; m_refreshHappened = true; diff --git a/src/plugins/cpptools/modelmanagertesthelper.h b/src/plugins/cpptools/modelmanagertesthelper.h index fdc1e449ee48119e7ce8744597e3fe0d112541be..f3bd2dd8790430c4288cd7b8363b795d0a387d90 100644 --- a/src/plugins/cpptools/modelmanagertesthelper.h +++ b/src/plugins/cpptools/modelmanagertesthelper.h @@ -80,7 +80,7 @@ public: Project *createProject(const QString &name); void resetRefreshedSourceFiles(); - QStringList waitForRefreshedSourceFiles(); + QSet waitForRefreshedSourceFiles(); void waitForFinishedGc(); signals: @@ -88,13 +88,13 @@ signals: void projectAdded(ProjectExplorer::Project*); public slots: - void sourceFilesRefreshed(const QStringList &files); + void sourceFilesRefreshed(const QSet &files); void gcFinished(); private: bool m_gcFinished; bool m_refreshHappened; - QStringList m_lastRefreshedSourceFiles; + QSet m_lastRefreshedSourceFiles; }; } // namespace Internal diff --git a/src/plugins/cpptools/typehierarchybuilder_test.cpp b/src/plugins/cpptools/typehierarchybuilder_test.cpp index a96e3224546e75bfa4932e21d5c801980c6b5d7a..0a933dd8b99aa29cd7de2c77f95bbfa4debcc2d4 100644 --- a/src/plugins/cpptools/typehierarchybuilder_test.cpp +++ b/src/plugins/cpptools/typehierarchybuilder_test.cpp @@ -103,7 +103,7 @@ public: QVERIFY(succeededSoFar()); // Write files - QStringList filePaths; + QSet filePaths; foreach (const Tests::TestDocument &document, documents) { QVERIFY(document.writeToDisk()); filePaths << document.filePath(); @@ -114,7 +114,7 @@ public: const Snapshot snapshot = globalSnapshot(); // Get class for which to generate the hierarchy - const Document::Ptr firstDocument = snapshot.document(filePaths.first()); + const Document::Ptr firstDocument = snapshot.document(documents.first().filePath()); QVERIFY(firstDocument); QVERIFY(firstDocument->diagnosticMessages().isEmpty()); Class *clazz = FindFirstClassInDocument()(firstDocument); diff --git a/src/plugins/genericprojectmanager/cppmodelmanagerhelper.cpp b/src/plugins/genericprojectmanager/cppmodelmanagerhelper.cpp index 33621345b22a25f224110bd80f39b103c25ae86d..c645837865df6d8e8c8a6c983d5a6043205d55eb 100644 --- a/src/plugins/genericprojectmanager/cppmodelmanagerhelper.cpp +++ b/src/plugins/genericprojectmanager/cppmodelmanagerhelper.cpp @@ -40,8 +40,8 @@ using namespace GenericProjectManager::Internal::Tests; CppModelManagerHelper::CppModelManagerHelper(QObject *parent) : QObject(parent) { - connect(cppModelManager(), SIGNAL(sourceFilesRefreshed(const QStringList &)), - this, SLOT(onSourceFilesRefreshed(const QStringList &))); + connect(cppModelManager(), SIGNAL(sourceFilesRefreshed(const QSet &)), + this, SLOT(onSourceFilesRefreshed(const QSet &))); } @@ -59,7 +59,7 @@ void CppModelManagerHelper::waitForSourceFilesRefreshed(const QStringList &files { QTime t; t.start(); - QSignalSpy spy(cppModelManager(), SIGNAL(sourceFilesRefreshed(const QStringList &))); + QSignalSpy spy(cppModelManager(), SIGNAL(sourceFilesRefreshed(const QSet &))); foreach (const QString &file, files) { while (!m_refreshedSourceFiles.contains(file)) { @@ -83,7 +83,7 @@ void CppModelManagerHelper::waitForSourceFilesRefreshed(const QStringList &files } } -void CppModelManagerHelper::onSourceFilesRefreshed(const QStringList &files) +void CppModelManagerHelper::onSourceFilesRefreshed(const QSet &files) { - m_refreshedSourceFiles += files; + m_refreshedSourceFiles.unite(files); } diff --git a/src/plugins/genericprojectmanager/cppmodelmanagerhelper.h b/src/plugins/genericprojectmanager/cppmodelmanagerhelper.h index e854c73c8834ccbd7521463751763821ac22ae11..d5e2c4d4f6b809b6f81579a78de0cd2ad911ae02 100644 --- a/src/plugins/genericprojectmanager/cppmodelmanagerhelper.h +++ b/src/plugins/genericprojectmanager/cppmodelmanagerhelper.h @@ -51,10 +51,10 @@ public: void waitForSourceFilesRefreshed(const QStringList &files, int timeOut = defaultTimeOut); private slots: - void onSourceFilesRefreshed(const QStringList &files); + void onSourceFilesRefreshed(const QSet &files); private: - QStringList m_refreshedSourceFiles; + QSet m_refreshedSourceFiles; }; } // Tests namespace diff --git a/src/plugins/todo/cpptodoitemsscanner.cpp b/src/plugins/todo/cpptodoitemsscanner.cpp index b001edc5ff57990d9218c38053fa59bbb4b0005a..ce938b10fd5c5fa1daa9b1d71fb68159a718e485 100644 --- a/src/plugins/todo/cpptodoitemsscanner.cpp +++ b/src/plugins/todo/cpptodoitemsscanner.cpp @@ -52,9 +52,9 @@ void CppTodoItemsScanner::keywordListChanged() CppTools::CppModelManagerInterface *modelManager = CppTools::CppModelManagerInterface::instance(); - QStringList filesToBeUpdated; + QSet filesToBeUpdated; foreach (const CppTools::ProjectInfo &info, modelManager->projectInfos()) - filesToBeUpdated << info.project().data()->files(ProjectExplorer::Project::ExcludeGeneratedFiles); + filesToBeUpdated.unite(info.project().data()->files(ProjectExplorer::Project::ExcludeGeneratedFiles).toSet()); modelManager->updateSourceFiles(filesToBeUpdated); }