Clang: Fix updating supportive translation unit

...with new project arguments.

Reproduce with:
 1. Open a file with some #ifdef
 2. Edit the file, e.g. type space.
 3. Change the build configuration so that the highlighting flips in the
    editor.
 4. Edit the file again, the configuration flips again [repeat].

Change-Id: Ib97c18fc46538d74c63972e682a348ae2736a4e6
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Nikolai Kosjar
2017-05-03 15:48:44 +02:00
parent fda21898fb
commit cf0e3f2db3
9 changed files with 61 additions and 10 deletions

View File

@@ -50,6 +50,7 @@
#include <updatetranslationunitsforeditormessage.h>
#include <updatevisibletranslationunitsmessage.h>
#include <utils/algorithm.h>
#include <utils/qtcassert.h>
#include <QCoreApplication>
@@ -155,7 +156,16 @@ void ClangCodeModelServer::registerProjectPartsForEditor(const RegisterProjectPa
try {
projects.createOrUpdate(message.projectContainers());
documents.setDocumentsDirtyIfProjectPartChanged();
std::vector<Document> affectedDocuments = documents.setDocumentsDirtyIfProjectPartChanged();
for (Document &document : affectedDocuments) {
document.setResponsivenessIncreaseNeeded(document.isResponsivenessIncreased());
documentProcessors().remove(document);
document.translationUnits().removeAll();
document.translationUnits().createAndAppend();
documentProcessors().create(document);
}
processJobsForDirtyAndVisibleDocuments();
} catch (const std::exception &exception) {