Class: Byebug::DAP::Command::Scopes

Inherits:
Byebug::DAP::Command show all
Defined in:
lib/byebug/dap/commands/scopes.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/byebug/dap/commands/scopes.rb', line 7

def execute
  started!

  frame, thnum, frnum = resolve_frame_id(args.frameId)
  return unless frame

  scopes = []

  locals = frame_local_names(frame).sort
  unless locals.empty?
    scopes << Protocol::Scope.new(
      name: 'Locals',
      presentationHint: 'locals',
      variablesReference: @session.save_variables(thnum, frnum, :locals, locals),
      namedVariables: locals.size,
      indexedVariables: 0,
      expensive: false)
      .validate!
  end

  globals = global_names.sort
  unless globals.empty?
    scopes << Protocol::Scope.new(
      name: 'Globals',
      presentationHint: 'globals',
      variablesReference: @session.save_variables(thnum, frnum, :globals, globals),
      namedVariables: globals.size,
      indexedVariables: 0,
      expensive: true)
      .validate!
  end

  respond! body: Protocol::ScopesResponseBody.new(scopes: scopes)
end