MCPcopy
hub / github.com/microsoft/vscode-js-debug / Session

Class Session

src/sessionManager.ts:43–89  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41 * @template TSessionImpl Type of the mplementation specific debug session
42 */
43export class Session<TSessionImpl extends IDebugSessionLike> implements IDisposable {
44 public readonly connection: DapConnection;
45 private readonly subscriptions = new DisposableList();
46
47 constructor(
48 public readonly debugSession: TSessionImpl,
49 transport: IDapTransport | DapConnection,
50 public readonly logger: ILogger,
51 public readonly sessionStates: SessionSubStates,
52 private readonly parent?: Session<TSessionImpl>,
53 ) {
54 if (transport instanceof DapConnection) {
55 this.connection = transport;
56 } else {
57 transport.setLogger(logger);
58 this.connection = new DapConnection(transport, this.logger);
59 }
60 }
61
62 listenToTarget(target: ITarget) {
63 this.subscriptions.push(
64 target.onNameChanged(() => this.setName(target)),
65 this.sessionStates.onAdd(
66 ([sessionId]) => sessionId === this.debugSession.id && this.setName(target),
67 ),
68 this.sessionStates.onRemove(
69 ([sessionId]) => sessionId === this.debugSession.id && this.setName(target),
70 ),
71 );
72
73 this.setName(target);
74 }
75
76 dispose() {
77 this.subscriptions.dispose();
78 }
79
80 private setName(target: ITarget) {
81 const substate = this.sessionStates.get(this.debugSession.id);
82 let name = target.name();
83 if (this.parent instanceof RootSession) {
84 name = `${name} « ${this.parent.debugSession.name}`;
85 }
86
87 this.debugSession.name = substate ? `${name} (${substate})` : name;
88 }
89}
90
91export class RootSession<TSessionImpl extends IDebugSessionLike> extends Session<TSessionImpl> {
92 private _binder?: Binder;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected