Module: Debugger::Completion

Extended by:
Completion
Included in:
Completion
Defined in:
lib/debugger/completion.rb

Defined Under Namespace

Modules: Command

Constant Summary collapse

VERSION =
'1.0.0'
COMMANDS =
[ "backtrace", "break", "catch", "condition", "continue",
  "delete", "disable", "display", "down", "edit", "enable", "eval", "exit",
    "finish", "frame", "help", "info", "irb", "jump", "list", "method", "next",
    "p", "pp", "ps", "putl", "quit", "reload", "restart", "save", "set",
    "show", "source", "step", "thread", "tmate", "trace", "undisplay",
    "up", "var", "where"
]

Instance Method Summary collapse

Instance Method Details

#commandsObject



38
# File 'lib/debugger/completion.rb', line 38

def commands; COMMANDS; end

#current_bindingObject



47
48
49
# File 'lib/debugger/completion.rb', line 47

def current_binding
  (cmd = first_object(Debugger::Command)) && cmd.send(:get_binding) rescue nil
end

#default_actionObject



40
41
42
43
44
45
# File 'lib/debugger/completion.rb', line 40

def default_action
  completions = commands + ['completion_toggle']
  completions += @irb_completion ? Bond::DefaultMission.completions + Object.constants :
    Bond::Mission.current_eval("local_variables | instance_variables")
  completions - ['__dbg_verbose_save']
end

#first_object(klass) ⇒ Object



51
52
53
54
# File 'lib/debugger/completion.rb', line 51

def first_object(klass)
  ObjectSpace.each_object(klass) {|e| return e }
  nil
end

#startObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/debugger/completion.rb', line 16

def start
  Bond.restart(:eval_binding=>lambda { Debugger::Completion.current_binding },
             :default_mission=>lambda {|e| Debugger::Completion.default_action }) do
    complete(:methods=>%w{catch cat}) { objects_of(Class).select {|e| e < StandardError } }
    complete(:methods=>%w{disable enable}) { %w{breakpoints display} }
    complete(:methods=>['help', 'h']) { Debugger::Completion.commands }
    complete(:method=>'info') { %w{args breakpoints catch display file files} +
      %w{global_variables instance_variables line locals program stack thread} +
      %w{threads variables}
    }
    complete(:methods=>%w{set show}) { %w{annotate args autoeval autolist autoirb} +
      %w{basename callstyle debuggertesting forcestep fullpath history} +
      %w{keep-frame-bindings linetrace+ linetrace listsize trace width}
    }
    complete(:methods=>%w{quit exit q}) { %w{unconditionally} }
    complete(:methods=>%w{save source}, :action=>:files)
    complete(:methods=>%w{thread th}) { %w{list stop resume switch current} }
    complete(:methods=>%w{trace tr}) { %w{on off var} }
    complete(:methods=>%w{var v}) { %w{class const global instance local} }
  end
end

#toggle_irb_completionObject



56
57
58
# File 'lib/debugger/completion.rb', line 56

def toggle_irb_completion
  @irb_completion = !@irb_completion
end