diff --git a/src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp b/src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp index a282350f246..c7294d57c66 100644 --- a/src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp +++ b/src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp @@ -101,10 +101,8 @@ ClangEditorDocumentProcessor::~ClangEditorDocumentProcessor() m_parserWatcher.cancel(); m_parserWatcher.waitForFinished(); - if (m_projectPart) { - m_communicator.unregisterTranslationUnitsForEditor( - {ClangBackEnd::FileContainer(filePath(), m_projectPart->id())}); - } + if (m_projectPart) + unregisterTranslationUnitForEditor(); } void ClangEditorDocumentProcessor::runImpl( @@ -384,11 +382,6 @@ QFuture ClangEditorDocumentProcessor::toolTipInfo(const Q static_cast(column)); } -ClangBackEnd::FileContainer ClangEditorDocumentProcessor::fileContainerWithArguments() const -{ - return fileContainerWithArguments(m_projectPart.data()); -} - void ClangEditorDocumentProcessor::clearDiagnosticsWithFixIts() { m_diagnosticManager.clearDiagnosticsWithFixIts(); @@ -442,7 +435,7 @@ void ClangEditorDocumentProcessor::registerTranslationUnitForEditor(CppTools::Pr if (m_projectPart) { if (projectPart->id() == m_projectPart->id()) return; - m_communicator.unregisterTranslationUnitsForEditor({fileContainerWithArguments()}); + unregisterTranslationUnitForEditor(); } m_communicator.registerTranslationUnitsForEditor( @@ -450,6 +443,13 @@ void ClangEditorDocumentProcessor::registerTranslationUnitForEditor(CppTools::Pr ClangCodeModel::Utils::setLastSentDocumentRevision(filePath(), revision()); } +void ClangEditorDocumentProcessor::unregisterTranslationUnitForEditor() +{ + QTC_ASSERT(m_projectPart, return); + m_communicator.unregisterTranslationUnitsForEditor( + {ClangBackEnd::FileContainer(filePath(), m_projectPart->id())}); +} + void ClangEditorDocumentProcessor::updateTranslationUnitIfProjectPartExists() { if (m_projectPart) { @@ -621,17 +621,6 @@ static QStringList fileArguments(const QString &filePath, CppTools::ProjectPart + precompiledHeaderOptions(filePath, projectPart); } -ClangBackEnd::FileContainer -ClangEditorDocumentProcessor::fileContainerWithArguments(CppTools::ProjectPart *projectPart) const -{ - const auto projectPartId = projectPart - ? Utf8String::fromString(projectPart->id()) - : Utf8String(); - const QStringList theFileArguments = fileArguments(filePath(), projectPart); - - return {filePath(), projectPartId, Utf8StringVector(theFileArguments), revision()}; -} - ClangBackEnd::FileContainer ClangEditorDocumentProcessor::fileContainerWithArgumentsAndDocumentContent( CppTools::ProjectPart *projectPart) const diff --git a/src/plugins/clangcodemodel/clangeditordocumentprocessor.h b/src/plugins/clangcodemodel/clangeditordocumentprocessor.h index e79525e736d..27c4b355dc0 100644 --- a/src/plugins/clangcodemodel/clangeditordocumentprocessor.h +++ b/src/plugins/clangcodemodel/clangeditordocumentprocessor.h @@ -92,7 +92,7 @@ public: int line, int column) override; - ClangBackEnd::FileContainer fileContainerWithArguments() const; + void unregisterTranslationUnitForEditor(); void clearDiagnosticsWithFixIts(); @@ -110,7 +110,6 @@ private: HeaderErrorDiagnosticWidgetCreator creatorForHeaderErrorDiagnosticWidget( const ClangBackEnd::DiagnosticContainer &firstHeaderErrorDiagnostic); ClangBackEnd::FileContainer simpleFileContainer(const QByteArray &codecName = QByteArray()) const; - ClangBackEnd::FileContainer fileContainerWithArguments(CppTools::ProjectPart *projectPart) const; ClangBackEnd::FileContainer fileContainerWithArgumentsAndDocumentContent( CppTools::ProjectPart *projectPart) const; ClangBackEnd::FileContainer fileContainerWithDocumentContent(const QString &projectpartId) const; diff --git a/src/plugins/clangcodemodel/clangmodelmanagersupport.cpp b/src/plugins/clangcodemodel/clangmodelmanagersupport.cpp index 9495e6d5ebc..4de96c5a0ea 100644 --- a/src/plugins/clangcodemodel/clangmodelmanagersupport.cpp +++ b/src/plugins/clangcodemodel/clangmodelmanagersupport.cpp @@ -376,7 +376,7 @@ void ModelManagerSupportClang::unregisterTranslationUnitsWithProjectParts( { const auto processors = clangProcessorsWithProjectParts(projectPartIds); foreach (ClangEditorDocumentProcessor *processor, processors) { - m_communicator.unregisterTranslationUnitsForEditor({processor->fileContainerWithArguments()}); + processor->unregisterTranslationUnitForEditor(); processor->clearProjectPart(); processor->run(); }