Files
arduino-ide/arduino-ide-extension/src/browser/theia/debug/debug-session-contribution.ts
2025-03-29 01:33:25 +09:00

56 lines
1.7 KiB
TypeScript

import { injectable } from '@theia/core/shared/inversify';
import { DebugSessionConnection } from '@theia/debug/lib/browser/debug-session-connection';
import { DefaultDebugSessionFactory as TheiaDefaultDebugSessionFactory } from '@theia/debug/lib/browser/debug-session-contribution';
import { DebugSessionManager } from '@theia/debug/lib/browser/debug-session-manager';
import { DebugConfigurationSessionOptions } from '@theia/debug/lib/browser/debug-session-options';
import {
DebugAdapterPath,
DebugChannel,
ForwardingDebugChannel,
} from '@theia/debug/lib/common/debug-service';
import { DebugSession } from './debug-session';
@injectable()
export class DefaultDebugSessionFactory extends TheiaDefaultDebugSessionFactory {
override get(
manager: DebugSessionManager,
sessionId: string,
options: DebugConfigurationSessionOptions,
parentSession?: DebugSession
): DebugSession {
const connection = new DebugSessionConnection(
sessionId,
() =>
new Promise<DebugChannel>((resolve) =>
this.connectionProvider.listen(
`${DebugAdapterPath}/${sessionId}`,
(_, wsChannel) => {
resolve(new ForwardingDebugChannel(wsChannel));
},
false
)
),
this.getTraceOutputChannel()
);
// patched debug session
return new DebugSession(
sessionId,
options,
parentSession,
this.testService,
options.testRun,
manager,
connection,
this.terminalService,
this.editorManager,
this.breakpoints,
this.labelProvider,
this.messages,
this.fileService,
this.debugContributionProvider,
this.workspaceService,
2_000
);
}
}