File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -140,13 +140,14 @@ def process_macros
140140 Solargraph . logger . debug { "ApiMap#process_macros: named macros: #{ store . named_macros . keys . join ( ', ' ) } " }
141141 source_maps . each do |source_map |
142142 method_candidates = source_map . macro_method_candidates ( store . macro_method_names )
143+ Solargraph . logger . warn "Candidates: #{ method_candidates } "
143144 Solargraph . logger . debug { "ApiMap#process_macros: processing source map for #{ source_map . filename } with #{ method_candidates . size } macro method candidates" }
144145 method_candidates . each do |node |
145146 closure = source_map . locate_closure_pin ( node . location . line , node . location . column )
146147 chain = Solargraph ::Parser ::ParserGem ::NodeChainer . chain ( node )
147148 if node . children [ 0 ] . nil? && store . macro_method_name_pins . key? ( node . children [ 1 ] . to_s )
148149 match = store . macro_method_name_pins [ node . children [ 1 ] . to_s ] . find do |pin |
149- super_and_sub? ( pin . namespace , closure . name )
150+ get_complex_type_methods ( closure . return_type ) . include? ( pin )
150151 end
151152 if match
152153 match . macros . each do |macro |
Original file line number Diff line number Diff line change @@ -201,4 +201,27 @@ def foo(klass)
201201 expect ( pin . typify ( api_map ) . to_s ) . to eq ( 'Array<klass>' )
202202 end
203203 end
204+
205+ describe '#process_macros' do
206+ it 'processes macro directives from extended modules' do
207+ source = Solargraph ::Source . load_string ( %(
208+ module Extension
209+ # @!macro
210+ # @!method $1
211+ # @return [$2]
212+ def make_method(name, klass)
213+ end
214+ end
215+
216+ class Example
217+ extend Extension
218+
219+ make_method :macro_method, String
220+ end
221+ ) )
222+ api_map = Solargraph ::ApiMap . new . map ( source )
223+ pin = api_map . get_path_pins ( 'Example#macro_method' ) . first
224+ expect ( pin . return_type . to_s ) . to eq ( 'String' )
225+ end
226+ end
204227end
You can’t perform that action at this time.
0 commit comments