Skip to content

Commit

Permalink
Merge branch 'castwide:master' into load-paths
Browse files Browse the repository at this point in the history
  • Loading branch information
mkon authored Jul 26, 2023
2 parents a804caa + 0b65280 commit 99f809b
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 3 deletions.
4 changes: 3 additions & 1 deletion SPONSORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ The following people and organizations provide funding or other resources. [Beco
## Linked Sponsors

- **[Calyptix Security](https://www.calyptix.com/)**
- **[Lightward](https://lightward.com)**

## Named Sponsors

- Akira Yamada
- Jesus Castello
- Joel Drapper
- Yutaka Tachibana
- Spencer
2 changes: 1 addition & 1 deletion lib/solargraph/source/chain/call.rb
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def arguments_match arguments, signature
# @param name_pin [Pin::Base]
# @return [Array<Pin::Base>]
def super_pins api_map, name_pin
pins = api_map.get_method_stack(name_pin.namespace, name_pin.name, scope: name_pin.scope)
pins = api_map.get_method_stack(name_pin.namespace, name_pin.name, scope: name_pin.context.scope)
pins.reject{|p| p.path == name_pin.path}
end

Expand Down
2 changes: 1 addition & 1 deletion lib/solargraph/source_map/mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def remove_inline_comment_hashes comment
started = false
comment.lines.each { |l|
# Trim the comment and minimum leading whitespace
p = l.encode('UTF-8', invalid: :replace, replace: '?').gsub(/^#/, '')
p = l.encode('UTF-8', invalid: :replace, replace: '?').gsub(/^#+/, '')
if num.nil? && !p.strip.empty?
num = p.index(/[^ ]/)
started = true
Expand Down
20 changes: 20 additions & 0 deletions spec/source/chain/call_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,26 @@
expect(type.tag).to eq('Array')
end

it "handles super calls to same method" do
api_map = Solargraph::ApiMap.new
source = Solargraph::Source.load_string(%(
class Foo
def my_method
123
end
end
class Bar < Foo
def my_method
456 + super
end
end
Bar.new.my_method))
api_map.map source
chain = Solargraph::Source::SourceChainer.chain(source, Solargraph::Position.new(11, 14))
type = chain.infer(api_map, Solargraph::Pin::ROOT_PIN, api_map.source_map(nil).locals)
expect(type.tag).to eq('Integer')
end

it "adds virtual constructors for <Class>.new calls with conflicting return types" do
api_map = Solargraph::ApiMap.new
source = Solargraph::Source.load_string(%(
Expand Down
16 changes: 16 additions & 0 deletions spec/source_map/mapper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1589,4 +1589,20 @@ def barbaz; end
Solargraph::SourceMap.load('spec/fixtures/invalid_node_comment.rb')
}.not_to raise_error
end

it 'parses method directives that start with multiple hashes' do
source = %(
module Bar
##
# @!method foobar()
# @return [String]
define_method :foobar do
"foobar"
end
end
)
map = Solargraph::SourceMap.load_string(source)
pin = map.first_pin('Bar#foobar')
expect(pin.path).to eq('Bar#foobar')
end
end

0 comments on commit 99f809b

Please sign in to comment.