@@ -11,8 +11,6 @@ class RDoc::Parser::RBS < RDoc::Parser
1111 parse_files_matching RBS_FILE_EXTENSION
1212
1313 def scan
14- @attributes_by_context = { }
15- @methods_by_context = { }
1614 _ , _ , decls = ::RBS ::Parser . parse_signature ( @content )
1715 decls . each do |decl |
1816 parse_decl decl , @top_level
@@ -92,28 +90,12 @@ def attr_rw_matches?(existing_rw, new_rw)
9290 existing_rw . each_char . any? { |rw | new_rw . include? rw }
9391 end
9492
95- def attribute_index ( context )
96- index = @attributes_by_context [ context ] ||= { }
97- context . attributes [ index . length ..] . each do |attribute |
98- index [ [ attribute . name , attribute . singleton ] ] ||= attribute
99- end
100- index
101- end
102-
103- def method_index ( context )
104- index = @methods_by_context [ context ] ||= { }
105- context . method_list [ index . length ..] . each do |method |
106- index [ [ method . name , !!method . singleton ] ] ||= method
107- end
108- index
109- end
110-
11193 def merge_attribute_methods ( context , name , rw , singleton , comment , type_signature_lines )
11294 method_names = [ ]
11395 method_names << name if rw . include? ( 'R' )
11496 method_names << "#{ name } =" if rw . include? ( 'W' )
11597
116- methods = method_names . map { |method_name | method_index ( context ) [ [ method_name , singleton ] ] }
98+ methods = method_names . map { |method_name | context . find_method_from_hash ( method_name , singleton ) }
11799 methods . compact . each do |method |
118100 merge_documentation method , comment , type_signature_lines
119101 end
@@ -153,7 +135,7 @@ def parse_attr_decl(decl, context)
153135 type_signature_lines = [ decl . type . to_s ]
154136 name = decl . name . to_s
155137 singleton = decl . kind == :singleton
156- if attribute = attribute_index ( context ) [ [ name , singleton ] ]
138+ if attribute = context . find_attribute_from_hash ( name , singleton )
157139 merge_documentation attribute , comment , type_signature_lines if
158140 attr_rw_matches? attribute . rw , rw
159141 return
@@ -263,7 +245,7 @@ def parse_method_decl(decl, context)
263245 singleton = rdoc_method_singleton? ( decl )
264246 visibility = rdoc_method_visibility ( decl )
265247
266- if method = method_index ( context ) [ [ method_name , singleton ] ]
248+ if method = context . find_method_from_hash ( method_name , singleton )
267249 merge_documentation method , comment , type_signature_lines
268250 return
269251 end
0 commit comments