Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RUBY-31157 #237 Fix signatures for IRB >= 1.6.3 #238

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions lib/ruby-debug-ide/commands/expression_info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,16 @@ def execute
string_to_parse = Command.unescape_incoming(@match.post_match) + " \n \n\n"
total_lines = string_to_parse.count("\n") + 1

lexer = RubyLex.new
lexer.set_input(create_io_reader(string_to_parse))
IRB.init_config(nil) unless IRB.conf && IRB.conf[:PROMPT]
irb_workspace = IRB::WorkSpace.new Object.new
irb_context = IRB::Context.new(nil, irb_workspace)

lexer = RubyLex.instance_method(:initialize).arity == 1 ?
RubyLex.new(irb_context) : RubyLex.new
lexer.method(:set_input).arity == 1 ?
lexer.set_input(create_io_reader(string_to_parse)) :
lexer.set_input(create_io_reader(string_to_parse), context: irb_context)


last_statement = ''
last_prompt = ''
Expand All @@ -25,9 +33,9 @@ def execute
last_indent = indent
end

lexer.each_top_level_statement do |line, line_no|
last_statement = line
end
lexer.method(:each_top_level_statement).arity == 0 ?
lexer.each_top_level_statement { |line, line_no| last_statement = line } :
lexer.each_top_level_statement(irb_context) { |line, line_no| last_statement = line }

incomplete = true
if /\A\s*\Z/m =~ last_statement
Expand Down