From 02fafd6c9924cf683cc3949d6a28d2d57fe3c86d Mon Sep 17 00:00:00 2001 From: "Hana (Hyang-Ah) Kim" Date: Thu, 27 Oct 2022 13:41:19 -0400 Subject: [PATCH] src/goMain: show warning message about go.enableCodeLens.references Also remove the warning message about old go.languageServerExperimentalFeature.documentLink. The seeting was gone long ago. Updates golang/vscode-go#2509 Change-Id: I49127f9d6fab3a8dfc5a6bf7e1b361a23deef43a Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/445935 TryBot-Result: kokoro Run-TryBot: Hyang-Ah Hana Kim Reviewed-by: Jamal Carvalho --- src/goMain.ts | 54 ++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 45 insertions(+), 9 deletions(-) diff --git a/src/goMain.ts b/src/goMain.ts index 55f7e350cd..873f2eb1ef 100644 --- a/src/goMain.ts +++ b/src/goMain.ts @@ -371,23 +371,17 @@ function lintDiagnosticCollectionName(lintToolName: string) { } async function showDeprecationWarning() { - // Present a warning about the deprecation of the go.documentLink setting. - const experimentalFeatures = getGoConfig()['languageServerExperimentalFeatures']; + const cfg = getGoConfig(); + const experimentalFeatures = cfg['languageServerExperimentalFeatures']; if (experimentalFeatures) { // TODO(golang/vscode-go#50): Eventually notify about deprecation of // all of the settings. See golang/vscode-go#1109 too. // The `diagnostics` setting is still used as a workaround for running custom vet. - if (experimentalFeatures['documentLink'] === false) { - vscode.window - .showErrorMessage(`The 'go.languageServerExperimentalFeature.documentLink' setting is now deprecated. - Please use '"gopls": {"ui.navigation.importShortcut": "Definition" }' instead. - See [the settings doc](https://github.com/golang/vscode-go/blob/master/docs/settings.md#uinavigationimportshortcut) for more details.`); - } const promptKey = 'promptedLanguageServerExperimentalFeatureDeprecation'; const prompted = getFromGlobalState(promptKey, false); if (!prompted && experimentalFeatures['diagnostics'] === false) { const msg = `The 'go.languageServerExperimentalFeature.diagnostics' setting will be deprecated soon. - If you would like additional configuration for diagnostics from gopls, please see and response to [Issue 50](https://github.com/golang/vscode-go/issues/50).`; + If you would like additional configuration for diagnostics from gopls, please see and response to [Issue 50](https://go.dev/s/vscode-issue/50).`; const selected = await vscode.window.showInformationMessage(msg, "Don't show again"); switch (selected) { case "Don't show again": @@ -395,4 +389,46 @@ async function showDeprecationWarning() { } } } + const codelensFeatures = cfg['enableCodeLens']; + if (codelensFeatures && codelensFeatures['references']) { + const promptKey = 'promptedCodeLensReferencesFeatureDeprecation'; + const prompted = getFromGlobalState(promptKey, false); + if (!prompted) { + const msg = + "The 'go.enableCodeLens.references' setting will be removed soon. Please see [Issue 2509](https://go.dev/s/vscode-issue/2509)."; + const selected = await vscode.window.showWarningMessage(msg, 'Update Settings', "Don't show again"); + switch (selected) { + case 'Update Settings': + { + const { globalValue, workspaceValue, workspaceFolderValue } = cfg.inspect<{ + [key: string]: boolean; + }>('enableCodeLens') || { + globalValue: undefined, + workspaceValue: undefined, + workspaceFolderValue: undefined + }; + if (globalValue && globalValue['references']) { + delete globalValue.references; + cfg.update('enableCodeLens', globalValue, vscode.ConfigurationTarget.Global); + } + if (workspaceValue && workspaceValue['references']) { + delete workspaceValue.references; + cfg.update('enableCodeLens', workspaceValue, vscode.ConfigurationTarget.Workspace); + } + if (workspaceFolderValue && workspaceFolderValue['references']) { + delete workspaceFolderValue.references; + cfg.update( + 'enableCodeLens', + workspaceFolderValue, + vscode.ConfigurationTarget.WorkspaceFolder + ); + } + } + break; + case "Don't show again": + updateGlobalState(promptKey, true); + break; + } + } + } }