From 75770e1f857b4d423eca56ff0bda4ac5d12e60c2 Mon Sep 17 00:00:00 2001 From: Alan Donovan Date: Tue, 27 Jun 2023 13:30:25 -0400 Subject: [PATCH] package.json: add gopls.start_debugging This command invokes the gopls command that starts its internal debugging web server (and requests that the client open the web page). I used the terms "language server" instead of gopls, and "maintainer interface" instead of debug server since "debug" has a different conntation in the VS Code UI. Tested manually. Change-Id: I9fe5d90f095ef3eed4ea2c1a7ba42117ceb002a2 Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/506516 Run-TryBot: Alan Donovan Reviewed-by: Hyang-Ah Hana Kim Auto-Submit: Alan Donovan TryBot-Result: kokoro --- docs/commands.md | 4 ++++ package.json | 5 +++++ src/commands/index.ts | 1 + src/commands/startLanguageServer.ts | 16 ++++++++++++++++ src/goMain.ts | 1 + 5 files changed, 27 insertions(+) diff --git a/docs/commands.md b/docs/commands.md index c9cd7a05ca..372613a48e 100644 --- a/docs/commands.md +++ b/docs/commands.md @@ -159,6 +159,10 @@ Toggles between file in current active editor and the corresponding test file. Toggle the display of vulnerability analysis in dependencies. +### `Go: Start language server's maintainer interface` + +Start the Go language server's maintainer interface (a web server). + ### `Go: Add Tags To Struct Fields` Add tags configured in go.addTags setting to selected struct using gomodifytags diff --git a/package.json b/package.json index 439b79e284..5ca41b0cb1 100644 --- a/package.json +++ b/package.json @@ -397,6 +397,11 @@ "title": "Go: Toggle Vulncheck", "description": "Toggle the display of vulnerability analysis in dependencies." }, + { + "command": "go.languageserver.maintain", + "title": "Go: Start language server's maintainer interface", + "description": "Start the Go language server's maintainer interface (a web server)." + }, { "command": "go.add.tags", "title": "Go: Add Tags To Struct Fields", diff --git a/src/commands/index.ts b/src/commands/index.ts index d15dffc76c..5e05bda95b 100644 --- a/src/commands/index.ts +++ b/src/commands/index.ts @@ -21,6 +21,7 @@ export { runBuilds } from './runBuilds'; export { showCommands } from './showCommands'; export { startDebugSession } from './startDebugSession'; export { startLanguageServer } from './startLanguageServer'; +export { startGoplsMaintainerInterface } from './startLanguageServer'; export { toggleGCDetails } from './toggleGCDetails'; type CommandCallback = (...args: T) => Promise | unknown; diff --git a/src/commands/startLanguageServer.ts b/src/commands/startLanguageServer.ts index e2c6f13bca..351d691e5f 100644 --- a/src/commands/startLanguageServer.ts +++ b/src/commands/startLanguageServer.ts @@ -138,3 +138,19 @@ function shouldActivateLanguageFeatures() { } return true; } + +export const startGoplsMaintainerInterface: CommandFactory = (ctx, goCtx) => { + return () => { + if (!goCtx.languageServerIsRunning) { + vscode.window.showErrorMessage( + '"Go: Start language server\'s maintainer interface" command is available only when the language server is running' + ); + return; + } + vscode.commands.executeCommand('gopls.start_debugging', {}).then(undefined, (reason) => { + vscode.window.showErrorMessage( + `"Go: Start language server's maintainer interface" command failed: ${reason}` + ); + }); + }; +}; diff --git a/src/goMain.ts b/src/goMain.ts index 79304cb64b..f1f91636b9 100644 --- a/src/goMain.ts +++ b/src/goMain.ts @@ -103,6 +103,7 @@ export async function activate(ctx: vscode.ExtensionContext): Promise