-
Notifications
You must be signed in to change notification settings - Fork 136
Simplify each_top_level_statement #576
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
Conversation
9ac0f6f to
7907a48
Compare
| end | ||
| def save_prompt_to_context_io(ltype, indent, continue, line_num_offset) | ||
| # Implicitly saves prompt string to `@context.io.prompt`. This will be used in the next `@input.call`. | ||
| @prompt.call(ltype, indent, continue, @line_no + line_num_offset) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@prompt is not going to be nil in actual use cases because Irb#eval_input always calls RubyLex#set_prompt before calling RubyLex#each_top_level_statemen.
But I think this type of implicit dependency is risky and we should probably refactor that later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍 But I think there's a conflict in test file.
Co-authored-by: Stan Lo <stan001212@gmail.com>
da1c0aa to
dfd4ced
Compare
(ruby/irb#576) * Simplify each_top_level_statement, reduce instance vars * Update lib/irb/ruby-lex.rb Co-authored-by: Stan Lo <stan001212@gmail.com> * Remove unused ltype from TestRubyLex#check_state response * Remove unnecessary const path of TerminateLineInput * Combine duplicated code state check into method --------- ruby/irb@172453cec4 Co-authored-by: Stan Lo <stan001212@gmail.com>
This pull request is an extract of refactor from #500
Refactored each_top_level_statement
@exp_line_no@indent@continue@linefromruby-lex.rbdef each_top_level_statementtodef readmultilinecatch(:TERM_INPUT)andthrow :TERM_INPUTinto simple loop and breakdef lexbecause it is only used from test code now