diff options
author | Takashi Kokubun <[email protected]> | 2022-11-21 00:46:22 -0800 |
---|---|---|
committer | git <[email protected]> | 2022-11-21 08:46:27 +0000 |
commit | c9fbc779a680f3e1fd884ec80722cd32a990e0e9 (patch) | |
tree | eaecf5a5673cbd05b9ffb3747ce724323254edb5 /lib/irb/context.rb | |
parent | 65e31402ae46672e87cddb1f2e618d1c00591151 (diff) |
[ruby/irb] Add commands to start and use the debugger
(https://github.com/ruby/irb/pull/449)
* Seamlessly integrate a few debug commands
* Improve the break command support
* Utilize skip_src option if available
* Add step and delete commands
* Write end-to-end tests for each debugger command
* Add documentation
* Add backtrace, info, catch commands
https://github.com/ruby/irb/commit/976100c1c2
Diffstat (limited to 'lib/irb/context.rb')
-rw-r--r-- | lib/irb/context.rb | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/irb/context.rb b/lib/irb/context.rb index c5d98772b8..91fbb2fcf1 100644 --- a/lib/irb/context.rb +++ b/lib/irb/context.rb @@ -486,9 +486,9 @@ module IRB @workspace.local_variable_set(:_, exception) end - # Transform a non-identifier alias (ex: @, $) + # Transform a non-identifier alias (@, $) or keywords (next, break) command, args = line.split(/\s/, 2) - if original = symbol_alias(command) + if original = command_aliases[command.to_sym] line = line.gsub(/\A#{Regexp.escape(command)}/, original.to_s) command = original end @@ -545,10 +545,16 @@ module IRB workspace.binding.local_variables end - # Return a command name if it's aliased from the argument and it's not an identifier. - def symbol_alias(command) + # Return true if it's aliased from the argument and it's not an identifier. + def symbol_alias?(command) return nil if command.match?(/\A\w+\z/) - command_aliases[command.to_sym] + command_aliases.key?(command.to_sym) + end + + # Return true if the command supports transforming args + def transform_args?(command) + command = command_aliases.fetch(command.to_sym, command) + ExtendCommandBundle.load_command(command)&.respond_to?(:transform_args) end end end |