Add support for elp.debugSingle command

Summary: * Add a `elp.debugSingle` command, which will eventually be used by the ELP "debug" code lens to start a debugging session for a given testcase.

Reviewed By: alanz

Differential Revision: D68159114

fbshipit-source-id: f0c2396f40518b1dd590eea49c6b300265899d7a
This commit is contained in:
Roberto Aloi 2025-01-16 00:48:46 -08:00 committed by Facebook GitHub Bot
parent 9ca22ec50f
commit 71978c9c8b
3 changed files with 33 additions and 3 deletions

View file

@ -9,6 +9,7 @@
import * as vscode from 'vscode';
import * as dapConfig from './dapConfig';
import * as edbDebugger from './debugger';
export type Runnable = {
label: string;
@ -39,6 +40,15 @@ export function registerCommands(context: vscode.ExtensionContext) {
},
),
);
// elp.debugSingle
context.subscriptions.push(
vscode.commands.registerCommand(
'elp.debugSingle',
async (runnable: Runnable) => {
await debugSingle(runnable);
},
),
);
}
export function runSingle(runnable: Runnable): Thenable<vscode.TaskExecution> {
@ -90,3 +100,23 @@ export function buildTask(
const exec = new vscode.ProcessExecution(command, args, definition);
return new vscode.Task(definition, vscode.TaskScope.Workspace, name, task_source, exec, []);
}
export async function debugSingle(runnable: Runnable): Promise<void> {
const debugConfiguration = {
type: edbDebugger.DEBUG_TYPE,
name: 'Erlang EDB',
request: 'launch',
launchCommand: {
cwd: "${workspaceFolder}",
command: "rebar3",
arguments: [
"ct",
"--sname",
"debuggee",
runnable.args.args
]
},
targetNode: 'debuggee'
};
await vscode.debug.startDebugging(undefined, debugConfiguration);
}

View file

@ -26,4 +26,4 @@ export function withErlangInstallationPath(): string {
export function command(): string {
const dapConfig = vscode.workspace.getConfiguration(DAP_CONFIG);
return dapConfig.get<string>('command') || '';
}
}

View file

@ -10,9 +10,9 @@
import * as vscode from 'vscode';
import * as dapConfig from './dapConfig';
const DEBUG_TYPE = 'erlang-edb';
export const DEBUG_TYPE = 'erlang-edb';
interface EdbDebugConfiguration extends vscode.DebugConfiguration {
export interface EdbDebugConfiguration extends vscode.DebugConfiguration {
launchCommand: {
command: string;
arguments?: Array<string>;