clangd: Use QtC system environment for environment variables

Users would set QTC_CLANGD_COMPLETION_RESULTS in the Qt Creator
system environment variable dialog and expect that clangd would
the be configured with the corresponding --limit-results value.

Task-number: QTCREATORBUG-28071
Change-Id: Ia7a9b6a96fabe7ba16906c547a15716f0b83f0ec
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Cristian Adam
2022-08-22 15:46:21 +02:00
parent 6a3933c87a
commit 9102452272

View File

@@ -82,6 +82,7 @@
#include <texteditor/texteditorsettings.h> #include <texteditor/texteditorsettings.h>
#include <texteditor/texteditor.h> #include <texteditor/texteditor.h>
#include <utils/algorithm.h> #include <utils/algorithm.h>
#include <utils/environment.h>
#include <utils/fileutils.h> #include <utils/fileutils.h>
#include <utils/itemviews.h> #include <utils/itemviews.h>
#include <utils/runextensions.h> #include <utils/runextensions.h>
@@ -275,7 +276,8 @@ static BaseClientInterface *clientInterface(Project *project, const Utils::FileP
+ (settings.autoIncludeHeaders() ? "iwyu" : "never"); + (settings.autoIncludeHeaders() ? "iwyu" : "never");
bool ok = false; bool ok = false;
const int userValue = qEnvironmentVariableIntValue("QTC_CLANGD_COMPLETION_RESULTS", &ok); const int userValue
= Utils::Environment::systemEnvironment().value("QTC_CLANGD_COMPLETION_RESULTS").toInt(&ok);
const QString limitResults = QString("--limit-results=%1").arg(ok ? userValue : 0); const QString limitResults = QString("--limit-results=%1").arg(ok ? userValue : 0);
Utils::CommandLine cmd{settings.clangdFilePath(), {indexingOption, headerInsertionOption, Utils::CommandLine cmd{settings.clangdFilePath(), {indexingOption, headerInsertionOption,