Improve Clangd settings page

- add tooltips to the labels
- move the completion settings together
- move the "threshold" settings together
- move the indexing option together with the worker threads option
- mention that we fallback to a built-in indexer if clangd background
  indexing is turned off
- add tool tip to worker threads option that mentions that this is also
  used for background indexing
- adapt documentation

Fixes: QTCREATORBUG-28071
Change-Id: I89b00a586fa79fd5ba25c4d187e36d5cfc2d4903
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Eike Ziller
2022-09-01 16:12:51 +02:00
parent a634833720
commit 29f9f0d822
2 changed files with 54 additions and 25 deletions

View File

@@ -143,14 +143,21 @@
\uicontrol Clangd > \uicontrol {Use clangd}. \uicontrol Clangd > \uicontrol {Use clangd}.
\image qtcreator-options-clangd.png "clangd preferences" \image qtcreator-options-clangd.png "clangd preferences"
\li In \uicontrol {Path to executable}, enter the path to clangd \li In \uicontrol {Path to executable}, enter the path to clangd
version 13, or later. version 14, or later.
\li For more accurate results during global symbol searches, select \li For more accurate results during global symbol searches, select
\uicontrol {Enable background indexing}. However, this increases the \uicontrol {Enable background indexing}. However, this increases the
CPU load the first time you open the project. CPU load the first time you open the project. If clangd background
\li Select \uicontrol {Insert header files on completion} to allow indexing is disabled, \QC falls back to a faster, but less accurate
clangd to insert header files as part of symbol completion. built-in indexer.
\li By default, clangd attempts to use all unused cores. You can set a \li By default, clangd attempts to use all unused cores. You can set a
fixed number of cores to use in \uicontrol {Worker thread count}. fixed number of cores to use in \uicontrol {Worker thread count}.
Background indexing also uses this many worker threads.
\li Select \uicontrol {Insert header files on completion} to allow
clangd to insert header files as part of symbol completion.
\li Set the number of \uicontrol {Completion results} if you regularly
miss important results during code completion. Set it to 0 to remove
the limit on the number of completion results. Setting this to 0 or a
very high number can make code completion slow.
\li In \uicontrol {Document update threshold}, specify the amount of \li In \uicontrol {Document update threshold}, specify the amount of
time \QC waits before sending document changes to the server. time \QC waits before sending document changes to the server.
If the document changes again while waiting, this timeout is reset. If the document changes again while waiting, this timeout is reset.

View File

