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

Don't use lex_state emulation on Ruby 2.5 or later #546

Merged
merged 2 commits into from
Nov 7, 2017

Conversation

aycabta
Copy link
Member

@aycabta aycabta commented Oct 19, 2017

RDoc::RipperStateLex has InnerStateLex that is emulation layer about lex_state of parse.y, but after Ruby 2.5 or later, Ripper gives lex_state value as state method inside Ripper::Filter's callback. On this Pull Request, uses the new feature of Ripper on Ruby 2.5 or later.

RDoc::RipperStateLex has InnerStateLex that is emulation layer about
lex_state of parse.y, but after Ruby 2.5 or later, Ripper gives
lex_state value as state method inside Ripper::Filter's callback.
On this commit, uses the new feature of Ripper on Ruby 2.5 or later.
@@ -1,6 +1,9 @@
require 'ripper'

class RDoc::RipperStateLex
# TODO: Remove this constants after Ruby 2.4 EOL
RIPPER_HAS_LEX_STATE = (RUBY_VERSION >= '2.5.0')
Copy link
Member

Choose a reason for hiding this comment

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

Should we use respond_to? instead of RUBY_VERSION ?

Copy link
Member

Choose a reason for hiding this comment

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

or defined?

@aycabta aycabta force-pushed the remove-lex_state-emulation-on-ruby25 branch from 55d568d to ee9d50a Compare October 25, 2017 12:07
@aycabta
Copy link
Member Author

aycabta commented Oct 25, 2017

OK, I'll use Ripper::Filter.method_defined?(:state).

@@ -1,6 +1,9 @@
require 'ripper'

class RDoc::RipperStateLex
# TODO: Remove this constants after Ruby 2.4 EOL
RIPPER_HAS_LEX_STATE = Ripper::Filter.method_defined?(:state)
Copy link
Member

Choose a reason for hiding this comment

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

👍

@hsbt hsbt merged commit b55f2f9 into ruby:master Nov 7, 2017
@aycabta aycabta deleted the remove-lex_state-emulation-on-ruby25 branch November 8, 2017 06:40
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