Skip to content

Commit

Permalink
Use Ripper::EXPR_LABEL directly
Browse files Browse the repository at this point in the history
Since this is only used from outside RipperStateLex, there's no longer
any benefit to using the indirect reference rather than just going
straight to Ripper.
  • Loading branch information
nevans committed Jun 7, 2024
1 parent 5996255 commit deefe9a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
1 change: 0 additions & 1 deletion lib/rdoc/parser/ripper_state_lex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class RDoc::Parser::RipperStateLex
EXPR_ENDFN = Ripper::EXPR_ENDFN
EXPR_ARG = Ripper::EXPR_ARG
EXPR_FNAME = Ripper::EXPR_FNAME
EXPR_LABEL = Ripper::EXPR_LABEL

class InnerStateLex < Ripper::Filter
def initialize(code)
Expand Down
12 changes: 6 additions & 6 deletions lib/rdoc/parser/ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ def get_included_module_with_optional_parens
when :on_comment, :on_embdoc then
@read.pop
if :on_nl == end_token[:kind] and "\n" == tk[:text][-1] and
(!continue or (tk[:state] & RDoc::Parser::RipperStateLex::EXPR_LABEL) != 0) then
(!continue or (tk[:state] & Ripper::EXPR_LABEL) != 0) then
break if !continue and nest <= 0
end
when :on_comma then
Expand All @@ -526,7 +526,7 @@ def get_included_module_with_optional_parens
nest += 1
when 'if', 'unless', 'while', 'until', 'rescue'
# postfix if/unless/while/until/rescue must be EXPR_LABEL
nest += 1 unless (tk[:state] & RDoc::Parser::RipperStateLex::EXPR_LABEL) != 0
nest += 1 unless (tk[:state] & Ripper::EXPR_LABEL) != 0
when 'end'
nest -= 1
break if nest == 0
Expand Down Expand Up @@ -1041,7 +1041,7 @@ def parse_constant_body container, constant, is_array_or_hash # :nodoc:
elsif (:on_kw == tk[:kind] && 'def' == tk[:text]) then
nest += 1
elsif (:on_kw == tk[:kind] && %w{do if unless case begin}.include?(tk[:text])) then
if (tk[:state] & RDoc::Parser::RipperStateLex::EXPR_LABEL) == 0
if (tk[:state] & Ripper::EXPR_LABEL) == 0
nest += 1
end
elsif [:on_rparen, :on_rbrace, :on_rbracket].include?(tk[:kind]) ||
Expand Down Expand Up @@ -1662,7 +1662,7 @@ def parse_method_or_yield_parameters(method = nil,
when :on_comment, :on_embdoc then
@read.pop
if :on_nl == end_token[:kind] and "\n" == tk[:text][-1] and
(!continue or (tk[:state] & RDoc::Parser::RipperStateLex::EXPR_LABEL) != 0) then
(!continue or (tk[:state] & Ripper::EXPR_LABEL) != 0) then
if method && method.block_params.nil? then
unget_tk tk
read_documentation_modifiers method, modifiers
Expand Down Expand Up @@ -1882,7 +1882,7 @@ def parse_statements(container, single = NORMAL, current_method = nil,
end

when 'until', 'while' then
if (tk[:state] & RDoc::Parser::RipperStateLex::EXPR_LABEL) == 0
if (tk[:state] & Ripper::EXPR_LABEL) == 0
nest += 1
skip_optional_do_after_expression
end
Expand All @@ -1898,7 +1898,7 @@ def parse_statements(container, single = NORMAL, current_method = nil,
skip_optional_do_after_expression

when 'case', 'do', 'if', 'unless', 'begin' then
if (tk[:state] & RDoc::Parser::RipperStateLex::EXPR_LABEL) == 0
if (tk[:state] & Ripper::EXPR_LABEL) == 0
nest += 1
end

Expand Down

0 comments on commit deefe9a

Please sign in to comment.