solargraph icon indicating copy to clipboard operation
solargraph copied to clipboard

Resolve constants in references

Open apiology opened this issue 3 months ago • 2 comments

Also replaces 'include' logic with call to ApiMap::Constants

Fixes #1099

Includes:

  • https://github.com/castwide/solargraph/pull/1087 (saw it break under this PR in my dev branch)

apiology avatar Sep 26 '25 16:09 apiology

Interested to see if this creates the same perf problem as before...

apiology avatar Sep 26 '25 16:09 apiology

The change in types in the solargraph-rails specs looks like an improvement to me - I'll make the change there, no need to wait on it. Specifically:

Hash#sum seems to do this sort of thing:

irb(main):006> {1=>"foo"}.sum([5])
[5, 1, "foo"]
irb(main):007> 

Before: (master branch with solargraph pin brought in)

broz@Mac:~/src/solargraph$ bundle exec solargraph pin --stack 'Hash{Integer => String}#sum'
#<Solargraph::Pin::Method `Enumerable#sum 
def sum: () -> (Elem | ::Integer)
       | sum: [T] () { [T] (arg0 Elem) -> T } -> (::Integer | T)
       | sum: [T] (?arg0 T) -> (Elem | T)
       | sum: [U] (?arg0 U) { [U] (arg0 Elem) -> U } -> U
` at #<Solargraph::Location /Users/broz/.rbenv/versions/3.1.6/lib/ruby/gems/3.1.0/gems/rbs-4.0.0.dev.4/core/enumerable.rbs, #<Solargraph::Range #<Solargraph::Position 1814, 2> to #<Solargraph::Position 1817, 50>>>) via :rbs>
broz@Mac:~/src/solargraph$ 

After this it's actually retaining types:

broz@Mac:~/src/solargraph$ bundle exec solargraph pin --stack 'Hash{Integer => String}#sum'
#<Solargraph::Pin::Method `Enumerable#sum 
def sum: () -> ([::Integer, ::String] | ::Integer)
       | sum: [T] () { [T] (arg0 [::Integer, ::String]) -> T } -> (::Integer | T)
       | sum: [T] (?arg0 T) -> ([::Integer, ::String] | T)
       | sum: [U] (?arg0 U) { [U] (arg0 [::Integer, ::String]) -> U } -> U
` at #<Solargraph::Location /Users/broz/.rbenv/versions/3.1.6/lib/ruby/gems/3.1.0/gems/rbs-4.0.0.dev.4/core/enumerable.rbs, #<Solargraph::Range #<Solargraph::Position 1814, 2> to #<Solargraph::Position 1817, 50>>>) via :rbs>
broz@Mac:~/src/solargraph$ 

apiology avatar Sep 26 '25 20:09 apiology