diff --git a/editors/code/client/src/commands.ts b/editors/code/client/src/commands.ts index a902773687..b57302cea7 100644 --- a/editors/code/client/src/commands.ts +++ b/editors/code/client/src/commands.ts @@ -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 { @@ -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 { + 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); +} diff --git a/editors/code/client/src/dapConfig.ts b/editors/code/client/src/dapConfig.ts index 1141f2eb5b..f5eae2cc66 100644 --- a/editors/code/client/src/dapConfig.ts +++ b/editors/code/client/src/dapConfig.ts @@ -26,4 +26,4 @@ export function withErlangInstallationPath(): string { export function command(): string { const dapConfig = vscode.workspace.getConfiguration(DAP_CONFIG); return dapConfig.get('command') || ''; -} \ No newline at end of file +} diff --git a/editors/code/client/src/debugger.ts b/editors/code/client/src/debugger.ts index ebd76673b0..dd537fa3ea 100644 --- a/editors/code/client/src/debugger.ts +++ b/editors/code/client/src/debugger.ts @@ -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;