Skip to content

Commit 75770e1

Browse files
adonovangopherbot
authored andcommitted
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 <[email protected]> Reviewed-by: Hyang-Ah Hana Kim <[email protected]> Auto-Submit: Alan Donovan <[email protected]> TryBot-Result: kokoro <[email protected]>
1 parent 5f5a875 commit 75770e1

File tree

5 files changed

+27
-0
lines changed

5 files changed

+27
-0
lines changed

docs/commands.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,10 @@ Toggles between file in current active editor and the corresponding test file.
159159

160160
Toggle the display of vulnerability analysis in dependencies.
161161

162+
### `Go: Start language server's maintainer interface`
163+
164+
Start the Go language server's maintainer interface (a web server).
165+
162166
### `Go: Add Tags To Struct Fields`
163167

164168
Add tags configured in go.addTags setting to selected struct using gomodifytags

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,11 @@
397397
"title": "Go: Toggle Vulncheck",
398398
"description": "Toggle the display of vulnerability analysis in dependencies."
399399
},
400+
{
401+
"command": "go.languageserver.maintain",
402+
"title": "Go: Start language server's maintainer interface",
403+
"description": "Start the Go language server's maintainer interface (a web server)."
404+
},
400405
{
401406
"command": "go.add.tags",
402407
"title": "Go: Add Tags To Struct Fields",

src/commands/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export { runBuilds } from './runBuilds';
2121
export { showCommands } from './showCommands';
2222
export { startDebugSession } from './startDebugSession';
2323
export { startLanguageServer } from './startLanguageServer';
24+
export { startGoplsMaintainerInterface } from './startLanguageServer';
2425
export { toggleGCDetails } from './toggleGCDetails';
2526

2627
type CommandCallback<T extends unknown[]> = (...args: T) => Promise<unknown> | unknown;

src/commands/startLanguageServer.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,19 @@ function shouldActivateLanguageFeatures() {
138138
}
139139
return true;
140140
}
141+
142+
export const startGoplsMaintainerInterface: CommandFactory = (ctx, goCtx) => {
143+
return () => {
144+
if (!goCtx.languageServerIsRunning) {
145+
vscode.window.showErrorMessage(
146+
'"Go: Start language server\'s maintainer interface" command is available only when the language server is running'
147+
);
148+
return;
149+
}
150+
vscode.commands.executeCommand('gopls.start_debugging', {}).then(undefined, (reason) => {
151+
vscode.window.showErrorMessage(
152+
`"Go: Start language server's maintainer interface" command failed: ${reason}`
153+
);
154+
});
155+
};
156+
};

src/goMain.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<ExtensionA
103103

104104
const registerCommand = commands.createRegisterCommand(ctx, goCtx);
105105
registerCommand('go.languageserver.restart', commands.startLanguageServer);
106+
registerCommand('go.languageserver.maintain', commands.startGoplsMaintainerInterface);
106107

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

0 commit comments

Comments
 (0)