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

Class SessionManager

src/sessionManager.ts:123–288  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

121}
122
123export class SessionManager<TSessionImpl extends IDebugSessionLike>
124 implements IDisposable, IBinderDelegate
125{
126 private _disposables: IDisposable[] = [];
127 private _sessions = new Map<string, Session<TSessionImpl>>();
128
129 private _pendingTarget = new Map<string, { target: ITarget; parent: Session<TSessionImpl> }>();
130 private _sessionForTarget = new Map<ITarget, Promise<Session<TSessionImpl>>>();
131 private _sessionForTargetCallbacks = new Map<
132 ITarget,
133 { fulfill: (session: Session<TSessionImpl>) => void; reject: (error: Error) => void }
134 >();
135
136 constructor(
137 private readonly globalContainer: Container,
138 private readonly sessionLauncher: ISessionLauncher<TSessionImpl>,
139 ) {}
140
141 public terminate(debugSession: TSessionImpl) {
142 const session = this._sessions.get(debugSession.id);
143 this._sessions.delete(debugSession.id);
144 if (session) session.dispose();
145 }
146
147 /**
148 * Gets whether the pending target ID exists.
149 */
150 public hasPendingTargetId(targetId: string) {
151 return this._pendingTarget.has(targetId);
152 }
153
154 public createNewRootSession(
155 debugSession: TSessionImpl,
156 transport: IDapTransport | DapConnection,
157 ) {
158 const root = new RootSession(
159 debugSession,
160 transport,
161 createTopLevelSessionContainer(this.globalContainer),
162 );
163 root.createBinder(this);
164 this._sessions.set(debugSession.id, root);
165 return root;
166 }
167
168 /**
169 * @inheritdoc
170 */
171 public createNewChildSession(
172 debugSession: TSessionImpl,
173 pendingTargetId: string,
174 transport: IDapTransport | DapConnection,
175 ): Session<TSessionImpl> {
176 const pending = this._pendingTarget.get(pendingTargetId);
177 if (!pending) {
178 throw new Error(`Cannot find target ${pendingTargetId}`);
179 }
180

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected