Class: Byebug::DAP::Command::Variables

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

Constant Summary

Constants inherited from Byebug::DAP::Command

EVAL_ERROR

Instance Method Summary collapse

Methods included from ValueHelpers

#prepare_value, #prepare_value_response

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



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/byebug/dap/commands/variables.rb', line 10

def execute
  started!

  thnum, frnum, named, indexed = resolve_variables_reference(args.variablesReference)

  case args.filter
  when 'named'
    indexed = []
  when 'indexed'
    named = []
  end

  vars = named + indexed

  first = args.start || 0
  last = args.count ? first + args.count : vars.size
  last = vars.size unless last < vars.size

  variables = vars[first...last].map { |var, get| prepare_value_response(thnum, frnum, :variable, name: var) { get.call(var) } }

  respond! body: Protocol::VariablesResponseBody.new(variables: variables)
end