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 <hyangah@gmail.com>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
diff --git a/docs/commands.md b/docs/commands.md
index 03a9919..e75e936 100644
--- a/docs/commands.md
+++ b/docs/commands.md
@@ -190,3 +190,11 @@
 ### `Go: Choose Go Environment`
 
 Choose a different Go version or binary for this project. (WIP)
+
+### `Go: Show Survey Configuration`
+
+Show the current Go survey configuration
+
+### `Go: Reset Survey Configuration`
+
+Reset the current Go survey configuration history
diff --git a/package.json b/package.json
index 5bac921..c95d718 100644
--- a/package.json
+++ b/package.json
@@ -365,6 +365,16 @@
         "command": "go.environment.choose",
         "title": "Go: Choose Go Environment",
         "description": "Choose a different Go version or binary for this project. (WIP)"
+      },
+      {
+        "command": "go.survey.showConfig",
+        "title": "Go: Show Survey Configuration",
+        "description": "Show the current Go survey configuration"
+      },
+      {
+        "command": "go.survey.resetConfig",
+        "title": "Go: Reset Survey Configuration",
+        "description": "Reset the current Go survey configuration history"
       }
     ],
     "breakpoints": [
diff --git a/src/goLanguageServer.ts b/src/goLanguageServer.ts
index 7c5811e..e229a39 100644
--- a/src/goLanguageServer.ts
+++ b/src/goLanguageServer.ts
@@ -45,7 +45,7 @@
 import { GoReferenceProvider } from './goReferences';
 import { GoRenameProvider } from './goRename';
 import { GoSignatureHelpProvider } from './goSignature';
-import { updateLanguageServerIconGoStatusBar } from './goStatus';
+import { outputChannel, updateLanguageServerIconGoStatusBar } from './goStatus';
 import { GoCompletionItemProvider } from './goSuggest';
 import { GoWorkspaceSymbolProvider } from './goSymbol';
 import { getTool, Tool } from './goTools';
@@ -1005,8 +1005,31 @@
 	}
 }
 
+export async function showSurveyConfig() {
+	outputChannel.appendLine('Gopls Survey Configuration');
+	outputChannel.appendLine(JSON.stringify(getSurveyConfig(), null, 2));
+	outputChannel.show();
+
+	const selected = await vscode.window.showInformationMessage(`Maybe prompt for survey?`, 'Yes', 'No');
+	switch (selected) {
+		case 'Yes':
+			maybePromptForGoplsSurvey();
+			break;
+		default:
+			break;
+	}
+}
+
+export function resetSurveyConfig() {
+	flushSurveyConfig(null);
+}
+
 function flushSurveyConfig(cfg: SurveyConfig) {
-	updateGlobalState(goplsSurveyConfig, JSON.stringify(cfg));
+	if (cfg) {
+		updateGlobalState(goplsSurveyConfig, JSON.stringify(cfg));
+	} else {
+		updateGlobalState(goplsSurveyConfig, null);  // reset
+	}
 }
 
 // errorKind refers to the different possible kinds of gopls errors.
diff --git a/src/goMain.ts b/src/goMain.ts
index b8b520f..462d6a8 100644
--- a/src/goMain.ts
+++ b/src/goMain.ts
@@ -34,6 +34,8 @@
 import {
 	languageServerIsRunning,
 	promptForLanguageServerDefaultChange,
+	resetSurveyConfig,
+	showSurveyConfig,
 	startLanguageServerWithFallback, watchLanguageServerConfiguration
 } from './goLanguageServer';
 import { lintCode } from './goLint';
@@ -507,6 +509,12 @@
 		})
 	);
 
+	// Survey related commands
+	ctx.subscriptions.push(
+		vscode.commands.registerCommand('go.survey.showConfig', () => showSurveyConfig()));
+	ctx.subscriptions.push(
+		vscode.commands.registerCommand('go.survey.resetConfig', () => resetSurveyConfig()));
+
 	vscode.languages.setLanguageConfiguration(GO_MODE.language, {
 		wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g
 	});