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: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Kandeler
2022-05-03 13:06:49 +02:00
parent 70e8e1b530
commit 23fceb9ef3
2 changed files with 14 additions and 0 deletions

View File

@@ -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);

View File

@@ -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);