Add support for elp.restartServer command (#90)

Summary:
Adds the ability to restart the ELP server from the VS Code command palette.

Closes #90.

Reviewed By: alanz

Differential Revision: D72441620

fbshipit-source-id: 7346149f6756520c0fa9cc4fccb0488009eccae7
This commit is contained in:
Roberto Aloi 2025-04-04 01:33:28 -07:00 committed by Facebook GitHub Bot
parent fb987b48e3
commit 01f12130ad
3 changed files with 17 additions and 7 deletions

View file

@ -10,6 +10,7 @@
import * as vscode from 'vscode';
import * as dapConfig from './dapConfig';
import * as edbDebugger from './debugger';
import { LanguageClient } from 'vscode-languageclient/node';
export type Runnable = {
label: string;
@ -30,8 +31,7 @@ export type CommonRunnableArgs = {
workspaceRoot: string;
};
export function registerCommands(context: vscode.ExtensionContext) {
// elp.runSingle
export function registerCommands(context: vscode.ExtensionContext, client: LanguageClient) {
context.subscriptions.push(
vscode.commands.registerCommand(
'elp.runSingle',
@ -39,15 +39,18 @@ export function registerCommands(context: vscode.ExtensionContext) {
await runSingle(runnable);
},
),
);
// elp.debugSingle
context.subscriptions.push(
vscode.commands.registerCommand(
'elp.debugSingle',
async (runnable: Runnable) => {
await debugSingle(runnable);
},
),
vscode.commands.registerCommand(
'elp.restartServer',
async () => {
await client.restart();
},
),
);
}

View file

@ -66,8 +66,6 @@ export function activate(context: vscode.ExtensionContext) {
}
};
registerCommands(context);
// Create the language client and start the client.
client = new LanguageClient(
'elp',
@ -76,6 +74,8 @@ export function activate(context: vscode.ExtensionContext) {
clientOptions
);
registerCommands(context, client);
log.append('Activating debugger');
// Activate the DAP Debugger
activateDebugger(context);

View file

@ -61,6 +61,13 @@
"path": "./third-party/grammar/Erlang.plist"
}
],
"commands": [
{
"command": "elp.restartServer",
"title": "Restart server",
"category": "Erlang"
}
],
"debuggers": [
{
"type": "erlang-edb",