(args: Dap.EvaluateParams)
| 341 | } |
| 342 | |
| 343 | async evaluate(args: Dap.EvaluateParams): Promise<Dap.EvaluateResult | Dap.Error> { |
| 344 | let callFrameId: Cdp.Debugger.CallFrameId | undefined; |
| 345 | if (args.frameId !== undefined) { |
| 346 | const stackFrame = this._pausedDetails |
| 347 | ? this._pausedDetails.stackTrace.frame(args.frameId) |
| 348 | : undefined; |
| 349 | if (!stackFrame) return this._stackFrameNotFoundError(); |
| 350 | callFrameId = stackFrame.callFrameId(); |
| 351 | if (!callFrameId) return this._evaluateOnAsyncFrameError(); |
| 352 | } |
| 353 | |
| 354 | if (args.context === 'repl' && args.expression.startsWith('cd ')) { |
| 355 | const contextName = args.expression.substring('cd '.length).trim(); |
| 356 | for (const ec of this._executionContexts.values()) { |
| 357 | if (this._delegate.executionContextName(ec.description) === contextName) { |
| 358 | this._selectedContext = ec; |
| 359 | return { |
| 360 | result: `[${contextName}]`, |
| 361 | variablesReference: 0, |
| 362 | }; |
| 363 | } |
| 364 | } |
| 365 | } |
| 366 | |
| 367 | // For clipboard evaluations, return a safe JSON-stringified string. |
| 368 | const params: Cdp.Runtime.EvaluateParams = |
| 369 | args.context === 'clipboard' |
| 370 | ? { |
| 371 | expression: serializeForClipboardTmpl(args.expression, '2'), |
| 372 | includeCommandLineAPI: true, |
| 373 | returnByValue: true, |
| 374 | objectGroup: 'console', |
| 375 | } |
| 376 | : { |
| 377 | expression: args.expression, |
| 378 | includeCommandLineAPI: true, |
| 379 | objectGroup: 'console', |
| 380 | generatePreview: true, |
| 381 | timeout: args.context === 'hover' ? 500 : undefined, |
| 382 | }; |
| 383 | |
| 384 | if (args.context === 'repl') { |
| 385 | params.expression = sourceUtils.wrapObjectLiteral(params.expression); |
| 386 | if (params.expression.indexOf('await') !== -1) { |
| 387 | const rewritten = sourceUtils.rewriteTopLevelAwait(params.expression); |
| 388 | if (rewritten) { |
| 389 | params.expression = rewritten; |
| 390 | params.awaitPromise = true; |
| 391 | } |
| 392 | } |
| 393 | } |
| 394 | |
| 395 | const responsePromise = this.evaluator.evaluate( |
| 396 | callFrameId |
| 397 | ? { ...params, callFrameId } |
| 398 | : { |
| 399 | ...params, |
| 400 | contextId: this._selectedContext ? this._selectedContext.description.id : undefined, |
nothing calls this directly
no test coverage detected