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

Class StackFrame

src/adapter/stackTrace.ts:360–693  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

358}
359
360export class StackFrame implements IStackFrameElement {
361 public readonly frameId = frameIdCounter();
362 /** Override for the `name` in the DAP representation. */
363 public overrideName?: string;
364 /** @inheritdoc */
365 public readonly root = this;
366
367 private _rawLocation: RawLocation;
368
369 /** @inheritdoc */
370 public readonly uiLocation: () =>
371 | Promise<IPreferredUiLocation | undefined>
372 | IPreferredUiLocation
373 | undefined;
374 private _scope: IScope | undefined;
375 private _thread: Thread;
376 public readonly isReplEval: boolean;
377
378 public get rawPosition() {
379 // todo: move RawLocation to use Positions, then just return that.
380 return new Base1Position(this._rawLocation.lineNumber, this._rawLocation.columnNumber);
381 }
382
383 /** Raw chain from the runtime, applicable only to debug-triggered traces */
384 public get rawScopeChain() {
385 return this._scope?.chain || [];
386 }
387
388 static fromRuntime(
389 thread: Thread,
390 callFrame: Cdp.Runtime.CallFrame,
391 isAsync: boolean,
392 ): StackFrame {
393 return new StackFrame(thread, callFrame, thread.rawLocation(callFrame), isAsync);
394 }
395
396 static fromDebugger(thread: Thread, callFrame: Cdp.Debugger.CallFrame): StackFrame {
397 const result = new StackFrame(thread, callFrame, thread.rawLocation(callFrame));
398 result._scope = {
399 chain: callFrame.scopeChain,
400 thisObject: callFrame.this,
401 returnValue: callFrame.returnValue,
402 variables: new Array(callFrame.scopeChain.length).fill(undefined),
403 // eslint-disable-next-line
404 callFrameId: callFrame.callFrameId!,
405 };
406 return result;
407 }
408
409 constructor(
410 thread: Thread,
411 private readonly callFrame: Cdp.Debugger.CallFrame | Cdp.Runtime.CallFrame,
412 rawLocation: RawLocation,
413 private readonly isAsync = false,
414 ) {
415 this._rawLocation = rawLocation;
416 this.uiLocation = once(() => thread.rawLocationToUiLocation(rawLocation));
417 this._thread = thread;

Callers

nothing calls this directly

Calls 11

_scopeVariableMethod · 0.95
onceFunction · 0.90
shouldStepOverStackFrameFunction · 0.90
getEnhancedNameFunction · 0.85
getDefaultNameFunction · 0.85
uiLocationMethod · 0.80
pausedVariablesMethod · 0.80
getVariableNamesMethod · 0.80
mapMethod · 0.80
allMethod · 0.80
pushMethod · 0.65

Tested by

no test coverage detected