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

Store context in RubyLex #503

Merged
merged 1 commit into from
Jan 14, 2023
Merged

Store context in RubyLex #503

merged 1 commit into from
Jan 14, 2023

Conversation

st0012
Copy link
Member

@st0012 st0012 commented Jan 10, 2023

Some background/assumptions 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 once 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.

Copy link
Collaborator

@hasumikin hasumikin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

I made a related PR ruby/reline#498

@st0012
Copy link
Member Author

st0012 commented Jan 12, 2023

@hasumikin That's awesome, thank you 👍

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.
@hasumikin hasumikin merged commit 5c8d3df into master Jan 14, 2023
@hasumikin hasumikin deleted the store-context-in-lexer branch January 14, 2023 09:19
hasumikin added a commit to ruby/reline that referenced this pull request Jan 14, 2023
* Correspond to refactored RubyLex

ref: ruby/irb#503

* Fix test_yamatanooroti
matzbot pushed a commit to ruby/ruby that referenced this pull request Jan 14, 2023
(ruby/reline#498)

* Correspond to refactored RubyLex

ref: ruby/irb#503

* Fix test_yamatanooroti
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants