Class: Byebug::DAP::Command::BreakpointLocations

Inherits:
Byebug::DAP::Command show all
Defined in:
lib/byebug/dap/commands/breakpoint_locations.rb

Constant Summary

Constants inherited from Byebug::DAP::Command

EVAL_ERROR

Instance Method Summary collapse

Methods inherited from Byebug::DAP::Command

command, execute, #execute_on_thread, #initialize, #log, register!, resolve!, #safe_execute, #started!, #stopped!

Methods included from SafeHelpers

#safe

Constructor Details

This class inherits a constructor from Byebug::DAP::Command

Instance Method Details

#executeObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/byebug/dap/commands/breakpoint_locations.rb', line 7

def execute
  return unless path = can_read_file!(args.source.path)
  lines = potential_breakpoint_lines(path) { |e|
    respond! success: false, message: "Failed to resolve breakpoints for #{path}"
    return
  }

  unless args.endLine
    if lines.include?(args.line)
      respond! body: { breakpoints: [{ line: args.line }] }
    else
      respond! body: { breakpoints: [] }
    end
    return
  end

  range = [args.line..args.endLine]
  lines.filter! { |l| range.include?(l) }
  respond! body: { breakpoints: lines.map { |l| { line: l } } }
end