Skip to content

Commit

Permalink
package.json: add gopls.start_debugging
Browse files Browse the repository at this point in the history
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 <adonovan@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
  • Loading branch information
adonovan authored and gopherbot committed Jul 5, 2023
1 parent 5f5a875 commit 75770e1
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<T extends unknown[]> = (...args: T) => Promise<unknown> | unknown;
Expand Down
16 changes: 16 additions & 0 deletions src/commands/startLanguageServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`
);
});
};
};
1 change: 1 addition & 0 deletions src/goMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<ExtensionA

const registerCommand = commands.createRegisterCommand(ctx, goCtx);
registerCommand('go.languageserver.restart', commands.startLanguageServer);
registerCommand('go.languageserver.maintain', commands.startGoplsMaintainerInterface);

await commands.startLanguageServer(ctx, goCtx)(RestartReason.ACTIVATION);

Expand Down

0 comments on commit 75770e1

Please sign in to comment.