Commit c2eb91e0 authored by Nikolai Kosjar's avatar Nikolai Kosjar

CppTools: Update visible documents on project update

With asynchron project managers, creating a new project from a wizard or
re-opening a session will first open the editor documents and then
provide the project information later (it's the other way around with
synchronous project managers). This sequence leave the documents with
various error diagnostics behind. Fixed by re-triggering the re-parsing.

This change does not fix QTCREATORBUG-11606 yet. Though it will trigger
a reparse with the right includes, clang still reports 'file not found'.
Will be addressed by a follow-up patch.

Task-number: QTCREATORBUG-11606
Change-Id: Ib5d251e05accf4268f9b36decc5224b2c75f610c
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
Reviewed-by: default avatarFawzi Mohamed <fawzi.mohamed@digia.com>
parent 4472437b
......@@ -456,7 +456,7 @@ void CppModelManager::removeExtraEditorSupport(AbstractEditorSupport *editorSupp
d->m_extraEditorSupports.remove(editorSupport);
}
EditorDocumentHandle *CppModelManager::editorDocument(const QString &filePath)
EditorDocumentHandle *CppModelManager::editorDocument(const QString &filePath) const
{
QTC_ASSERT(!filePath.isEmpty(), return 0);
......@@ -697,6 +697,24 @@ void CppModelManager::recalculateFileToProjectParts()
}
}
void CppModelManager::updateVisibleEditorDocuments() const
{
QSet<QString> visibleDocumentsInEditMode;
foreach (Core::IEditor *editor, Core::EditorManager::visibleEditors()) {
if (const Core::IDocument *document = editor->document()) {
const QString filePath = document->filePath();
QTC_ASSERT(!filePath.isEmpty(), continue);
visibleDocumentsInEditMode.insert(filePath);
}
}
// Re-process these documents
foreach (const QString &filePath, visibleDocumentsInEditMode) {
if (EditorDocumentHandle *editor = editorDocument(filePath))
editor->processor()->run();
}
}
QFuture<void> CppModelManager::updateProjectInfo(const ProjectInfo &newProjectInfo)
{
if (!newProjectInfo.isValid())
......@@ -768,6 +786,12 @@ QFuture<void> CppModelManager::updateProjectInfo(const ProjectInfo &newProjectIn
emit projectPartsUpdated(newProjectInfo.project().data());
// Ideally, we would update all the editor documents that depend on the 'filesToReindex'.
// However, on e.g. a session restore first the editor documents are created and then the
// project updates come in. That is, there are no reasonable dependency tables based on
// resolved includes that we could rely on.
updateVisibleEditorDocuments();
// Trigger reindexing
return updateSourceFiles(filesToReindex, ForcedProgressNotification);
}
......
......@@ -115,7 +115,7 @@ public:
void addExtraEditorSupport(AbstractEditorSupport *editorSupport);
void removeExtraEditorSupport(AbstractEditorSupport *editorSupport);
EditorDocumentHandle *editorDocument(const QString &filePath);
EditorDocumentHandle *editorDocument(const QString &filePath) const;
void registerEditorDocument(EditorDocumentHandle *editorDocument);
void unregisterEditorDocument(const QString &filePath);
......@@ -189,6 +189,7 @@ private slots:
private:
void delayedGC();
void recalculateFileToProjectParts();
void updateVisibleEditorDocuments() const;
void replaceSnapshot(const CPlusPlus::Snapshot &newSnapshot);
void removeFilesFromSnapshot(const QSet<QString> &removedFiles);
......
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