Clang: Fix slowness of code completion after opening the file

Task-number: QTCREATORBUG-15429
Change-Id: I9a8a582fb3c59a960425f83eb8e7b436f15d1c1a
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This commit is contained in:
Marco Bubke
2015-12-02 13:31:07 +01:00
parent 48a2e15c28
commit 493a2a6189
14 changed files with 126 additions and 37 deletions

View File

@@ -116,9 +116,12 @@ void ClangIpcServer::registerTranslationUnitsForEditor(const ClangBackEnd::Regis
TIME_SCOPE_DURATION("ClangIpcServer::registerTranslationUnitsForEditor");
try {
translationUnits.create(message.fileContainers());
auto createdTranslationUnits = translationUnits.create(message.fileContainers());
unsavedFiles.createOrUpdate(message.fileContainers());
sendDocumentAnnotationsTimer.start(0);
translationUnits.setUsedByCurrentEditor(message.currentEditorFilePath());
translationUnits.setVisibleInEditors(message.visibleEditorFilePaths());
startDocumentAnnotations();
reparseVisibleDocuments(createdTranslationUnits);
} catch (const ProjectPartDoNotExistException &exception) {
client()->projectPartsDoNotExist(ProjectPartsDoNotExistMessage(exception.projectPartIds()));
} catch (const std::exception &exception) {
@@ -299,4 +302,19 @@ void ClangIpcServer::startDocumentAnnotationsTimerIfFileIsNotATranslationUnit(co
sendDocumentAnnotationsTimer.start(0);
}
void ClangIpcServer::startDocumentAnnotations()
{
DocumentAnnotationsSendState sendState = DocumentAnnotationsSendState::MaybeThereAreDocumentAnnotations;
while (sendState == DocumentAnnotationsSendState::MaybeThereAreDocumentAnnotations)
sendState = translationUnits.sendDocumentAnnotations();
}
void ClangIpcServer::reparseVisibleDocuments(std::vector<TranslationUnit> &translationUnits)
{
for (TranslationUnit &translationUnit : translationUnits)
if (translationUnit.isVisibleInEditor())
translationUnit.reparse();
}
}