class Byebug::DAP::Command::Variables

Public Instance Methods

execute() click to toggle source
# 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