Skip to content

Commit 9c93b31

Browse files
authored
Merge pull request #631 from aycabta/fix-random_nameerror-of-ripperstatelex
Fix random NameError of RipperStateLex
2 parents d153084 + ff2073f commit 9c93b31

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

lib/rdoc/markup/to_html.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def accept_verbatim verbatim
200200

201201
content = if verbatim.ruby? or parseable? text then
202202
begin
203-
tokens = RDoc::RipperStateLex.parse text
203+
tokens = RDoc::Parser::RipperStateLex.parse text
204204
klass = ' class="ruby"'
205205

206206
result = RDoc::TokenStream.to_html tokens

lib/rdoc/parser/ripper_state_lex.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22
require 'ripper'
33

4-
class RDoc::RipperStateLex
4+
class RDoc::Parser::RipperStateLex
55
# TODO: Remove this constants after Ruby 2.4 EOL
66
RIPPER_HAS_LEX_STATE = Ripper::Filter.method_defined?(:state)
77

lib/rdoc/parser/ruby.rb

+9-9
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def initialize(top_level, file_name, content, options, stats)
179179
@size = 0
180180
@token_listeners = nil
181181
content = RDoc::Encoding.remove_magic_comment content
182-
@scanner = RDoc::RipperStateLex.parse(content)
182+
@scanner = RDoc::Parser::RipperStateLex.parse(content)
183183
@content = content
184184
@scanner_point = 0
185185
@prev_seek = nil
@@ -741,9 +741,9 @@ def parse_call_parameters(tk)
741741
when end_token
742742
if end_token == :on_rparen
743743
nest -= 1
744-
break if RDoc::RipperStateLex.end?(tk) and nest <= 0
744+
break if RDoc::Parser::RipperStateLex.end?(tk) and nest <= 0
745745
else
746-
break if RDoc::RipperStateLex.end?(tk)
746+
break if RDoc::Parser::RipperStateLex.end?(tk)
747747
end
748748
when :on_comment, :on_embdoc
749749
unget_tk(tk)
@@ -961,15 +961,15 @@ def parse_constant_body container, constant, is_array_or_hash # :nodoc:
961961
elsif (:on_kw == tk[:kind] && 'def' == tk[:text]) then
962962
nest += 1
963963
elsif (:on_kw == tk[:kind] && %w{do if unless case begin}.include?(tk[:text])) then
964-
if (tk[:state] & RDoc::RipperStateLex::EXPR_LABEL) == 0
964+
if (tk[:state] & RDoc::Parser::RipperStateLex::EXPR_LABEL) == 0
965965
nest += 1
966966
end
967967
elsif [:on_rparen, :on_rbrace, :on_rbracket].include?(tk[:kind]) ||
968968
(:on_kw == tk[:kind] && 'end' == tk[:text]) then
969969
nest -= 1
970970
elsif (:on_comment == tk[:kind] or :on_embdoc == tk[:kind]) then
971971
unget_tk tk
972-
if nest <= 0 and RDoc::RipperStateLex.end?(tk) then
972+
if nest <= 0 and RDoc::Parser::RipperStateLex.end?(tk) then
973973
body = get_tkread_clean(/^[ \t]+/, '')
974974
read_documentation_modifiers constant, RDoc::CONSTANT_MODIFIERS
975975
break
@@ -985,7 +985,7 @@ def parse_constant_body container, constant, is_array_or_hash # :nodoc:
985985
break
986986
end
987987
elsif :on_nl == tk[:kind] then
988-
if nest <= 0 and RDoc::RipperStateLex.end?(tk) then
988+
if nest <= 0 and RDoc::Parser::RipperStateLex.end?(tk) then
989989
unget_tk tk
990990
break
991991
end
@@ -1555,7 +1555,7 @@ def parse_method_or_yield_parameters(method = nil,
15551555
when :on_comment, :on_embdoc then
15561556
@read.pop
15571557
if :on_nl == end_token[:kind] and "\n" == tk[:text][-1] and
1558-
(!continue or (tk[:state] & RDoc::RipperStateLex::EXPR_LABEL) != 0) then
1558+
(!continue or (tk[:state] & RDoc::Parser::RipperStateLex::EXPR_LABEL) != 0) then
15591559
if method && method.block_params.nil? then
15601560
unget_tk tk
15611561
read_documentation_modifiers method, modifiers
@@ -1772,7 +1772,7 @@ def parse_statements(container, single = NORMAL, current_method = nil,
17721772
end
17731773

17741774
when 'until', 'while' then
1775-
if (tk[:state] & RDoc::RipperStateLex::EXPR_LABEL) == 0
1775+
if (tk[:state] & RDoc::Parser::RipperStateLex::EXPR_LABEL) == 0
17761776
nest += 1
17771777
skip_optional_do_after_expression
17781778
end
@@ -1788,7 +1788,7 @@ def parse_statements(container, single = NORMAL, current_method = nil,
17881788
skip_optional_do_after_expression
17891789

17901790
when 'case', 'do', 'if', 'unless', 'begin' then
1791-
if (tk[:state] & RDoc::RipperStateLex::EXPR_LABEL) == 0
1791+
if (tk[:state] & RDoc::Parser::RipperStateLex::EXPR_LABEL) == 0
17921792
nest += 1
17931793
end
17941794

0 commit comments

Comments
 (0)