protected async evaluateRequest()

in src/adapter/daffodilDebug.ts [568:625]


  protected async evaluateRequest(
    response: DebugProtocol.EvaluateResponse,
    args: DebugProtocol.EvaluateArguments
  ): Promise<void> {
    let reply: string | undefined = undefined

    if (args.context === 'repl') {
      // 'evaluate' supports to create and delete breakpoints from the 'repl':
      const matches = /new +([0-9]+)/.exec(args.expression)
      if (matches && matches.length === 2) {
        const mbp = await this._runtime.setBreakPoint(
          this._runtime.sourceFile,
          this.convertClientLineToDebugger(parseInt(matches[1]))
        )
        const bp = new Breakpoint(
          mbp.verified,
          this.convertDebuggerLineToClient(mbp.line),
          undefined,
          this.createSource(this._runtime.sourceFile)
        ) as DebugProtocol.Breakpoint
        bp.id = mbp.id
        this.sendEvent(new BreakpointEvent('new', bp))
        reply = `breakpoint created`
      } else {
        const matches = /del +([0-9]+)/.exec(args.expression)
        if (matches && matches.length === 2) {
          const mbp = this._runtime.clearBreakPoint(
            this._runtime.sourceFile,
            this.convertClientLineToDebugger(parseInt(matches[1]))
          )
          if (mbp) {
            const bp = new Breakpoint(false) as DebugProtocol.Breakpoint
            bp.id = mbp.id
            this.sendEvent(new BreakpointEvent('removed', bp))
            reply = `breakpoint deleted`
          }
        } else {
          const matches = /progress/.exec(args.expression)
          if (matches && matches.length === 1) {
            if (this._reportProgress) {
              reply = `progress started`
              await this.progressSequence()
            } else {
              reply = `frontend doesn't support progress (capability 'supportsProgressReporting' not set)`
            }
          }
        }
      }
    }

    response.body = {
      result: reply
        ? reply
        : `evaluate(context: '${args.context}', '${args.expression}')`,
      variablesReference: 0,
    }
    this.sendResponse(response)
  }