Skip to content

Commit

Permalink
Add "parentSession" field to theia.DebugSession
Browse files Browse the repository at this point in the history
Fixes eclipse-theia#11512

Contributed on behalf of ST Microelectronics

Signed-off-by: Thomas Mäder <[email protected]>
  • Loading branch information
tsmaeder committed Oct 14, 2022
1 parent e96bb5b commit 24dddaa
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 13 deletions.
2 changes: 1 addition & 1 deletion packages/plugin-ext/src/common/plugin-api-rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1782,7 +1782,7 @@ export interface DebugExt {
debugConfiguration: theia.DebugConfiguration
): Promise<theia.DebugConfiguration | undefined | null>;

$createDebugSession(debugConfiguration: theia.DebugConfiguration, workspaceFolder: string | undefined): Promise<string>;
$createDebugSession(debugConfiguration: theia.DebugConfiguration, parentSessionId: string | undefined, workspaceFolder: string | undefined): Promise<string>;
$terminateDebugSession(sessionId: string): Promise<void>;
$getTerminalCreationOptions(debugType: string): Promise<TerminalOptionsExt | undefined>;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class PluginDebugAdapterContribution {

async createDebugSession(config: DebugConfiguration, workspaceFolder: string | undefined): Promise<string> {
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<void> {
Expand Down
3 changes: 2 additions & 1 deletion packages/plugin-ext/src/plugin/debug/debug-ext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,13 +313,14 @@ export class DebugExtImpl implements DebugExt {
return undefined;
}

async $createDebugSession(debugConfiguration: theia.DebugConfiguration, workspaceFolderUri: string | undefined): Promise<string> {
async $createDebugSession(debugConfiguration: theia.DebugConfiguration, parentSessionId: string | undefined, workspaceFolderUri: string | undefined): Promise<string> {
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) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,36 @@ 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,
protected readonly tracker: theia.DebugAdapterTracker,
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<void> {
if (this.tracker.onWillStartSession) {
this.tracker.onWillStartSession();
Expand Down
6 changes: 6 additions & 0 deletions packages/plugin/src/theia.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down

0 comments on commit 24dddaa

Please sign in to comment.