From 24dddaaf4592f21d805b55a3cc7e6cea08b23385 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=A4der?= Date: Fri, 14 Oct 2022 10:02:26 +0200 Subject: [PATCH] Add "parentSession" field to theia.DebugSession MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #11512 Contributed on behalf of ST Microelectronics Signed-off-by: Thomas Mäder --- .../plugin-ext/src/common/plugin-api-rpc.ts | 2 +- .../plugin-debug-adapter-contribution.ts | 2 +- .../plugin-ext/src/plugin/debug/debug-ext.ts | 3 +- .../debug/plugin-debug-adapter-session.ts | 31 +++++++++++++------ packages/plugin/src/theia.d.ts | 6 ++++ 5 files changed, 31 insertions(+), 13 deletions(-) diff --git a/packages/plugin-ext/src/common/plugin-api-rpc.ts b/packages/plugin-ext/src/common/plugin-api-rpc.ts index 4d4b78024b472..f1c515e8497c3 100644 --- a/packages/plugin-ext/src/common/plugin-api-rpc.ts +++ b/packages/plugin-ext/src/common/plugin-api-rpc.ts @@ -1782,7 +1782,7 @@ export interface DebugExt { debugConfiguration: theia.DebugConfiguration ): Promise; - $createDebugSession(debugConfiguration: theia.DebugConfiguration, workspaceFolder: string | undefined): Promise; + $createDebugSession(debugConfiguration: theia.DebugConfiguration, parentSessionId: string | undefined, workspaceFolder: string | undefined): Promise; $terminateDebugSession(sessionId: string): Promise; $getTerminalCreationOptions(debugType: string): Promise; } diff --git a/packages/plugin-ext/src/main/browser/debug/plugin-debug-adapter-contribution.ts b/packages/plugin-ext/src/main/browser/debug/plugin-debug-adapter-contribution.ts index 49f3a93bfd005..3c5f4c328a970 100644 --- a/packages/plugin-ext/src/main/browser/debug/plugin-debug-adapter-contribution.ts +++ b/packages/plugin-ext/src/main/browser/debug/plugin-debug-adapter-contribution.ts @@ -39,7 +39,7 @@ export class PluginDebugAdapterContribution { async createDebugSession(config: DebugConfiguration, workspaceFolder: string | undefined): Promise { await this.pluginService.activateByDebug('onDebugAdapterProtocolTracker', config.type); - return this.debugExt.$createDebugSession(config, workspaceFolder); + return this.debugExt.$createDebugSession(config, config.parentSession?.id, workspaceFolder); } async terminateDebugSession(sessionId: 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..e0485dd7536c5 100644 --- a/packages/plugin-ext/src/plugin/debug/debug-ext.ts +++ b/packages/plugin-ext/src/plugin/debug/debug-ext.ts @@ -313,13 +313,14 @@ export class DebugExtImpl implements DebugExt { return undefined; } - async $createDebugSession(debugConfiguration: theia.DebugConfiguration, workspaceFolderUri: string | undefined): Promise { + async $createDebugSession(debugConfiguration: theia.DebugConfiguration, parentSessionId: string | undefined, workspaceFolderUri: string | undefined): Promise { const sessionId = uuid.v4(); const theiaSession: theia.DebugSession = { id: sessionId, type: debugConfiguration.type, name: debugConfiguration.name, + parentSession: parentSessionId ? this.sessions.get(parentSessionId) : undefined, 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..eda89eb038f84 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,13 +32,28 @@ export class PluginDebugAdapterSession extends DebugAdapterSessionImpl { protected readonly theiaSession: theia.DebugSession) { super(theiaSession.id, debugAdapter); - - 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 parentSession(): theia.DebugSession | undefined { + return this.theiaSession.parentSession; + }; + + 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) { this.tracker.onWillStartSession(); diff --git a/packages/plugin/src/theia.d.ts b/packages/plugin/src/theia.d.ts index 8d3a632aab7db..5ad52da994e58 100644 --- a/packages/plugin/src/theia.d.ts +++ b/packages/plugin/src/theia.d.ts @@ -10417,6 +10417,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. */