forked from qt-creator/qt-creator
Clang: Avoid running pointless UpdateDocumentJobs
Opening a document (without typing in it), switching away and back to it resulted in running UpdateDocumentJobs for that document for nothing. As for documents we are going to reset, simply set opened documents initially dirty. Change-Id: I8edc2d1fb8f6f92950b4e2067f60609176bd5b26 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
@@ -102,9 +102,11 @@ void ClangCodeModelServer::documentsOpened(const ClangBackEnd::DocumentsOpenedMe
|
||||
QVector<FileContainer> toCreate;
|
||||
categorizeFileContainers(message.fileContainers, toCreate, toReset);
|
||||
|
||||
const std::vector<Document> createdDocuments = documents.create(toCreate);
|
||||
for (const auto &document : createdDocuments)
|
||||
std::vector<Document> createdDocuments = documents.create(toCreate);
|
||||
for (auto &document : createdDocuments) {
|
||||
document.setDirtyIfDependencyIsMet(document.filePath());
|
||||
documentProcessors().create(document);
|
||||
}
|
||||
const std::vector<Document> resetDocuments_ = resetDocuments(toReset);
|
||||
|
||||
unsavedFiles.createOrUpdate(message.fileContainers);
|
||||
@@ -341,8 +343,7 @@ void ClangCodeModelServer::processJobsForVisibleDocuments()
|
||||
void ClangCodeModelServer::processJobsForCurrentDocument()
|
||||
{
|
||||
auto currentDocuments = documents.filtered([](const Document &document) {
|
||||
return document.isUsedByCurrentEditor()
|
||||
&& (document.isDirty() || document.documentRevision() == 1);
|
||||
return document.isUsedByCurrentEditor() && document.isDirty();
|
||||
});
|
||||
QTC_CHECK(currentDocuments.size() <= 1);
|
||||
|
||||
|
@@ -311,11 +311,11 @@ TEST_F(ClangCodeModelServerSlowTest, GetNewCodeCompletionAfterUpdatingUnsavedFil
|
||||
requestCompletionsInFileA();
|
||||
}
|
||||
|
||||
TEST_F(ClangCodeModelServerSlowTest, TranslationUnitAfterCreationIsNotDirty)
|
||||
TEST_F(ClangCodeModelServerSlowTest, OpenedDocumentsAreDirty)
|
||||
{
|
||||
openDocument(filePathA, AnnotationJobsMultiplier);
|
||||
|
||||
ASSERT_THAT(clangServer, HasDirtyDocument(filePathA, 0U, false, false));
|
||||
ASSERT_THAT(clangServer, HasDirtyDocument(filePathA, 0U, true, false));
|
||||
}
|
||||
|
||||
TEST_F(ClangCodeModelServerSlowTest, SetCurrentAndVisibleEditor)
|
||||
|
Reference in New Issue
Block a user