Commit 7290c43d authored by Erik Verbruggen's avatar Erik Verbruggen Committed by Nikolai Kosjar

C++: update project info once after finishing adding all project parts.

So that recalculating the information is not O(n^2) but linear.

Change-Id: I69903e0b5ad321d071804d782ad634a3f300e71a
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@digia.com>
parent 9c1f44e9
......@@ -426,5 +426,6 @@ void AutotoolsProject::updateCppCodeModel()
foreach (Core::Id language, languages)
setProjectLanguage(language, true);
pInfo.finish();
m_codeModelFuture = modelManager->updateProjectInfo(pInfo);
}
......@@ -350,6 +350,7 @@ bool CMakeProject::parseCMakeLists()
}
m_codeModelFuture.cancel();
pinfo.finish();
m_codeModelFuture = modelmanager->updateProjectInfo(pinfo);
}
......
......@@ -104,6 +104,7 @@ public:
part->files.append(projectFile);
}
projectInfo.appendProjectPart(part);
projectInfo.finish();
}
ModelManagerTestHelper *modelManagerTestHelper;
......@@ -227,6 +228,7 @@ void CppToolsPlugin::test_modelmanager_paths_are_clean()
<< HeaderPath(testDataDir.includeDir(false), HeaderPath::IncludePath)
<< HeaderPath(testDataDir.frameworksDir(false), HeaderPath::FrameworkPath);
pi.appendProjectPart(part);
pi.finish();
mm->updateProjectInfo(pi);
......@@ -265,6 +267,7 @@ void CppToolsPlugin::test_modelmanager_framework_headers()
_("test_modelmanager_framework_headers.cpp"));
part->files << ProjectFile(source, ProjectFile::CXXSource);
pi.appendProjectPart(part);
pi.finish();
mm->updateProjectInfo(pi).waitForFinished();
QCoreApplication::processEvents();
......@@ -314,6 +317,7 @@ void CppToolsPlugin::test_modelmanager_refresh_also_includes_of_project_files()
<< HeaderPath(testDataDir.includeDir(false), HeaderPath::IncludePath);
part->files.append(ProjectFile(testCpp, ProjectFile::CXXSource));
pi.appendProjectPart(part);
pi.finish();
QSet<QString> refreshedFiles = updateProjectInfo(mm, &helper, pi);
QCOMPARE(refreshedFiles.size(), 1);
......@@ -331,6 +335,7 @@ void CppToolsPlugin::test_modelmanager_refresh_also_includes_of_project_files()
part->projectDefines = QByteArray("#define TEST_DEFINE 1\n");
pi.clearProjectParts();
pi.appendProjectPart(part);
pi.finish();
refreshedFiles = updateProjectInfo(mm, &helper, pi);
......@@ -372,6 +377,7 @@ void CppToolsPlugin::test_modelmanager_refresh_several_times()
part->files.append(ProjectFile(testHeader2, ProjectFile::CXXHeader));
part->files.append(ProjectFile(testCpp, ProjectFile::CXXSource));
pi.appendProjectPart(part);
pi.finish();
mm->updateProjectInfo(pi);
CPlusPlus::Snapshot snapshot;
......@@ -391,6 +397,7 @@ void CppToolsPlugin::test_modelmanager_refresh_several_times()
part->files.append(ProjectFile(testHeader2, ProjectFile::CXXHeader));
part->files.append(ProjectFile(testCpp, ProjectFile::CXXSource));
pi.appendProjectPart(part);
pi.finish();
refreshedFiles = updateProjectInfo(mm, &helper, pi);
QCOMPARE(refreshedFiles.size(), 3);
......@@ -435,6 +442,7 @@ void CppToolsPlugin::test_modelmanager_refresh_test_for_changes()
part->qtVersion = ProjectPart::Qt5;
part->files.append(ProjectFile(testCpp, ProjectFile::CXXSource));
pi.appendProjectPart(part);
pi.finish();
// Reindexing triggers a reparsing thread
helper.resetRefreshedSourceFiles();
......@@ -473,6 +481,7 @@ void CppToolsPlugin::test_modelmanager_refresh_added_and_purge_removed()
part->files.append(ProjectFile(testCpp, ProjectFile::CXXSource));
part->files.append(ProjectFile(testHeader1, ProjectFile::CXXHeader));
pi.appendProjectPart(part);
pi.finish();
CPlusPlus::Snapshot snapshot;
QSet<QString> refreshedFiles;
......@@ -495,6 +504,7 @@ void CppToolsPlugin::test_modelmanager_refresh_added_and_purge_removed()
newPart->files.append(ProjectFile(testCpp, ProjectFile::CXXSource));
newPart->files.append(ProjectFile(testHeader2, ProjectFile::CXXHeader));
pi.appendProjectPart(newPart);
pi.finish();
refreshedFiles = updateProjectInfo(mm, &helper, pi);
......@@ -529,7 +539,9 @@ void CppToolsPlugin::test_modelmanager_refresh_timeStampModified_if_sourcefiles_
part->qtVersion = ProjectPart::Qt5;
foreach (const ProjectFile &file, initialProjectFiles)
part->files.append(file);
pi.clearProjectParts();
pi.appendProjectPart(part);
pi.finish();
Document::Ptr document;
CPlusPlus::Snapshot snapshot;
......@@ -563,6 +575,7 @@ void CppToolsPlugin::test_modelmanager_refresh_timeStampModified_if_sourcefiles_
part->files.append(file);
pi.clearProjectParts();
pi.appendProjectPart(part);
pi.finish();
refreshedFiles = updateProjectInfo(mm, &helper, pi);
......@@ -835,6 +848,7 @@ void CppToolsPlugin::test_modelmanager_defines_per_project()
ProjectInfo pi = mm->projectInfo(project);
pi.appendProjectPart(part1);
pi.appendProjectPart(part2);
pi.finish();
updateProjectInfo(mm, &helper, pi);
QCOMPARE(mm->snapshot().size(), 4);
......@@ -910,6 +924,7 @@ void CppToolsPlugin::test_modelmanager_precompiled_headers()
ProjectInfo pi = mm->projectInfo(project);
pi.appendProjectPart(part1);
pi.appendProjectPart(part2);
pi.finish();
updateProjectInfo(mm, &helper, pi);
QCOMPARE(mm->snapshot().size(), 4);
......@@ -990,6 +1005,7 @@ void CppToolsPlugin::test_modelmanager_defines_per_editor()
ProjectInfo pi = mm->projectInfo(project);
pi.appendProjectPart(part1);
pi.appendProjectPart(part2);
pi.finish();
updateProjectInfo(mm, &helper, pi);
......
......@@ -166,15 +166,17 @@ const QList<ProjectPart::Ptr> ProjectInfo::projectParts() const
void ProjectInfo::appendProjectPart(const ProjectPart::Ptr &part)
{
if (!part)
return;
if (part)
m_projectParts.append(part);
}
void ProjectInfo::finish()
{
typedef ProjectPart::HeaderPath HeaderPath;
QSet<HeaderPath> incs;
foreach (const ProjectPart::Ptr &part, m_projectParts) {
// Update header paths
QSet<HeaderPath> incs = QSet<HeaderPath>::fromList(m_headerPaths);
foreach (const HeaderPath &hp, part->headerPaths) {
if (!incs.contains(hp)) {
incs.insert(hp);
......@@ -187,8 +189,6 @@ void ProjectInfo::appendProjectPart(const ProjectPart::Ptr &part)
m_sourceFiles.insert(file.path);
// Update defines
if (!m_defines.isEmpty())
m_defines.append('\n');
m_defines.append(part->toolchainDefines);
m_defines.append(part->projectDefines);
if (!part->projectConfigFile.isEmpty()) {
......@@ -196,6 +196,7 @@ void ProjectInfo::appendProjectPart(const ProjectPart::Ptr &part)
m_defines += ProjectPart::readProjectConfigFile(part);
m_defines.append('\n');
}
}
}
void ProjectInfo::clearProjectParts()
......
......@@ -146,6 +146,7 @@ public:
const QList<ProjectPart::Ptr> projectParts() const;
void appendProjectPart(const ProjectPart::Ptr &part);
void finish();
void clearProjectParts();
const ProjectPart::HeaderPaths headerPaths() const;
......
......@@ -346,6 +346,7 @@ void GenericProject::refreshCppCodeModel()
foreach (Core::Id language, languages)
setProjectLanguage(language, true);
pInfo.finish();
m_codeModelFuture = modelManager->updateProjectInfo(pInfo);
}
......
......@@ -741,6 +741,7 @@ void QbsProject::updateCppCodeModel(const qbs::ProjectData &prj)
if (pinfo.projectParts().isEmpty())
return;
pinfo.finish();
QtSupport::UiCodeModelManager::update(this, uiFiles);
......
......@@ -620,6 +620,7 @@ void QmakeProject::updateCppCodeModel()
if (!cppPart->files.isEmpty())
objcppPart->displayName += QLatin1String(" (ObjC++)");
}
pinfo.finish();
// Also update Ui Code Model Support:
QtSupport::UiCodeModelManager::update(this, uiCodeModelData);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment