forked from qt-creator/qt-creator
clangd: make --limit-results configurable in Preferences
The default value is the clangd default value: 100. Fixes: QTCREATORBUG-27152 Change-Id: Icb6c67645b33325da591cb360c17b3dd55fc60ad Reviewed-by: Christian Kandeler <christian.kandeler@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -262,8 +262,16 @@ static BaseClientInterface *clientInterface(Project *project, const Utils::FileP
|
||||
indexingOption += "=0";
|
||||
const QString headerInsertionOption = QString("--header-insertion=")
|
||||
+ (settings.autoIncludeHeaders() ? "iwyu" : "never");
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
// For the #include < test, which needs to get a local header file, but the list
|
||||
// is being flooded with system include headers. 4280 on Windows!
|
||||
const QString limitResults = QString("--limit-results=0");
|
||||
#else
|
||||
const QString limitResults = QString("--limit-results=%1").arg(settings.completionResults());
|
||||
#endif
|
||||
Utils::CommandLine cmd{settings.clangdFilePath(), {indexingOption, headerInsertionOption,
|
||||
"--limit-results=0", "--limit-references=0", "--clang-tidy=0"}};
|
||||
limitResults, "--limit-references=0", "--clang-tidy=0"}};
|
||||
if (settings.workerThreadLimit() != 0)
|
||||
cmd.addArg("-j=" + QString::number(settings.workerThreadLimit()));
|
||||
if (!jsonDbDir.isEmpty())
|
||||
|
@@ -83,6 +83,7 @@ static QString clangdUseGlobalSettingsKey() { return QLatin1String("useGlobalSet
|
||||
static QString sessionsWithOneClangdKey() { return QLatin1String("SessionsWithOneClangd"); }
|
||||
static QString diagnosticConfigIdKey() { return QLatin1String("diagnosticConfigId"); }
|
||||
static QString checkedHardwareKey() { return QLatin1String("checkedHardware"); }
|
||||
static QString completionResultsKey() { return QLatin1String("completionResults"); }
|
||||
|
||||
static FilePath g_defaultClangdFilePath;
|
||||
static FilePath fallbackClangdFilePath()
|
||||
@@ -489,6 +490,7 @@ QVariantMap ClangdSettings::Data::toMap() const
|
||||
map.insert(sessionsWithOneClangdKey(), sessionsWithOneClangd);
|
||||
map.insert(diagnosticConfigIdKey(), diagnosticConfigId.toSetting());
|
||||
map.insert(checkedHardwareKey(), true);
|
||||
map.insert(completionResultsKey(), completionResults);
|
||||
return map;
|
||||
}
|
||||
|
||||
@@ -506,6 +508,7 @@ void ClangdSettings::Data::fromMap(const QVariantMap &map)
|
||||
diagnosticConfigId = Id::fromSetting(map.value(diagnosticConfigIdKey(),
|
||||
initialClangDiagnosticConfigId().toSetting()));
|
||||
haveCheckedHardwareReqirements = map.value(checkedHardwareKey(), false).toBool();
|
||||
completionResults = map.value(completionResultsKey(), kDefaultCompletionResults).toInt();
|
||||
}
|
||||
|
||||
} // namespace CppEditor
|
||||
|
@@ -93,6 +93,9 @@ class CPPEDITOR_EXPORT ClangdSettings : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
// Default clangd --limit-results value is 100
|
||||
static const int kDefaultCompletionResults = 100;
|
||||
|
||||
class CPPEDITOR_EXPORT Data
|
||||
{
|
||||
public:
|
||||
@@ -112,7 +115,8 @@ public:
|
||||
&& s1.documentUpdateThreshold == s2.documentUpdateThreshold
|
||||
&& s1.sizeThresholdEnabled == s2.sizeThresholdEnabled
|
||||
&& s1.sizeThresholdInKb == s2.sizeThresholdInKb
|
||||
&& s1.haveCheckedHardwareReqirements == s2.haveCheckedHardwareReqirements;
|
||||
&& s1.haveCheckedHardwareReqirements == s2.haveCheckedHardwareReqirements
|
||||
&& s1.completionResults == s2.completionResults;
|
||||
}
|
||||
friend bool operator!=(const Data &s1, const Data &s2) { return !(s1 == s2); }
|
||||
|
||||
@@ -128,6 +132,7 @@ public:
|
||||
bool autoIncludeHeaders = false;
|
||||
bool sizeThresholdEnabled = false;
|
||||
bool haveCheckedHardwareReqirements = false;
|
||||
int completionResults = kDefaultCompletionResults;
|
||||
};
|
||||
|
||||
ClangdSettings(const Data &data) : m_data(data) {}
|
||||
@@ -148,6 +153,7 @@ public:
|
||||
int documentUpdateThreshold() const { return m_data.documentUpdateThreshold; }
|
||||
qint64 sizeThresholdInKb() const { return m_data.sizeThresholdInKb; }
|
||||
bool sizeThresholdEnabled() const { return m_data.sizeThresholdEnabled; }
|
||||
int completionResults() const { return m_data.completionResults; }
|
||||
bool sizeIsOkay(const Utils::FilePath &fp) const;
|
||||
ClangDiagnosticConfigs customDiagnosticConfigs() const;
|
||||
Utils::Id diagnosticConfigId() const;
|
||||
|
@@ -178,6 +178,7 @@ public:
|
||||
QSpinBox threadLimitSpinBox;
|
||||
QSpinBox documentUpdateThreshold;
|
||||
QSpinBox sizeThresholdSpinBox;
|
||||
QSpinBox completionResults;
|
||||
Utils::PathChooser clangdChooser;
|
||||
Utils::InfoLabel versionWarningLabel;
|
||||
ClangDiagnosticConfigsSelectionWidget *configSelectionWidget = nullptr;
|
||||
@@ -224,6 +225,13 @@ ClangdSettingsWidget::ClangdSettingsWidget(const ClangdSettings::Data &settingsD
|
||||
"Files greater than this will not be opened as documents in clangd.\n"
|
||||
"The built-in code model will handle highlighting, completion and so on."));
|
||||
|
||||
const auto completionResultsLabel = new QLabel(tr("Completion results:"));
|
||||
d->completionResults.setMinimum(0);
|
||||
d->completionResults.setMaximum(std::numeric_limits<int>::max());
|
||||
d->completionResults.setValue(settings.completionResults());
|
||||
d->completionResults.setToolTip(tr("The maximum number of completion results returned by clangd"));
|
||||
d->completionResults.setSpecialValueText(tr("No limit"));
|
||||
|
||||
const auto layout = new QVBoxLayout(this);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
layout->addWidget(&d->useClangdCheckBox);
|
||||
@@ -245,6 +253,12 @@ ClangdSettingsWidget::ClangdSettingsWidget(const ClangdSettings::Data &settingsD
|
||||
documentUpdateThresholdLayout->addStretch(1);
|
||||
const auto documentUpdateThresholdLabel = new QLabel(tr("Document update threshold:"));
|
||||
formLayout->addRow(documentUpdateThresholdLabel, documentUpdateThresholdLayout);
|
||||
|
||||
const auto limitResultsLayout = new QHBoxLayout;
|
||||
limitResultsLayout->addWidget(&d->completionResults);
|
||||
limitResultsLayout->addStretch(1);
|
||||
formLayout->addRow(completionResultsLabel, limitResultsLayout);
|
||||
|
||||
const auto sizeThresholdLayout = new QHBoxLayout;
|
||||
sizeThresholdLayout->addWidget(&d->sizeThresholdSpinBox);
|
||||
sizeThresholdLayout->addStretch(1);
|
||||
|
Reference in New Issue
Block a user