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

Function enable

src/adapter/breakpoints/breakpointBase.ts:176–213  ·  view source on GitHub ↗

* Sets the breakpoint in the provided thread and marks the "enabled" bit.

(thread: Thread)

Source from the content-addressed store, hash-verified

174 * Sets the breakpoint in the provided thread and marks the "enabled" bit.
175 */
176 public async enable(thread: Thread): Promise<void> {
177 if (this.isEnabled) {
178 return;
179 }
180
181 this.isEnabled = true;
182 const promises: Promise<void>[] = [this._setPredicted(thread)];
183 const source = this._manager._sourceContainer.source(this.source);
184 if (!source || !(source instanceof SourceFromMap)) {
185 promises.push(
186 // For breakpoints set before launch, we don't know whether they are in a compiled or
187 // a source map source. To make them work, we always set by url to not miss compiled.
188 // Additionally, if we have two sources with the same url, but different path (or no path),
189 // this will make breakpoint work in all of them.
190 this._setByPath(
191 thread,
192 source?.offsetSourceToScript(this.originalPosition) || this.originalPosition,
193 ),
194 );
195 }
196
197 await Promise.all(promises);
198
199 // double check still enabled to avoid racing
200 if (source && this.isEnabled) {
201 const uiLocations = await this._manager._sourceContainer.currentSiblingUiLocations({
202 lineNumber: this.originalPosition.lineNumber,
203 columnNumber: this.originalPosition.columnNumber,
204 source,
205 });
206
207 await Promise.all(
208 uiLocations.map(uiLocation =>
209 this._setByUiLocation(thread, source.offsetSourceToScript(uiLocation))
210 ),
211 );
212 }
213 }
214
215 /**
216 * Updates the breakpoint's locations in the UI. Should be called whenever

Callers

nothing calls this directly

Calls 8

_setPredictedMethod · 0.80
_setByPathMethod · 0.80
allMethod · 0.80
mapMethod · 0.80
sourceMethod · 0.65
pushMethod · 0.65
offsetSourceToScriptMethod · 0.45

Tested by

no test coverage detected