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

Method acquireDap

src/dapDebugServer.ts:142–178  ·  view source on GitHub ↗

@inheritdoc

(target: ITarget)

Source from the content-addressed store, hash-verified

140
141 /** @inheritdoc */
142 public async acquireDap(target: ITarget): Promise<DapConnection> {
143 const existing = this.sessions.get(target.id());
144 if (existing) {
145 const { connection } = await existing.promise;
146 return connection;
147 }
148
149 const parent = target.parent();
150 let dap: Dap.Api;
151 if (parent) {
152 const parentCnx = this.sessions.get(parent.id())?.settledValue;
153 if (!parentCnx) {
154 throw new Error('Expected parent session to have a settled value');
155 }
156 dap = parentCnx.connection.dap();
157 } else {
158 dap = this.dapRoot;
159 }
160
161 const deferred = getDeferred<ISessionInfo>();
162 this.sessions.set(target.id(), deferred);
163
164 // don't await on this, otherwise we deadlock since the promise may not
165 // resolve until launch is finished, which requires returning from this method
166 dap
167 .startDebuggingRequest({
168 request: target.launchConfig.request,
169 configuration: {
170 type: target.launchConfig.type,
171 name: target.name(),
172 __pendingTargetId: target.id(),
173 },
174 })
175 .catch(e => deferred.reject(e));
176
177 return deferred.promise.then(d => d.connection);
178 }
179
180 /** @inheritdoc */
181 public async initAdapter(adapter: DebugAdapter, target: ITarget): Promise<boolean> {

Callers

nothing calls this directly

Calls 8

getDeferredFunction · 0.90
dapMethod · 0.80
startDebuggingRequestMethod · 0.80
getMethod · 0.65
idMethod · 0.65
parentMethod · 0.65
setMethod · 0.65
nameMethod · 0.65

Tested by

no test coverage detected