diff --git a/packages/debug/src/browser/debug-session-manager.ts b/packages/debug/src/browser/debug-session-manager.ts index 40045b1661859..1b0bd4b9f474a 100644 --- a/packages/debug/src/browser/debug-session-manager.ts +++ b/packages/debug/src/browser/debug-session-manager.ts @@ -380,7 +380,7 @@ export class DebugSessionManager { } protected async doStart(sessionId: string, options: DebugConfigurationSessionOptions): Promise { - const parentSession = options.configuration.parentSession && this._sessions.get(options.configuration.parentSession.id); + const parentSession = options.configuration.parentSessionId ? this._sessions.get(options.configuration.parentSessionId) : undefined; const contrib = this.sessionContributionRegistry.get(options.configuration.type); const sessionFactory = contrib ? contrib.debugSessionFactory() : this.debugSessionFactory; const session = sessionFactory.get(sessionId, options, parentSession); diff --git a/packages/debug/src/common/debug-configuration.ts b/packages/debug/src/common/debug-configuration.ts index 8eb3ea4232f91..d0ecc48d1e4d3 100644 --- a/packages/debug/src/common/debug-configuration.ts +++ b/packages/debug/src/common/debug-configuration.ts @@ -35,7 +35,7 @@ export interface DebugConfiguration { */ [key: string]: any; - parentSession?: { id: string }; + parentSessionId?: string; lifecycleManagedByParent?: boolean; @@ -80,7 +80,7 @@ export namespace DebugConfiguration { export interface DebugSessionOptions { lifecycleManagedByParent?: boolean; - parentSession?: { id: string }; + parentSessionId?: string; consoleMode?: DebugConsoleMode; noDebug?: boolean; compact?: boolean; diff --git a/packages/plugin-ext/src/common/plugin-api-rpc.ts b/packages/plugin-ext/src/common/plugin-api-rpc.ts index 83df9be8d0eb5..74448ef3edd6a 100644 --- a/packages/plugin-ext/src/common/plugin-api-rpc.ts +++ b/packages/plugin-ext/src/common/plugin-api-rpc.ts @@ -109,6 +109,7 @@ import { ThemeType } from '@theia/core/lib/common/theme'; import { Disposable } from '@theia/core/lib/common/disposable'; import { PickOptions, QuickInputButtonHandle } from '@theia/core/lib/common'; import { Severity } from '@theia/core/lib/common/severity'; +import { DebugConfiguration, DebugSessionOptions } from '@theia/debug/lib/common/debug-configuration'; export interface PreferenceData { [scope: number]: any; @@ -1800,10 +1801,10 @@ export interface DebugExt { $resolveDebugConfigurationWithSubstitutedVariablesByHandle( handle: number, workspaceFolder: string | undefined, - debugConfiguration: theia.DebugConfiguration + debugConfiguration: DebugConfiguration ): Promise; - $createDebugSession(debugConfiguration: theia.DebugConfiguration, workspaceFolder: string | undefined): Promise; + $createDebugSession(debugConfiguration: DebugConfiguration, workspaceFolder: string | undefined): Promise; $terminateDebugSession(sessionId: string): Promise; $getTerminalCreationOptions(debugType: string): Promise; } @@ -1817,7 +1818,7 @@ export interface DebugMain { $unregisterDebugConfigurationProvider(handle: number): Promise; $addBreakpoints(breakpoints: Breakpoint[]): Promise; $removeBreakpoints(breakpoints: string[]): Promise; - $startDebugging(folder: theia.WorkspaceFolder | undefined, nameOrConfiguration: string | theia.DebugConfiguration, options: theia.DebugSessionOptions): Promise; + $startDebugging(folder: theia.WorkspaceFolder | undefined, nameOrConfiguration: string | theia.DebugConfiguration, options: DebugSessionOptions): Promise; $stopDebugging(sessionId?: string): Promise; $customRequest(sessionId: string, command: string, args?: any): Promise; $getDebugProtocolBreakpoint(sessionId: string, breakpointId: string): Promise; diff --git a/packages/plugin-ext/src/plugin/debug/debug-ext.ts b/packages/plugin-ext/src/plugin/debug/debug-ext.ts index 96ae50ba4b0bd..146d4d3b65d71 100644 --- a/packages/plugin-ext/src/plugin/debug/debug-ext.ts +++ b/packages/plugin-ext/src/plugin/debug/debug-ext.ts @@ -32,6 +32,7 @@ import { DebugAdapter } from '@theia/debug/lib/common/debug-model'; import { PluginDebugAdapterCreator } from './plugin-debug-adapter-creator'; import { NodeDebugAdapterCreator } from '../node/debug/plugin-node-debug-adapter-creator'; import { DebugProtocol } from '@vscode/debugprotocol'; +import { DebugConfiguration } from '@theia/debug/lib/common/debug-configuration'; interface ConfigurationProviderRecord { handle: number; @@ -171,7 +172,13 @@ export class DebugExtImpl implements DebugExt { } startDebugging(folder: theia.WorkspaceFolder | undefined, nameOrConfiguration: string | theia.DebugConfiguration, options: theia.DebugSessionOptions): PromiseLike { - return this.proxy.$startDebugging(folder, nameOrConfiguration, options); + return this.proxy.$startDebugging(folder, nameOrConfiguration, { + parentSessionId: options.parentSession?.id, + compact: options.compact, + consoleMode: options.consoleMode, + lifecycleManagedByParent: options.lifecycleManagedByParent, + noDebug: options.noDebug + }); } stopDebugging(session?: theia.DebugSession): PromiseLike { @@ -313,13 +320,15 @@ export class DebugExtImpl implements DebugExt { return undefined; } - async $createDebugSession(debugConfiguration: theia.DebugConfiguration, workspaceFolderUri: string | undefined): Promise { + async $createDebugSession(debugConfiguration: DebugConfiguration, workspaceFolderUri: string | undefined): Promise { const sessionId = uuid.v4(); + const parentSession = debugConfiguration.parentSessionId ? this.sessions.get(debugConfiguration.parentSessionId) : undefined; const theiaSession: theia.DebugSession = { id: sessionId, type: debugConfiguration.type, name: debugConfiguration.name, + parentSession: parentSession, workspaceFolder: this.toWorkspaceFolder(workspaceFolderUri), configuration: debugConfiguration, customRequest: async (command: string, args?: any) => { diff --git a/packages/plugin-ext/src/plugin/debug/plugin-debug-adapter-session.ts b/packages/plugin-ext/src/plugin/debug/plugin-debug-adapter-session.ts index 577c82937c74e..098194d994b08 100644 --- a/packages/plugin-ext/src/plugin/debug/plugin-debug-adapter-session.ts +++ b/packages/plugin-ext/src/plugin/debug/plugin-debug-adapter-session.ts @@ -24,11 +24,7 @@ import { DebugChannel } from '@theia/debug/lib/common/debug-service'; /** * Server debug adapter session. */ -export class PluginDebugAdapterSession extends DebugAdapterSessionImpl { - readonly type: string; - readonly name: string; - readonly workspaceFolder: theia.WorkspaceFolder | undefined; - readonly configuration: theia.DebugConfiguration; +export class PluginDebugAdapterSession extends DebugAdapterSessionImpl implements theia.DebugSession { constructor( override readonly debugAdapter: DebugAdapter, @@ -36,12 +32,24 @@ export class PluginDebugAdapterSession extends DebugAdapterSessionImpl { protected readonly theiaSession: theia.DebugSession) { super(theiaSession.id, debugAdapter); + } + + get parentSession(): theia.DebugSession | undefined { + return this.theiaSession.parentSession; + } - this.type = theiaSession.type; - this.name = theiaSession.name; - this.workspaceFolder = theiaSession.workspaceFolder; - this.configuration = theiaSession.configuration; + get type(): string { + return this.theiaSession.type; } + get name(): string { + return this.theiaSession.name; + }; + get workspaceFolder(): theia.WorkspaceFolder | undefined { + return this.theiaSession.workspaceFolder; + }; + get configuration(): theia.DebugConfiguration { + return this.theiaSession.configuration; + }; override async start(channel: DebugChannel): Promise { if (this.tracker.onWillStartSession) { diff --git a/packages/plugin/src/theia.d.ts b/packages/plugin/src/theia.d.ts index 2a64228cfc63c..885b163ef018b 100644 --- a/packages/plugin/src/theia.d.ts +++ b/packages/plugin/src/theia.d.ts @@ -10664,6 +10664,12 @@ export module '@theia/plugin' { */ readonly name: string; + /** + * The parent session of this debug session, if it was created as a child. + * @see DebugSessionOptions.parentSession + */ + readonly parentSession?: DebugSession; + /** * The workspace folder of this session or `undefined` for a folderless setup. */