module DEBUGGER__::UI_DAP

def event type, *args

def event type, *args
  case type
  when :load
    file_path, reloaded = *args
    if file_path
      send_event 'loadedSource',
                 reason: (reloaded ? :changed : :new),
                 source: {
                   path: file_path,
                 }
    end
  when :suspend_bp
    _i, bp, tid = *args
    if bp.kind_of?(CatchBreakpoint)
      reason = 'exception'
      text = bp.description
    else
      reason = 'breakpoint'
      text = bp ? bp.description : 'temporary bp'
    end
    send_event 'stopped', reason: reason,
                          description: text,
                          text: text,
                          threadId: tid,
                          allThreadsStopped: true
  when :suspend_trap
    _sig, tid = *args
    send_event 'stopped', reason: 'pause',
                          threadId: tid,
                          allThreadsStopped: true
  when :suspended
    tid, = *args
    send_event 'stopped', reason: 'step',
                          threadId: tid,
                          allThreadsStopped: true
  end
end