@@ -169,45 +169,62 @@ ClangdSettingsWidget::ClangdSettingsWidget(const ClangdSettings::Data &settingsD
: d(new Private) : d(new Private)
{ {
const ClangdSettings settings(settingsData); const ClangdSettings settings(settingsData);
const QString indexingToolTip = tr(
"If background indexing is enabled, global symbol searches will yield\n"
"more accurate results, at the cost of additional CPU load when\n"
"the project is first opened.\n"
"The indexing result is persisted in the project's build directory.\n"
"\n"
"If you disable background indexing, a faster, but less accurate,\n"
"built-in indexer is used instead.");
const QString workerThreadsToolTip = tr(
"Number of worker threads used by clangd. Background indexing also uses this many "
"worker threads.");
const QString autoIncludeToolTip = tr(
"Controls whether clangd may insert header files as part of symbol completion.");
const QString documentUpdateToolTip = tr(
"Defines the amount of time Qt Creator waits before sending document changes to the "
"server.\n"
"If the document changes again while waiting, this timeout resets.");
const QString sizeThresholdToolTip = tr(
"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 QString completionResultToolTip = tr(
"The maximum number of completion results returned by clangd.");
d->useClangdCheckBox.setText(tr("Use clangd")); d->useClangdCheckBox.setText(tr("Use clangd"));
d->useClangdCheckBox.setChecked(settings.useClangd()); d->useClangdCheckBox.setChecked(settings.useClangd());
d->clangdChooser.setExpectedKind(Utils::PathChooser::ExistingCommand); d->clangdChooser.setExpectedKind(Utils::PathChooser::ExistingCommand);
d->clangdChooser.setFilePath(settings.clangdFilePath()); d->clangdChooser.setFilePath(settings.clangdFilePath());
d->clangdChooser.setEnabled(d->useClangdCheckBox.isChecked()); d->clangdChooser.setEnabled(d->useClangdCheckBox.isChecked());
d->indexingCheckBox.setChecked(settings.indexingEnabled()); d->indexingCheckBox.setChecked(settings.indexingEnabled());
d->indexingCheckBox.setToolTip(tr( d->indexingCheckBox.setToolTip(indexingToolTip);
"If background indexing is enabled, global symbol searches will yield\n"
"more accurate results, at the cost of additional CPU load when\n"
"the project is first opened."));
d->autoIncludeHeadersCheckBox.setChecked(settings.autoIncludeHeaders()); d->autoIncludeHeadersCheckBox.setChecked(settings.autoIncludeHeaders());
d->autoIncludeHeadersCheckBox.setToolTip(tr( d->autoIncludeHeadersCheckBox.setToolTip(autoIncludeToolTip);
"Controls whether clangd may insert header files as part of symbol completion."));
d->threadLimitSpinBox.setValue(settings.workerThreadLimit()); d->threadLimitSpinBox.setValue(settings.workerThreadLimit());
d->threadLimitSpinBox.setSpecialValueText("Automatic"); d->threadLimitSpinBox.setSpecialValueText("Automatic");
d->threadLimitSpinBox.setToolTip(workerThreadsToolTip);
d->documentUpdateThreshold.setMinimum(50); d->documentUpdateThreshold.setMinimum(50);
d->documentUpdateThreshold.setMaximum(10000); d->documentUpdateThreshold.setMaximum(10000);
d->documentUpdateThreshold.setValue(settings.documentUpdateThreshold()); d->documentUpdateThreshold.setValue(settings.documentUpdateThreshold());
d->documentUpdateThreshold.setSingleStep(100); d->documentUpdateThreshold.setSingleStep(100);
d->documentUpdateThreshold.setSuffix(" ms"); d->documentUpdateThreshold.setSuffix(" ms");
d->documentUpdateThreshold.setToolTip( d->documentUpdateThreshold.setToolTip(documentUpdateToolTip);
tr("Defines the amount of time Qt Creator waits before sending document changes to the "
"server.\n"
"If the document changes again while waiting, this timeout resets.\n"));
d->sizeThresholdCheckBox.setText(tr("Ignore files greater than")); d->sizeThresholdCheckBox.setText(tr("Ignore files greater than"));
d->sizeThresholdCheckBox.setChecked(settings.sizeThresholdEnabled()); d->sizeThresholdCheckBox.setChecked(settings.sizeThresholdEnabled());
d->sizeThresholdCheckBox.setToolTip(sizeThresholdToolTip);
d->sizeThresholdSpinBox.setMinimum(1); d->sizeThresholdSpinBox.setMinimum(1);
d->sizeThresholdSpinBox.setMaximum(std::numeric_limits<int>::max()); d->sizeThresholdSpinBox.setMaximum(std::numeric_limits<int>::max());
d->sizeThresholdSpinBox.setSuffix(" KB"); d->sizeThresholdSpinBox.setSuffix(" KB");
d->sizeThresholdSpinBox.setValue(settings.sizeThresholdInKb()); d->sizeThresholdSpinBox.setValue(settings.sizeThresholdInKb());
d->sizeThresholdSpinBox.setToolTip(tr( d->sizeThresholdSpinBox.setToolTip(sizeThresholdToolTip);
"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:")); const auto completionResultsLabel = new QLabel(tr("Completion results:"));
completionResultsLabel->setToolTip(completionResultToolTip);
d->completionResults.setMinimum(0); d->completionResults.setMinimum(0);
d->completionResults.setMaximum(std::numeric_limits<int>::max()); d->completionResults.setMaximum(std::numeric_limits<int>::max());
d->completionResults.setValue(settings.completionResults()); d->completionResults.setValue(settings.completionResults());
d->completionResults.setToolTip(tr("The maximum number of completion results returned by clangd")); d->completionResults.setToolTip(completionResultToolTip);
d->completionResults.setSpecialValueText(tr("No limit")); d->completionResults.setSpecialValueText(tr("No limit"));
const auto layout = new QVBoxLayout(this); const auto layout = new QVBoxLayout(this);
@@ -218,29 +235,34 @@ ClangdSettingsWidget::ClangdSettingsWidget(const ClangdSettings::Data &settingsD
formLayout->addRow(chooserLabel, &d->clangdChooser); formLayout->addRow(chooserLabel, &d->clangdChooser);
formLayout->addRow(QString(), &d->versionWarningLabel); formLayout->addRow(QString(), &d->versionWarningLabel);
const auto indexingLabel = new QLabel(tr("Enable background indexing:")); const auto indexingLabel = new QLabel(tr("Enable background indexing:"));
indexingLabel->setToolTip(indexingToolTip);
formLayout->addRow(indexingLabel, &d->indexingCheckBox); formLayout->addRow(indexingLabel, &d->indexingCheckBox);
const auto autoIncludeHeadersLabel = new QLabel(tr("Insert header files on completion:"));
formLayout->addRow(autoIncludeHeadersLabel, &d->autoIncludeHeadersCheckBox);
const auto threadLimitLayout = new QHBoxLayout; const auto threadLimitLayout = new QHBoxLayout;
threadLimitLayout->addWidget(&d->threadLimitSpinBox); threadLimitLayout->addWidget(&d->threadLimitSpinBox);
threadLimitLayout->addStretch(1); threadLimitLayout->addStretch(1);
const auto threadLimitLabel = new QLabel(tr("Worker thread count:")); const auto threadLimitLabel = new QLabel(tr("Worker thread count:"));
threadLimitLabel->setToolTip(workerThreadsToolTip);
formLayout->addRow(threadLimitLabel, threadLimitLayout); formLayout->addRow(threadLimitLabel, threadLimitLayout);
const auto documentUpdateThresholdLayout = new QHBoxLayout;
documentUpdateThresholdLayout->addWidget(&d->documentUpdateThreshold);
documentUpdateThresholdLayout->addStretch(1);
const auto documentUpdateThresholdLabel = new QLabel(tr("Document update threshold:"));
formLayout->addRow(documentUpdateThresholdLabel, documentUpdateThresholdLayout);
const auto autoIncludeHeadersLabel = new QLabel(tr("Insert header files on completion:"));
autoIncludeHeadersLabel->setToolTip(autoIncludeToolTip);
formLayout->addRow(autoIncludeHeadersLabel, &d->autoIncludeHeadersCheckBox);
const auto limitResultsLayout = new QHBoxLayout; const auto limitResultsLayout = new QHBoxLayout;
limitResultsLayout->addWidget(&d->completionResults); limitResultsLayout->addWidget(&d->completionResults);
limitResultsLayout->addStretch(1); limitResultsLayout->addStretch(1);
formLayout->addRow(completionResultsLabel, limitResultsLayout); formLayout->addRow(completionResultsLabel, limitResultsLayout);
const auto documentUpdateThresholdLayout = new QHBoxLayout;
documentUpdateThresholdLayout->addWidget(&d->documentUpdateThreshold);
documentUpdateThresholdLayout->addStretch(1);
const auto documentUpdateThresholdLabel = new QLabel(tr("Document update threshold:"));
documentUpdateThresholdLabel->setToolTip(documentUpdateToolTip);
formLayout->addRow(documentUpdateThresholdLabel, documentUpdateThresholdLayout);
const auto sizeThresholdLayout = new QHBoxLayout; const auto sizeThresholdLayout = new QHBoxLayout;
sizeThresholdLayout->addWidget(&d->sizeThresholdSpinBox); sizeThresholdLayout->addWidget(&d->sizeThresholdSpinBox);
sizeThresholdLayout->addStretch(1); sizeThresholdLayout->addStretch(1);
formLayout->addRow(&d->sizeThresholdCheckBox, sizeThresholdLayout); formLayout->addRow(&d->sizeThresholdCheckBox, sizeThresholdLayout);
d->configSelectionWidget = new ClangDiagnosticConfigsSelectionWidget(formLayout); d->configSelectionWidget = new ClangDiagnosticConfigsSelectionWidget(formLayout);
d->configSelectionWidget->refresh( d->configSelectionWidget->refresh(
diagnosticConfigsModel(settings.customDiagnosticConfigs()), diagnosticConfigsModel(settings.customDiagnosticConfigs()),