Skip to content

Refactor parse_constant #522

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

Merged
merged 1 commit into from
Sep 25, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions lib/rdoc/parser/ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -872,21 +872,17 @@ def parse_constant container, tk, comment, ignore_constants = false

return unless name =~ /^\w+$/

eq_tk = get_tk

if :on_op == eq_tk[:kind] && '::' == eq_tk[:text] then
unget_tk eq_tk
if :on_op == peek_tk[:kind] && '::' == peek_tk[:text] then
unget_tk tk

container, name_t, = get_class_or_module container, ignore_constants

name = name_t[:text]

eq_tk = get_tk
end

is_array_or_hash = false
if eq_tk && :on_lbracket == eq_tk[:kind]
if peek_tk && :on_lbracket == peek_tk[:kind]
get_tk
nest = 1
while bracket_tk = get_tk
case bracket_tk[:kind]
Expand All @@ -898,14 +894,13 @@ def parse_constant container, tk, comment, ignore_constants = false
end
end
skip_tkspace false
eq_tk = get_tk
is_array_or_hash = true
end

unless eq_tk && :on_op == eq_tk[:kind] && '=' == eq_tk[:text] then
unget_tk eq_tk
unless peek_tk && :on_op == peek_tk[:kind] && '=' == peek_tk[:text] then
return false
end
get_tk

value = ''
con = RDoc::Constant.new name, value, comment
Expand Down