summaryrefslogtreecommitdiff
path: root/lib/irb.rb
diff options
context:
space:
mode:
authorStan Lo <stan001212@gmail.com>2023-01-10 20:43:33 +0000
committergit <svn-admin@ruby-lang.org>2023-01-14 09:19:09 +0000
commitcb9b885e78bb87195d483df1afedf58d0bb81e41 (patch)
tree1ba732ebb576213869f099b5bcb1b1d33620de16 /lib/irb.rb
parent2082ba7c69c1d38508bfa549df3f2980cf8d066d (diff)
[ruby/irb] Store context in RubyLex
Some background for this refactor: 1. Through a RubyLex instance's lifetime, the context passed to its methods should be the same. Given that `Context` is only initialised in `Irb#initialize`, this should be true. 2. When `RubyLex` is initialised, the context object should be accessible. This is also true in all 3 of `RubyLex.new`'s invocations. With the above observations, we should be able to store the context in `RubyLex` as an instance variable. And doing so will make `RubyLex`'s instance methods easier to use and maintain. https://github.com/ruby/irb/commit/5c8d3df2df
Diffstat (limited to 'lib/irb.rb')
-rw-r--r--lib/irb.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/irb.rb b/lib/irb.rb
index a33efa7be9..96dbaaa65b 100644
--- a/lib/irb.rb
+++ b/lib/irb.rb
@@ -468,7 +468,7 @@ module IRB
@context = Context.new(self, workspace, input_method)
@context.main.extend ExtendCommandBundle
@signal_status = :IN_IRB
- @scanner = RubyLex.new
+ @scanner = RubyLex.new(@context)
end
# A hook point for `debug` command's TracePoint after :IRB_EXIT as well as its clean-up
@@ -538,7 +538,7 @@ module IRB
@context.io.prompt
end
- @scanner.set_input(@context.io, context: @context) do
+ @scanner.set_input(@context.io) do
signal_status(:IN_INPUT) do
if l = @context.io.gets
print l if @context.verbose?
@@ -556,9 +556,9 @@ module IRB
end
end
- @scanner.set_auto_indent(@context) if @context.auto_indent_mode
+ @scanner.set_auto_indent
- @scanner.each_top_level_statement(@context) do |line, line_no|
+ @scanner.each_top_level_statement do |line, line_no|
signal_status(:IN_EVAL) do
begin
line.untaint if RUBY_VERSION < '2.7'