Clang: Update document annotations only if document is visible

So no reparsing is happen for invisible files.

Change-Id: I8bf3fe8aed38b30ceeabc50ba2f216acc4b8b718
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This commit is contained in:
Marco Bubke
2015-12-01 14:08:37 +01:00
parent 5f29a00c89
commit a992a1064c
3 changed files with 5 additions and 5 deletions

View File

@@ -282,6 +282,7 @@ void ClangIpcServer::updateVisibleTranslationUnits(const UpdateVisibleTranslatio
try { try {
translationUnits.setUsedByCurrentEditor(message.currentEditorFilePath()); translationUnits.setUsedByCurrentEditor(message.currentEditorFilePath());
translationUnits.setVisibleInEditors(message.visibleEditorFilePaths()); translationUnits.setVisibleInEditors(message.visibleEditorFilePaths());
sendDocumentAnnotationsTimer.start(0);
} catch (const std::exception &exception) { } catch (const std::exception &exception) {
qWarning() << "Error in ClangIpcServer::updateVisibleTranslationUnits:" << exception.what(); qWarning() << "Error in ClangIpcServer::updateVisibleTranslationUnits:" << exception.what();
} }

View File

@@ -171,8 +171,6 @@ DocumentAnnotationsSendState TranslationUnits::sendDocumentAnnotations()
auto documentAnnotationsSendState = sendDocumentAnnotationsForCurrentEditor(); auto documentAnnotationsSendState = sendDocumentAnnotationsForCurrentEditor();
if (documentAnnotationsSendState == DocumentAnnotationsSendState::NoDocumentAnnotationsSent) if (documentAnnotationsSendState == DocumentAnnotationsSendState::NoDocumentAnnotationsSent)
documentAnnotationsSendState = sendDocumentAnnotationsForVisibleEditors(); documentAnnotationsSendState = sendDocumentAnnotationsForVisibleEditors();
if (documentAnnotationsSendState == DocumentAnnotationsSendState::NoDocumentAnnotationsSent)
documentAnnotationsSendState = sendDocumentAnnotationsForAll();
return documentAnnotationsSendState; return documentAnnotationsSendState;
} }

View File

@@ -381,11 +381,11 @@ TEST_F(TranslationUnits, DoNotSendDocumentAnnotationsIfThereIsNothingToSend)
sendAllDocumentAnnotations(); sendAllDocumentAnnotations();
} }
TEST_F(TranslationUnits, SendDocumentAnnotationsAfterTranslationUnitCreation) TEST_F(TranslationUnits, DoNotSendDocumentAnnotationsAfterTranslationUnitCreation)
{ {
translationUnits.create({fileContainer, headerContainer}); translationUnits.create({fileContainer, headerContainer});
EXPECT_CALL(mockSendDocumentAnnotationsCallback, sendDocumentAnnotations()).Times(2); EXPECT_CALL(mockSendDocumentAnnotationsCallback, sendDocumentAnnotations()).Times(0);
sendAllDocumentAnnotations(); sendAllDocumentAnnotations();
} }
@@ -394,10 +394,11 @@ TEST_F(TranslationUnits, DoNotSendDocumentAnnotationsAfterGettingDocumentAnnotat
{ {
translationUnits.create({fileContainer, headerContainer}); translationUnits.create({fileContainer, headerContainer});
auto translationUnit = translationUnits.translationUnit(fileContainer); auto translationUnit = translationUnits.translationUnit(fileContainer);
translationUnit.setIsVisibleInEditor(true);
translationUnit.diagnostics(); // Reset translationUnit.diagnostics(); // Reset
translationUnit.highlightingInformations(); // Reset translationUnit.highlightingInformations(); // Reset
EXPECT_CALL(mockSendDocumentAnnotationsCallback, sendDocumentAnnotations()).Times(1); EXPECT_CALL(mockSendDocumentAnnotationsCallback, sendDocumentAnnotations()).Times(0);
sendAllDocumentAnnotations(); sendAllDocumentAnnotations();
} }