Skip to content

Commit

Permalink
Resolve self in yieldself tags
Browse files Browse the repository at this point in the history
  • Loading branch information
castwide committed Feb 14, 2024
1 parent 0612d50 commit 64d3a97
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/solargraph/pin/block.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions spec/source_map/clip_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 64d3a97

Please sign in to comment.