public constructor()

in src/adapter/daffodilDebug.ts [82:146]


  public constructor(fileAccessor: FileAccessor) {
    super('daffodil-debugger.txt')

    // this debugger uses zero-based lines and columns
    this.setDebuggerLinesStartAt1(false)
    this.setDebuggerColumnsStartAt1(false)

    this._runtime = new DaffodilRuntime(fileAccessor)

    // setup event handlers
    this._runtime.on('stopOnEntry', () => {
      this.sendEvent(new StoppedEvent('entry', DaffodilDebugSession.threadID))
    })
    this._runtime.on('stopOnStep', () => {
      this.sendEvent(new StoppedEvent('step', DaffodilDebugSession.threadID))
    })
    this._runtime.on('stopOnBreakpoint', () => {
      this.sendEvent(
        new StoppedEvent('breakpoint', DaffodilDebugSession.threadID)
      )
    })
    this._runtime.on('stopOnDataBreakpoint', () => {
      this.sendEvent(
        new StoppedEvent('data breakpoint', DaffodilDebugSession.threadID)
      )
    })
    this._runtime.on('stopOnException', (exception) => {
      if (exception) {
        this.sendEvent(
          new StoppedEvent(
            `exception(${exception})`,
            DaffodilDebugSession.threadID
          )
        )
      } else {
        this.sendEvent(
          new StoppedEvent('exception', DaffodilDebugSession.threadID)
        )
      }
    })
    this._runtime.on('breakpointValidated', (bp: IDaffodilBreakpoint) => {
      this.sendEvent(
        new BreakpointEvent('changed', {
          verified: bp.verified,
          id: bp.id,
        } as DebugProtocol.Breakpoint)
      )
    })
    this._runtime.on('output', (text, filePath, line, column) => {
      const e: DebugProtocol.OutputEvent = new OutputEvent(`${text}\n`)

      if (text === 'start' || text === 'startCollapsed' || text === 'end') {
        e.body.group = text
        e.body.output = `group-${text}\n`
      }

      e.body.source = this.createSource(filePath)
      e.body.line = this.convertDebuggerLineToClient(line)
      e.body.column = this.convertDebuggerColumnToClient(column)
      this.sendEvent(e)
    })
    this._runtime.on('end', () => {
      this.sendEvent(new TerminatedEvent())
    })
  }