forked from qt-creator/qt-creator
Clang: Extract TranslationUnitCore and (re)parse explicitly
Extract TranslationUnitCore, which is the API for the high-level
operations we need. TranslationUnit does not call any clang_* functions
anymore, except the one needed for disposing the CXTranslationUnit - for
now, we keep TranslationUnit the owner of TranslationUnitCore.
TranslationUnitCore will be passed on to the worker threads.
With this, the current "TranslationUnit" looses its meaning. We will
rename it to "Document" in a follow-up change.
***
TranslationUnit::cxTranslationUnit does not implicitly
creates/parses/reparses anymore. We use more verbose update operations
now.
The test ClangIpcServer.GetCodeCompletionDependingOnArgumets fails now
because of this - CodeCompleter::completeHelper() does not recreate the
translation unit anymore, thus working on the old data.
This will be addressed in a follow-up change.
Change-Id: I6213d6f1609cd3c9a54666c84cb8b623b2fefe1c
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -240,8 +240,10 @@ void ClangCodeModelServer::completeCode(const ClangBackEnd::CompleteCodeMessage
|
||||
TIME_SCOPE_DURATION("ClangCodeModelServer::completeCode");
|
||||
|
||||
try {
|
||||
CodeCompleter codeCompleter(translationUnits.translationUnit(message.filePath(), message.projectPartId()),
|
||||
unsavedFiles);
|
||||
auto translationUnit = translationUnits.translationUnit(message.filePath(), message.projectPartId());
|
||||
auto translationUnitCore = translationUnit.translationUnitCore();
|
||||
|
||||
CodeCompleter codeCompleter(translationUnitCore, unsavedFiles);
|
||||
|
||||
const auto codeCompletions = codeCompleter.complete(message.line(), message.column());
|
||||
|
||||
@@ -264,11 +266,13 @@ void ClangCodeModelServer::requestDocumentAnnotations(const RequestDocumentAnnot
|
||||
try {
|
||||
auto translationUnit = translationUnits.translationUnit(message.fileContainer().filePath(),
|
||||
message.fileContainer().projectPartId());
|
||||
auto translationUnitCore = translationUnit.translationUnitCore();
|
||||
|
||||
client()->documentAnnotationsChanged(DocumentAnnotationsChangedMessage(translationUnit.fileContainer(),
|
||||
translationUnit.mainFileDiagnostics(),
|
||||
translationUnit.highlightingMarks().toHighlightingMarksContainers(),
|
||||
translationUnit.skippedSourceRanges().toSourceRangeContainers()));
|
||||
client()->documentAnnotationsChanged(DocumentAnnotationsChangedMessage(
|
||||
translationUnit.fileContainer(),
|
||||
translationUnitCore.mainFileDiagnostics(),
|
||||
translationUnitCore.highlightingMarks().toHighlightingMarksContainers(),
|
||||
translationUnitCore.skippedSourceRanges().toSourceRangeContainers()));
|
||||
} catch (const TranslationUnitDoesNotExistException &exception) {
|
||||
client()->translationUnitDoesNotExist(TranslationUnitDoesNotExistMessage(exception.fileContainer()));
|
||||
} catch (const ProjectPartDoNotExistException &exception) {
|
||||
|
||||
Reference in New Issue
Block a user