diff --git a/packages/metals-languageclient/src/interfaces/DebugDiscoveryParams.ts b/packages/metals-languageclient/src/interfaces/DebugDiscoveryParams.ts index 9eb40a40..9d7200e0 100644 --- a/packages/metals-languageclient/src/interfaces/DebugDiscoveryParams.ts +++ b/packages/metals-languageclient/src/interfaces/DebugDiscoveryParams.ts @@ -1,6 +1,12 @@ export interface DebugDiscoveryParams { - path: string; + path: string | undefined; + mainClass: string | undefined; + buildTarget: string | undefined; runType: RunType; + args: string[] | undefined; + jvmOptions: string[] | undefined; + env: Map | undefined; + envFile: string | undefined; } export enum RunType { diff --git a/packages/metals-vscode/src/debugger/scalaDebugger.ts b/packages/metals-vscode/src/debugger/scalaDebugger.ts index 92e3fcfa..703052dd 100644 --- a/packages/metals-vscode/src/debugger/scalaDebugger.ts +++ b/packages/metals-vscode/src/debugger/scalaDebugger.ts @@ -168,6 +168,12 @@ class ScalaMainConfigProvider implements vscode.DebugConfigurationProvider { const args: DebugDiscoveryParams = { path: editor.document.uri.toString(true), runType: RunType.RunOrTestFile, + buildTarget: undefined, + mainClass: undefined, + args: undefined, + jvmOptions: undefined, + env: undefined, + envFile: undefined, }; await startDiscovery(debugConfiguration.noDebug, args); return debugConfiguration; @@ -186,15 +192,34 @@ class ScalaDebugServerFactory implements vscode.DebugAdapterDescriptorFactory { session.configuration.testClass !== undefined || session.configuration.hostName !== undefined ) { - const debugSession = await vscode.commands.executeCommand( - ServerCommands.DebugAdapterStart, - session.configuration - ); - - if (debugSession === undefined) { - return null; + if (session.configuration.noDebug) { + const args: DebugDiscoveryParams = { + path: undefined, + mainClass: session.configuration.mainClass, + buildTarget: session.configuration.buildTarget, + runType: RunType.Run, + args: session.configuration.args, + jvmOptions: session.configuration.jvmOptions, + env: session.configuration.env, + envFile: session.configuration.envFile, + }; + await startDiscovery(session.configuration.noDebug, args); + + // This is the only way not to have to run full fledged DAP server + return new vscode.DebugAdapterExecutable("echo", [ + '"Running in the task window"', + ]); } else { - return debugServerFromUri(debugSession.uri); + const debugSession = await vscode.commands.executeCommand( + ServerCommands.DebugAdapterStart, + session.configuration + ); + + if (debugSession === undefined) { + return null; + } else { + return debugServerFromUri(debugSession.uri); + } } } return null; diff --git a/packages/metals-vscode/src/extension.ts b/packages/metals-vscode/src/extension.ts index 006de20a..ed2444de 100644 --- a/packages/metals-vscode/src/extension.ts +++ b/packages/metals-vscode/src/extension.ts @@ -842,6 +842,12 @@ function launchMetals( const args: DebugDiscoveryParams = { path: editor.document.uri.toString(true), runType: RunType.RunOrTestFile, + buildTarget: undefined, + mainClass: undefined, + args: undefined, + jvmOptions: undefined, + env: undefined, + envFile: undefined, }; scalaDebugger.startDiscovery(true, args).then((wasStarted) => { if (!wasStarted) { @@ -854,6 +860,12 @@ function launchMetals( const args: DebugDiscoveryParams = { path: editor.document.uri.toString(true), runType: RunType.TestTarget, + buildTarget: undefined, + mainClass: undefined, + args: undefined, + jvmOptions: undefined, + env: undefined, + envFile: undefined, }; scalaDebugger.startDiscovery(true, args).then((wasStarted) => { if (!wasStarted) {