summaryrefslogtreecommitdiff
path: root/lib/irb/context.rb
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2022-11-21 00:46:22 -0800
committergit <svn-admin@ruby-lang.org>2022-11-21 08:46:27 +0000
commitc9fbc779a680f3e1fd884ec80722cd32a990e0e9 (patch)
treeeaecf5a5673cbd05b9ffb3747ce724323254edb5 /lib/irb/context.rb
parent65e31402ae46672e87cddb1f2e618d1c00591151 (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.rb16
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