diff --git a/CHANGELOG.md b/CHANGELOG.md index 43c816bd9..359779c52 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 0.50.1 +- Resolve self in yieldself tags + ## 0.50.0 - December 5, 2023 - Remove .travis.yml as its not longer used (#627) - Fix empty string case when processing requires (#644) diff --git a/lib/solargraph/pin/block.rb b/lib/solargraph/pin/block.rb index 887323326..0e5d2e066 100644 --- a/lib/solargraph/pin/block.rb +++ b/lib/solargraph/pin/block.rb @@ -63,7 +63,7 @@ def binder_or_nil api_map if receiver_pin && receiver_pin.docstring ys = receiver_pin.docstring.tag(:yieldself) if ys && ys.types && !ys.types.empty? - return ComplexType.try_parse(*ys.types).qualify(api_map, receiver_pin.context.namespace) + return ComplexType.try_parse(*ys.types).qualify(api_map, receiver_pin.context.namespace).self_to(receiver_pin.full_context.namespace) end end nil diff --git a/spec/source_map/clip_spec.rb b/spec/source_map/clip_spec.rb index dbc20c803..da063d9da 100644 --- a/spec/source_map/clip_spec.rb +++ b/spec/source_map/clip_spec.rb @@ -496,6 +496,28 @@ def bar; end expect(clip.complete.pins.map(&:path)).to include('Par#hidden') end + it 'infers self in @yieldself' do + source = Solargraph::Source.load_string(%( + class Par + def action; end + private + def hidden; end + end + class Foo < Par + # @yieldself [self] + def bar; end + end + Foo.new.bar do + x + end + ), 'file.rb') + api_map = Solargraph::ApiMap.new + api_map.map source + clip = api_map.clip_at('file.rb', [11, 8]) + expect(clip.complete.pins.map(&:path)).to include('Par#action') + expect(clip.complete.pins.map(&:path)).to include('Par#hidden') + end + it "processes @yieldpublic tags in completions" do source = Solargraph::Source.load_string(%( class Par