| 358 | } |
| 359 | |
| 360 | export 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; |
nothing calls this directly
no test coverage detected