mirror of
https://github.com/ruby/ruby.git
synced 2025-08-25 05:55:46 +02:00

(https://github.com/ruby/irb/pull/824)
* Command is not a method
* Fix command test
* Implement non-method command name completion
* Add test for ExtendCommandBundle.def_extend_command
* Add helper method install test
* Remove spaces in command input parse
* Remove command arg unquote in help command
* Simplify Statement and handle execution in IRB::Irb
* Tweak require, const name
* Always install CommandBundle module to main object
* Remove considering local variable in command or expression check
* Remove unused method, tweak
* Remove outdated comment for help command arg
Co-authored-by: Stan Lo <stan001212@gmail.com>
---------
8fb776e379
Co-authored-by: Stan Lo <stan001212@gmail.com>
80 lines
1.4 KiB
Ruby
80 lines
1.4 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
module IRB
|
|
class Statement
|
|
attr_reader :code
|
|
|
|
def is_assignment?
|
|
raise NotImplementedError
|
|
end
|
|
|
|
def suppresses_echo?
|
|
raise NotImplementedError
|
|
end
|
|
|
|
def should_be_handled_by_debugger?
|
|
raise NotImplementedError
|
|
end
|
|
|
|
class EmptyInput < Statement
|
|
def is_assignment?
|
|
false
|
|
end
|
|
|
|
def suppresses_echo?
|
|
true
|
|
end
|
|
|
|
# Debugger takes empty input to repeat the last command
|
|
def should_be_handled_by_debugger?
|
|
true
|
|
end
|
|
|
|
def code
|
|
""
|
|
end
|
|
end
|
|
|
|
class Expression < Statement
|
|
def initialize(code, is_assignment)
|
|
@code = code
|
|
@is_assignment = is_assignment
|
|
end
|
|
|
|
def suppresses_echo?
|
|
@code.match?(/;\s*\z/)
|
|
end
|
|
|
|
def should_be_handled_by_debugger?
|
|
true
|
|
end
|
|
|
|
def is_assignment?
|
|
@is_assignment
|
|
end
|
|
end
|
|
|
|
class Command < Statement
|
|
attr_reader :command_class, :arg
|
|
|
|
def initialize(original_code, command_class, arg)
|
|
@code = original_code
|
|
@command_class = command_class
|
|
@arg = arg
|
|
end
|
|
|
|
def is_assignment?
|
|
false
|
|
end
|
|
|
|
def suppresses_echo?
|
|
false
|
|
end
|
|
|
|
def should_be_handled_by_debugger?
|
|
require_relative 'command/debug'
|
|
IRB::Command::DebugCommand > @command_class
|
|
end
|
|
end
|
|
end
|
|
end
|