From 23fceb9ef36a70ca1520ef45baff07a7af46aecd Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Tue, 3 May 2022 13:06:49 +0200 Subject: [PATCH] CppEditor: Allow to retrieve clangd's internal include path The code model will need to use this one instead of the one hardcoded at build time. Change-Id: Ibd89d32f99b9250c909473f9a4a66f9a8a5f4f07 Reviewed-by: Reviewed-by: Qt CI Bot Reviewed-by: David Schulz --- src/plugins/cppeditor/cppcodemodelsettings.cpp | 13 +++++++++++++ src/plugins/cppeditor/cppcodemodelsettings.h | 1 + 2 files changed, 14 insertions(+) diff --git a/src/plugins/cppeditor/cppcodemodelsettings.cpp b/src/plugins/cppeditor/cppcodemodelsettings.cpp index 0cd2ada73b1..66069f57596 100644 --- a/src/plugins/cppeditor/cppcodemodelsettings.cpp +++ b/src/plugins/cppeditor/cppcodemodelsettings.cpp @@ -405,6 +405,19 @@ QVersionNumber ClangdSettings::clangdVersion(const FilePath &clangdFilePath) return it->second; } +FilePath ClangdSettings::clangdIncludePath() const +{ + QTC_ASSERT(useClangd(), return {}); + FilePath clangdPath = clangdFilePath(); + QTC_ASSERT(!clangdPath.isEmpty() && clangdPath.exists(), return {}); + const QVersionNumber version = clangdVersion(); + QTC_ASSERT(!version.isNull(), return {}); + const FilePath includePath = clangdPath.absolutePath().parentDir().pathAppended("lib/clang") + .pathAppended(version.toString()).pathAppended("include"); + QTC_ASSERT(includePath.exists(), return {}); + return includePath; +} + void ClangdSettings::loadSettings() { Utils::fromSettings(clangdSettingsKey(), {}, Core::ICore::settings(), &m_data); diff --git a/src/plugins/cppeditor/cppcodemodelsettings.h b/src/plugins/cppeditor/cppcodemodelsettings.h index 0d3e52247dd..483b3d0100d 100644 --- a/src/plugins/cppeditor/cppcodemodelsettings.h +++ b/src/plugins/cppeditor/cppcodemodelsettings.h @@ -155,6 +155,7 @@ public: static QVersionNumber clangdVersion(const Utils::FilePath &clangdFilePath); QVersionNumber clangdVersion() const { return clangdVersion(clangdFilePath()); } + Utils::FilePath clangdIncludePath() const; #ifdef WITH_TESTS static void setUseClangd(bool use);