[前][次][番号順一覧][スレッド一覧]

ruby-changes:64464

From: aycabta <ko1@a...>
Date: Tue, 22 Dec 2020 23:51:19 +0900 (JST)
Subject: [ruby-changes:64464] 47b26795d0 (master): [ruby/irb] Change variables handling for compatibility

https://git.ruby-lang.org/ruby.git/commit/?id=47b26795d0

From 47b26795d06ea13d646edddd51470d9a6cd377b4 Mon Sep 17 00:00:00 2001
From: aycabta <aycabta@g...>
Date: Tue, 22 Dec 2020 04:49:02 +0900
Subject: [ruby/irb] Change variables handling for compatibility

https://github.com/ruby/irb/commit/26fd1a75cf

diff --git a/lib/irb/ruby-lex.rb b/lib/irb/ruby-lex.rb
index 040c93e..7114522 100644
--- a/lib/irb/ruby-lex.rb
+++ b/lib/irb/ruby-lex.rb
@@ -201,14 +201,14 @@ class RubyLex https://github.com/ruby/ruby/blob/trunk/lib/irb/ruby-lex.rb#L201
     code = @line + (line.nil? ? '' : line)
     code.gsub!(/\s*\z/, '').concat("\n")
     @tokens = ripper_lex_without_warning(code)
-    @continue = process_continue(@tokens)
-    @code_block_open = check_code_block(code, @tokens)
-    @indent = process_nesting_level(@tokens)
-    @ltype = process_literal_type(@tokens)
+    @continue = process_continue
+    @code_block_open = check_code_block(code)
+    @indent = process_nesting_level
+    @ltype = process_literal_type
     line
   end
 
-  def process_continue(tokens)
+  def process_continue(tokens = @tokens)
     # last token is always newline
     if tokens.size >= 2 and tokens[-2][1] == :on_regexp_end
       # end of regexp literal
@@ -228,7 +228,7 @@ class RubyLex https://github.com/ruby/ruby/blob/trunk/lib/irb/ruby-lex.rb#L228
     false
   end
 
-  def check_code_block(code, tokens)
+  def check_code_block(code, tokens = @tokens)
     return true if tokens.empty?
     if tokens.last[1] == :on_heredoc_beg
       return true
@@ -321,7 +321,7 @@ class RubyLex https://github.com/ruby/ruby/blob/trunk/lib/irb/ruby-lex.rb#L321
     false
   end
 
-  def process_nesting_level(tokens)
+  def process_nesting_level(tokens = @tokens)
     indent = 0
     in_oneliner_def = nil
     tokens.each_with_index { |t, index|
@@ -574,7 +574,7 @@ class RubyLex https://github.com/ruby/ruby/blob/trunk/lib/irb/ruby-lex.rb#L574
     start_token.last.nil? ? '' : start_token.last
   end
 
-  def process_literal_type(tokens)
+  def process_literal_type(tokens = @tokens)
     start_token = check_string_literal(tokens)
     case start_token[1]
     when :on_tstring_beg
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]