forked from qt-creator/qt-creator
CppTools: Do not put configuration document into global snapshot and working copy
These are remnants of the time when we had only one snapshot. Change-Id: I6ff4db645d1065a0ef195834890e0774e2e2c60e Reviewed-by: David Schulz <david.schulz@qt.io> Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
This commit is contained in:
@@ -382,8 +382,6 @@ static AnalyzeUnits unitsToAnalyzeFromProjectParts(const QList<ProjectPart::Ptr>
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
foreach (const ProjectFile &file, projectPart->files) {
|
foreach (const ProjectFile &file, projectPart->files) {
|
||||||
if (file.path == CppModelManager::configurationFileName())
|
|
||||||
continue;
|
|
||||||
QTC_CHECK(file.kind != ProjectFile::Unclassified);
|
QTC_CHECK(file.kind != ProjectFile::Unclassified);
|
||||||
if (ProjectFile::isSource(file.kind)) {
|
if (ProjectFile::isSource(file.kind)) {
|
||||||
const CompilerOptionsBuilder::PchUsage pchUsage = CppTools::getPchUsage();
|
const CompilerOptionsBuilder::PchUsage pchUsage = CppTools::getPchUsage();
|
||||||
|
@@ -355,6 +355,7 @@ QFuture<void> BuiltinIndexingSupport::refreshSourceFiles(const QSet<QString> &so
|
|||||||
params.indexerFileSizeLimitInMb = indexerFileSizeLimitInMb();
|
params.indexerFileSizeLimitInMb = indexerFileSizeLimitInMb();
|
||||||
params.headerPaths = mgr->headerPaths();
|
params.headerPaths = mgr->headerPaths();
|
||||||
params.workingCopy = mgr->workingCopy();
|
params.workingCopy = mgr->workingCopy();
|
||||||
|
params.workingCopy.insert(mgr->configurationFileName(), mgr->definedMacros());
|
||||||
params.sourceFiles = sourceFiles;
|
params.sourceFiles = sourceFiles;
|
||||||
|
|
||||||
QFuture<void> result = Utils::runAsync(mgr->sharedThreadPool(), parse, params);
|
QFuture<void> result = Utils::runAsync(mgr->sharedThreadPool(), parse, params);
|
||||||
|
@@ -593,11 +593,6 @@ WorkingCopy CppModelManager::buildWorkingCopyList()
|
|||||||
workingCopy.insert(es->fileName(), es->contents(), es->revision());
|
workingCopy.insert(es->fileName(), es->contents(), es->revision());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the project configuration file
|
|
||||||
QByteArray conf = codeModelConfiguration();
|
|
||||||
conf += definedMacros();
|
|
||||||
workingCopy.insert(configurationFileName(), conf);
|
|
||||||
|
|
||||||
return workingCopy;
|
return workingCopy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -850,12 +845,6 @@ QFuture<void> CppModelManager::updateProjectInfo(const ProjectInfo &newProjectIn
|
|||||||
removeProjectInfoFilesAndIncludesFromSnapshot(oldProjectInfo);
|
removeProjectInfoFilesAndIncludesFromSnapshot(oldProjectInfo);
|
||||||
filesToReindex.unite(newSourceFiles);
|
filesToReindex.unite(newSourceFiles);
|
||||||
|
|
||||||
// The "configuration file" includes all defines and therefore should be updated
|
|
||||||
if (comparer.definesChanged()) {
|
|
||||||
QMutexLocker snapshotLocker(&d->m_snapshotMutex);
|
|
||||||
d->m_snapshot.remove(configurationFileName());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Otherwise check for added and modified files
|
// Otherwise check for added and modified files
|
||||||
} else {
|
} else {
|
||||||
const QSet<QString> addedFiles = comparer.addedFiles();
|
const QSet<QString> addedFiles = comparer.addedFiles();
|
||||||
@@ -985,6 +974,9 @@ bool CppModelManager::isClangCodeModelActive() const
|
|||||||
|
|
||||||
void CppModelManager::emitDocumentUpdated(Document::Ptr doc)
|
void CppModelManager::emitDocumentUpdated(Document::Ptr doc)
|
||||||
{
|
{
|
||||||
|
if (Client::isInjectedFile(doc->fileName()))
|
||||||
|
return;
|
||||||
|
|
||||||
if (replaceDocument(doc))
|
if (replaceDocument(doc))
|
||||||
emit documentUpdated(doc);
|
emit documentUpdated(doc);
|
||||||
}
|
}
|
||||||
|
@@ -632,7 +632,7 @@ void CppToolsPlugin::test_modelmanager_extraeditorsupport_uiFiles()
|
|||||||
CppModelManager *mm = CppModelManager::instance();
|
CppModelManager *mm = CppModelManager::instance();
|
||||||
WorkingCopy workingCopy = mm->workingCopy();
|
WorkingCopy workingCopy = mm->workingCopy();
|
||||||
|
|
||||||
QCOMPARE(workingCopy.size(), 2); // mm->configurationFileName() and "ui_*.h"
|
QCOMPARE(workingCopy.size(), 1);
|
||||||
|
|
||||||
QStringList fileNamesInWorkinCopy;
|
QStringList fileNamesInWorkinCopy;
|
||||||
QHashIterator<Utils::FileName, QPair<QByteArray, unsigned> > it = workingCopy.iterator();
|
QHashIterator<Utils::FileName, QPair<QByteArray, unsigned> > it = workingCopy.iterator();
|
||||||
@@ -642,8 +642,7 @@ void CppToolsPlugin::test_modelmanager_extraeditorsupport_uiFiles()
|
|||||||
}
|
}
|
||||||
fileNamesInWorkinCopy.sort();
|
fileNamesInWorkinCopy.sort();
|
||||||
const QString expectedUiHeaderFileName = _("ui_mainwindow.h");
|
const QString expectedUiHeaderFileName = _("ui_mainwindow.h");
|
||||||
QCOMPARE(fileNamesInWorkinCopy.at(0), mm->configurationFileName());
|
QCOMPARE(fileNamesInWorkinCopy.at(0), expectedUiHeaderFileName);
|
||||||
QCOMPARE(fileNamesInWorkinCopy.at(1), expectedUiHeaderFileName);
|
|
||||||
|
|
||||||
// Check CppSourceProcessor / includes.
|
// Check CppSourceProcessor / includes.
|
||||||
// The CppSourceProcessor is expected to find the ui_* file in the working copy.
|
// The CppSourceProcessor is expected to find the ui_* file in the working copy.
|
||||||
@@ -794,7 +793,7 @@ void CppToolsPlugin::test_modelmanager_defines_per_project()
|
|||||||
pi.appendProjectPart(part2);
|
pi.appendProjectPart(part2);
|
||||||
|
|
||||||
helper.updateProjectInfo(pi);
|
helper.updateProjectInfo(pi);
|
||||||
QCOMPARE(mm->snapshot().size(), 4);
|
QCOMPARE(mm->snapshot().size(), 3);
|
||||||
|
|
||||||
// Open a file in the editor
|
// Open a file in the editor
|
||||||
QCOMPARE(Core::DocumentModel::openedDocuments().size(), 0);
|
QCOMPARE(Core::DocumentModel::openedDocuments().size(), 0);
|
||||||
@@ -862,7 +861,7 @@ void CppToolsPlugin::test_modelmanager_precompiled_headers()
|
|||||||
pi.appendProjectPart(part2);
|
pi.appendProjectPart(part2);
|
||||||
|
|
||||||
helper.updateProjectInfo(pi);
|
helper.updateProjectInfo(pi);
|
||||||
QCOMPARE(mm->snapshot().size(), 4);
|
QCOMPARE(mm->snapshot().size(), 3);
|
||||||
|
|
||||||
// Open a file in the editor
|
// Open a file in the editor
|
||||||
QCOMPARE(Core::DocumentModel::openedDocuments().size(), 0);
|
QCOMPARE(Core::DocumentModel::openedDocuments().size(), 0);
|
||||||
@@ -944,7 +943,7 @@ void CppToolsPlugin::test_modelmanager_defines_per_editor()
|
|||||||
|
|
||||||
helper.updateProjectInfo(pi);
|
helper.updateProjectInfo(pi);
|
||||||
|
|
||||||
QCOMPARE(mm->snapshot().size(), 4);
|
QCOMPARE(mm->snapshot().size(), 3);
|
||||||
|
|
||||||
// Open a file in the editor
|
// Open a file in the editor
|
||||||
QCOMPARE(Core::DocumentModel::openedDocuments().size(), 0);
|
QCOMPARE(Core::DocumentModel::openedDocuments().size(), 0);
|
||||||
|
@@ -423,11 +423,8 @@ bool VerifyCleanCppModelManager::isClean(bool testOnlyForCleanedProjects)
|
|||||||
RETURN_FALSE_IF_NOT(mm->headerPaths().isEmpty());
|
RETURN_FALSE_IF_NOT(mm->headerPaths().isEmpty());
|
||||||
RETURN_FALSE_IF_NOT(mm->definedMacros().isEmpty());
|
RETURN_FALSE_IF_NOT(mm->definedMacros().isEmpty());
|
||||||
RETURN_FALSE_IF_NOT(mm->projectFiles().isEmpty());
|
RETURN_FALSE_IF_NOT(mm->projectFiles().isEmpty());
|
||||||
if (!testOnlyForCleanedProjects) {
|
if (!testOnlyForCleanedProjects)
|
||||||
RETURN_FALSE_IF_NOT(mm->snapshot().isEmpty());
|
RETURN_FALSE_IF_NOT(mm->snapshot().isEmpty());
|
||||||
RETURN_FALSE_IF_NOT(mm->workingCopy().size() == 1);
|
|
||||||
RETURN_FALSE_IF_NOT(mm->workingCopy().contains(mm->configurationFileName()));
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -535,14 +535,11 @@ bool QtCreatorIntegration::navigateToSlot(const QString &objectName,
|
|||||||
} else {
|
} else {
|
||||||
const CppTools::WorkingCopy workingCopy =
|
const CppTools::WorkingCopy workingCopy =
|
||||||
CppTools::CppModelManager::instance()->workingCopy();
|
CppTools::CppModelManager::instance()->workingCopy();
|
||||||
const Utils::FileName configFileName =
|
|
||||||
Utils::FileName::fromString(CppTools::CppModelManager::configurationFileName());
|
|
||||||
QHashIterator<Utils::FileName, QPair<QByteArray, unsigned> > it = workingCopy.iterator();
|
QHashIterator<Utils::FileName, QPair<QByteArray, unsigned> > it = workingCopy.iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
it.next();
|
it.next();
|
||||||
const Utils::FileName &fileName = it.key();
|
const Utils::FileName &fileName = it.key();
|
||||||
if (fileName != configFileName)
|
newDocTable.insert(docTable.document(fileName));
|
||||||
newDocTable.insert(docTable.document(fileName));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
docTable = newDocTable;
|
docTable = newDocTable;
|
||||||
|
@@ -461,8 +461,6 @@ void QmakeProject::updateCppCodeModel()
|
|||||||
}
|
}
|
||||||
generators.append(proGenerators);
|
generators.append(proGenerators);
|
||||||
|
|
||||||
cppPart->files.prepend(ProjectFile(CppTools::CppModelManager::configurationFileName(),
|
|
||||||
ProjectFile::CXXSource));
|
|
||||||
projectInfo.appendProjectPart(cppPart);
|
projectInfo.appendProjectPart(cppPart);
|
||||||
|
|
||||||
if (!objcppPart->files.isEmpty()) {
|
if (!objcppPart->files.isEmpty()) {
|
||||||
|
Reference in New Issue
Block a user