[ruby/reline] Correspond to refactored RubyLex

(https://github.com/ruby/reline/pull/498)

* Correspond to refactored RubyLex

ref: https://github.com/ruby/irb/pull/503

* Fix test_yamatanooroti
This commit is contained in:
HASUMI Hitoshi 2023-01-14 18:19:37 +09:00 коммит произвёл git
Родитель cb9b885e78
Коммит 5b26f76ad9
1 изменённых файлов: 6 добавлений и 8 удалений

Просмотреть файл

@ -4,11 +4,11 @@ require 'irb/ruby-lex'
class TerminationChecker < RubyLex class TerminationChecker < RubyLex
def terminated?(code) def terminated?(code)
code.gsub!(/\n*$/, '').concat("\n") code.gsub!(/\n*$/, '').concat("\n")
@tokens = self.class.ripper_lex_without_warning(code) tokens = self.class.ripper_lex_without_warning(code)
continue = process_continue continue = process_continue(tokens)
code_block_open = check_code_block(code) code_block_open = check_code_block(code, tokens)
indent = process_nesting_level indent = process_nesting_level(tokens)
ltype = process_literal_type ltype = process_literal_type(tokens)
if code_block_open or ltype or continue or indent > 0 if code_block_open or ltype or continue or indent > 0
false false
else else
@ -19,9 +19,7 @@ end
class AutoIndent < RubyLex class AutoIndent < RubyLex
def initialize def initialize
context = Struct.new("MockIRBContext", :auto_indent_mode, :workspace, :local_variables).new(true, nil, []) @context = Struct.new("MockIRBContext", :auto_indent_mode, :workspace, :local_variables).new(true, nil, [])
set_input(self, context: context)
set_auto_indent(context)
end end
def auto_indent(&block) def auto_indent(&block)