diff --git a/src/plugins/clangcodemodel/clangbackendipcintegration.cpp b/src/plugins/clangcodemodel/clangbackendipcintegration.cpp index 6b68a98ddae..e38d5b10d55 100644 --- a/src/plugins/clangcodemodel/clangbackendipcintegration.cpp +++ b/src/plugins/clangcodemodel/clangbackendipcintegration.cpp @@ -83,16 +83,19 @@ using namespace ClangCodeModel::Internal; using namespace ClangBackEnd; using namespace TextEditor; -namespace { - -QString backendProcessPath() +static QString backendProcessPath() { return Core::ICore::libexecPath() + QStringLiteral("/clangbackend") + QStringLiteral(QTC_HOST_EXE_SUFFIX); } -bool printAliveMessageHelper() +static CppTools::CppEditorDocumentHandle *cppDocument(const QString &filePath) +{ + return CppTools::CppModelManager::instance()->cppEditorDocument(filePath); +} + +static bool printAliveMessageHelper() { const bool print = qEnvironmentVariableIntValue("QTC_CLANG_FORCE_VERBOSE_ALIVE"); if (!print) { @@ -103,14 +106,12 @@ bool printAliveMessageHelper() return print; } -bool printAliveMessage() +static bool printAliveMessage() { static bool print = log().isDebugEnabled() ? printAliveMessageHelper() : false; return print; } -} // anonymous namespace - IpcReceiver::IpcReceiver() : m_printAliveMessage(printAliveMessage()) { @@ -539,43 +540,21 @@ void IpcCommunicator::registerProjectsParts(const QListcppEditorDocument(filePath); + const CppTools::CppEditorDocumentHandle *document = cppDocument(filePath); updateTranslationUnit(filePath, document->contents(), document->revision()); } void IpcCommunicator::updateUnsavedFileFromCppEditorDocument(const QString &filePath) { - const auto document = CppTools::CppModelManager::instance()->cppEditorDocument(filePath); + const CppTools::CppEditorDocumentHandle *document = cppDocument(filePath); updateUnsavedFile(filePath, document->contents(), document->revision()); } namespace { -CppTools::CppEditorDocumentHandle *cppDocument(const QString &filePath) -{ - return CppTools::CppModelManager::instance()->cppEditorDocument(filePath); -} -bool documentHasChanged(const QString &filePath, - uint revision) -{ - auto *document = cppDocument(filePath); - if (document) - return document->sendTracker().shouldSendRevision(revision); - - return true; -} - -void setLastSentDocumentRevision(const QString &filePath, - uint revision) -{ - auto *document = cppDocument(filePath); - - if (document) - document->sendTracker().setLastSentRevision(int(revision)); -} } void IpcCommunicator::updateTranslationUnit(const QString &filePath, @@ -603,6 +582,20 @@ void IpcCommunicator::updateUnsavedFile(const QString &filePath, const QByteArra documentRevision}}); } +static bool documentHasChanged(const QString &filePath, uint revision) +{ + if (CppTools::CppEditorDocumentHandle *document = cppDocument(filePath)) + return document->sendTracker().shouldSendRevision(revision); + + return true; +} + +static void setLastSentDocumentRevision(const QString &filePath, uint revision) +{ + if (CppTools::CppEditorDocumentHandle *document = cppDocument(filePath)) + document->sendTracker().setLastSentRevision(int(revision)); +} + void IpcCommunicator::updateTranslationUnitWithRevisionCheck(const FileContainer &fileContainer) { if (documentHasChanged(fileContainer.filePath(), fileContainer.documentRevision())) { @@ -632,9 +625,7 @@ void IpcCommunicator::updateTranslationUnitWithRevisionCheck(Core::IDocument *do void IpcCommunicator::updateChangeContentStartPosition(const QString &filePath, int position) { - auto *document = cppDocument(filePath); - - if (document) + if (CppTools::CppEditorDocumentHandle *document = cppDocument(filePath)) document->sendTracker().applyContentChange(position); }