Skip to content

Commit 76e3f4c

Browse files
committed
src/goLanguageServer: add survey config inspection commands
go.survey.showConfig: retrieve the current config from the memento. Users can optionally select to run the survey prompt decision making process. go.survey.resetConfig: clear the current config state stored in the memento. Change-Id: I7340bdf709d568981481e091cea12b9ca4efc388 Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/263899 Trust: Hyang-Ah Hana Kim <[email protected]> Run-TryBot: Hyang-Ah Hana Kim <[email protected]> TryBot-Result: kokoro <[email protected]> Reviewed-by: Rebecca Stambler <[email protected]>
1 parent b44ecdb commit 76e3f4c

File tree

4 files changed

+51
-2
lines changed

4 files changed

+51
-2
lines changed

docs/commands.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,3 +190,11 @@ Restart the running instance of the language server
190190
### `Go: Choose Go Environment`
191191

192192
Choose a different Go version or binary for this project. (WIP)
193+
194+
### `Go: Show Survey Configuration`
195+
196+
Show the current Go survey configuration
197+
198+
### `Go: Reset Survey Configuration`
199+
200+
Reset the current Go survey configuration history

package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,16 @@
365365
"command": "go.environment.choose",
366366
"title": "Go: Choose Go Environment",
367367
"description": "Choose a different Go version or binary for this project. (WIP)"
368+
},
369+
{
370+
"command": "go.survey.showConfig",
371+
"title": "Go: Show Survey Configuration",
372+
"description": "Show the current Go survey configuration"
373+
},
374+
{
375+
"command": "go.survey.resetConfig",
376+
"title": "Go: Reset Survey Configuration",
377+
"description": "Reset the current Go survey configuration history"
368378
}
369379
],
370380
"breakpoints": [

src/goLanguageServer.ts

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ import { GoDocumentSymbolProvider } from './goOutline';
4545
import { GoReferenceProvider } from './goReferences';
4646
import { GoRenameProvider } from './goRename';
4747
import { GoSignatureHelpProvider } from './goSignature';
48-
import { updateLanguageServerIconGoStatusBar } from './goStatus';
48+
import { outputChannel, updateLanguageServerIconGoStatusBar } from './goStatus';
4949
import { GoCompletionItemProvider } from './goSuggest';
5050
import { GoWorkspaceSymbolProvider } from './goSymbol';
5151
import { getTool, Tool } from './goTools';
@@ -1005,8 +1005,31 @@ function getSurveyConfig(): SurveyConfig {
10051005
}
10061006
}
10071007

1008+
export async function showSurveyConfig() {
1009+
outputChannel.appendLine('Gopls Survey Configuration');
1010+
outputChannel.appendLine(JSON.stringify(getSurveyConfig(), null, 2));
1011+
outputChannel.show();
1012+
1013+
const selected = await vscode.window.showInformationMessage(`Maybe prompt for survey?`, 'Yes', 'No');
1014+
switch (selected) {
1015+
case 'Yes':
1016+
maybePromptForGoplsSurvey();
1017+
break;
1018+
default:
1019+
break;
1020+
}
1021+
}
1022+
1023+
export function resetSurveyConfig() {
1024+
flushSurveyConfig(null);
1025+
}
1026+
10081027
function flushSurveyConfig(cfg: SurveyConfig) {
1009-
updateGlobalState(goplsSurveyConfig, JSON.stringify(cfg));
1028+
if (cfg) {
1029+
updateGlobalState(goplsSurveyConfig, JSON.stringify(cfg));
1030+
} else {
1031+
updateGlobalState(goplsSurveyConfig, null); // reset
1032+
}
10101033
}
10111034

10121035
// errorKind refers to the different possible kinds of gopls errors.

src/goMain.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ import {
3434
import {
3535
languageServerIsRunning,
3636
promptForLanguageServerDefaultChange,
37+
resetSurveyConfig,
38+
showSurveyConfig,
3739
startLanguageServerWithFallback, watchLanguageServerConfiguration
3840
} from './goLanguageServer';
3941
import { lintCode } from './goLint';
@@ -507,6 +509,12 @@ export function activate(ctx: vscode.ExtensionContext) {
507509
})
508510
);
509511

512+
// Survey related commands
513+
ctx.subscriptions.push(
514+
vscode.commands.registerCommand('go.survey.showConfig', () => showSurveyConfig()));
515+
ctx.subscriptions.push(
516+
vscode.commands.registerCommand('go.survey.resetConfig', () => resetSurveyConfig()));
517+
510518
vscode.languages.setLanguageConfiguration(GO_MODE.language, {
511519
wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g
512520
});

0 commit comments

Comments
 (0)