Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
149 commits
Select commit Hold shift + click to select a range
df1334b
Enable strict type checking in CI
apiology May 6, 2025
ffeaa1c
Merge branch 'master' into run_strict_typechecking_in_ci
apiology Jun 28, 2025
28be4f7
Merge remote-tracking branch 'origin/master' into run_strict_typechec…
apiology Jul 2, 2025
8b11075
Add 'solargraph method_pin' command for debugging
apiology Jul 13, 2025
6fab42e
Merge remote-tracking branch 'origin/master' into method_pin
apiology Jul 13, 2025
bf61295
RuboCop and Solargraph fixes
apiology Jul 14, 2025
8b8c88b
Merge remote-tracking branch 'origin/master' into method_pin
apiology Jul 14, 2025
fdd3810
Linting fix
apiology Aug 4, 2025
30cdfc8
Add spec
apiology Aug 4, 2025
a30d790
Fix spec
apiology Aug 4, 2025
20dbf8e
Merge branch 'master' into method_pin
apiology Aug 19, 2025
0fcff5d
Merge branch 'master' into run_strict_typechecking_in_ci
apiology Aug 24, 2025
e4afaad
Allow newer RBS gem versions, exclude incompatible ones (#995)
apiology Aug 19, 2025
a0a7878
Look for external requires before cataloging bench (#1021)
apiology Aug 19, 2025
0e86b88
Remove Library#folding_ranges (#904)
castwide Aug 19, 2025
c90f016
Complain in strong type-checking if an @sg-ignore line is not needed …
apiology Aug 19, 2025
8c7a5b8
Document a log level env variable (#894)
apiology Aug 21, 2025
fba485e
Fix hole in type checking evaluation (#1009)
apiology Aug 24, 2025
f61b1b6
Improve typechecking error message (#1014)
apiology Aug 24, 2025
9d4c711
Internal strict type-checking fixes (#1013)
apiology Aug 24, 2025
3bcbf85
Reproduce and fix a ||= (or-asgn) evaluation issue (#1017)
apiology Aug 24, 2025
25557b4
Define closure for Pin::Symbol, for completeness (#1027)
apiology Aug 24, 2025
32565d4
Fix 'all!' config to reporters (#1018)
apiology Aug 24, 2025
3946cc4
Fix DocMap.all_rbs_collection_gems_in_memory return type (#1037)
castwide Aug 24, 2025
43cacca
Fix RuboCop linting errors in regular expressions (#1038)
castwide Aug 24, 2025
d3bdfea
Resolve class aliases via Constant pins (#1029)
apiology Aug 24, 2025
4a10b44
Speed-up LSP completion response times (#1035)
lekemula Aug 24, 2025
7a633b1
Merge remote-tracking branch 'origin/master' into method_pin
apiology Aug 27, 2025
d1e6b12
RuboCop todo update
apiology Aug 27, 2025
5b612dd
Try rbs collection update before specs
apiology Aug 27, 2025
f2291f4
RuboCop fixes
apiology Aug 27, 2025
be46aa3
Add @sg-ignores
apiology Aug 27, 2025
0927309
Fix typo
apiology Aug 27, 2025
7899550
Exclude problematic combinations on Ruby head
apiology Aug 27, 2025
d5d6c5f
Fix indentation
apiology Aug 27, 2025
2c6cacd
method_pin -> pin, hide command
apiology Aug 27, 2025
56636ae
Fix type
apiology Aug 27, 2025
447c778
Make 'self' types concrete while checking arguments
apiology Aug 29, 2025
3638359
strict -> strong
apiology Aug 29, 2025
1da7ae5
Merge remote-tracking branch 'origin/master' into run_strict_typechec…
apiology Aug 29, 2025
b4a2ab1
Also change default in Rakefile
apiology Aug 29, 2025
6acfa0c
RuboCop todo file stability
apiology Aug 30, 2025
14be6bf
Merge remote-tracking branch 'origin/master' into rubocop_stability
apiology Aug 30, 2025
61260f3
Fix merge issue
apiology Aug 30, 2025
91ced05
Add spec
apiology Aug 31, 2025
2702f44
Work around strong typechecking issue
apiology Aug 31, 2025
f623a73
Pull in overcommit fix
apiology Sep 1, 2025
a8b678b
Add spec
apiology Sep 1, 2025
9f7fe59
Add --references flag (superclass for now)
apiology Sep 2, 2025
2f0ff82
Merge remote-tracking branch 'origin/master' into method_pin
apiology Sep 2, 2025
79e8cd9
Add another @sg-ignore
apiology Sep 2, 2025
da205a3
Catch up with .rubocop_todo.yml
apiology Sep 2, 2025
4c486ed
Add another @sg-ignore
apiology Sep 2, 2025
200e7e4
Tolerate case statement in specs
apiology Sep 2, 2025
b10cdd1
Drop broken 'namespaces' method
apiology Sep 4, 2025
ea3db32
Merge branch 'rubocop_stability' into drop_broken_namespaces_method
apiology Sep 4, 2025
452bd37
Merge remote-tracking branch 'origin/master' into drop_broken_namespa…
apiology Sep 6, 2025
8edc773
Merge remote-tracking branch 'origin/master' into rubocop_stability
apiology Sep 6, 2025
bb0f607
Rerun rubocop todo
apiology Sep 6, 2025
41f098b
Rebuild rubocop todo file
apiology Sep 6, 2025
5ea1270
Merge remote-tracking branch 'origin/master' into run_strict_typechec…
apiology Sep 7, 2025
0ede18a
Merge branch 'rubocop_stability' into method_pin
apiology Sep 7, 2025
8d88f5c
Merge remote-tracking branch 'origin/master' into overcommit_yardoc_b…
apiology Sep 7, 2025
40c78d4
Merge remote-tracking branch 'origin/master' into handle_more_typeche…
apiology Sep 7, 2025
837d7f6
Force build
apiology Sep 7, 2025
a4208e7
Restore
apiology Sep 7, 2025
f08b76a
Merge remote-tracking branch 'origin/master' into fix_solargraph_rspe…
apiology Sep 7, 2025
b66f2ac
install -> update with rbs collection
apiology Sep 7, 2025
a09a9af
Try Ruby 3.2
apiology Sep 7, 2025
6fc8feb
Update solargraph
apiology Sep 7, 2025
388c170
Re-add bundle install
apiology Sep 7, 2025
f80b73a
Drop MATRIX_SOLARGRAPH_VERSION
apiology Sep 7, 2025
ce2bee6
Drop debugging changes
apiology Sep 7, 2025
c261704
Merge remote-tracking branch 'origin/master' into rubocop_stability
apiology Sep 7, 2025
dbe9a3e
Update expectations from master branch
apiology Sep 7, 2025
620fa00
Merge branch 'fix_solargraph_rspec_check' into rubocop_stability
apiology Sep 7, 2025
b0ace93
Merge branch 'rubocop_stability' into method_pin
apiology Sep 7, 2025
9c9a760
Merge branch 'rubocop_stability' into overcommit_yardoc_bundle_fix
apiology Sep 8, 2025
e7651b8
Merge branch 'rubocop_stability' into drop_broken_namespaces_method
apiology Sep 8, 2025
1b12d27
Merge branch 'master' into rubocop_stability
apiology Sep 13, 2025
db725f7
Update rubocop todo
apiology Sep 13, 2025
267b685
Merge branch 'master' into method_pin
apiology Sep 13, 2025
0e00195
Merge branch 'rubocop_stability' into method_pin
apiology Sep 13, 2025
b6d86ec
Fix merge failure
apiology Sep 13, 2025
f4399eb
[regression] Fix issue resolving mixins under same namespace
apiology Sep 25, 2025
3324b4c
Prevent recursion via caching mechanism
apiology Sep 25, 2025
174bf4e
Linting fix, ignore rubocop-yard issue pending yard PR merge
apiology Sep 25, 2025
4898313
[regression] Fix resolution in deep YARD namespace hierarchies
apiology Sep 25, 2025
f8f7ca2
Linting
apiology Sep 26, 2025
1023646
Merge branch 'fix_mixin_under_same_ns' into fix_yard_pin_resolution_i…
apiology Sep 26, 2025
8ce4bb9
Fix merge
apiology Sep 26, 2025
a398b84
Resolve constants in references
apiology Sep 26, 2025
dd06a47
Linting
apiology Sep 26, 2025
cc86aec
Ratchet RuboCop
apiology Sep 26, 2025
343cd23
Fix lack of parameters in include types
apiology Sep 26, 2025
d787886
Bug fixes
apiology Sep 26, 2025
63a53db
Add actual type for Mutexes
apiology Sep 26, 2025
9d4ba44
Allow more valid method pin paths
apiology Sep 26, 2025
2712e66
RuboCop fix
apiology Sep 26, 2025
7bc2092
Linting
apiology Sep 26, 2025
7546f73
Enable solargraph-rspec tests
lekemula Sep 21, 2025
9c79e5b
Fix rspec gems specs
lekemula Sep 21, 2025
5d4bbc3
Closure merging fixes
apiology Sep 28, 2025
b5898e2
Drop incidental requirement
apiology Sep 28, 2025
12e4563
[regression] Fix resolution of a nested type case
apiology Sep 28, 2025
b8174dd
Fix example name
apiology Sep 28, 2025
884e821
Merge branch 'fix_yard_pin_resolution_issues' into fix_resolution_of_…
apiology Sep 28, 2025
d69cd60
Merge branch 'master' into method_pin
apiology Sep 30, 2025
6e8c74a
Merge remote-tracking branch 'origin/master' into handle_more_typeche…
apiology Sep 30, 2025
12da1e3
Merge remote-tracking branch 'origin/master' into fix_resolution_of_a…
apiology Sep 30, 2025
faa57aa
Add another unmerged-Yard-PR issue
apiology Sep 30, 2025
4315f73
Merge branch 'fix_resolution_of_another_ambiguous_type' into handle_m…
apiology Sep 30, 2025
b9f2900
Fix merge issue
apiology Sep 30, 2025
f99883b
Merge remote-tracking branch 'origin/master' into overcommit_yardoc_b…
apiology Sep 30, 2025
4918790
Merge branch 'master' into drop_broken_namespaces_method
apiology Sep 30, 2025
3df4406
Ratchet RuboCop
apiology Sep 30, 2025
c23f64f
Merge remote-tracking branch 'origin/master' into handle_more_typeche…
apiology Sep 30, 2025
f8a78bf
Merge remote-tracking branch 'origin/master' into run_strict_typechec…
apiology Sep 30, 2025
2e6aa3f
Drop unneeded @sg-ignores
apiology Sep 30, 2025
66abe83
Drop unneeded @sg-ignore
apiology Sep 30, 2025
c35d6a7
Drop another @sg-ignore
apiology Sep 30, 2025
053de42
Merge remote-tracking branch 'origin/master' into method_pin
apiology Sep 30, 2025
523ca94
Merge remote-tracking branch 'origin/master' into try_again_removing_…
apiology Sep 30, 2025
df0c1db
Merge remote-tracking branch 'lekemula/enable-solargraph-rspec-plugin…
apiology Oct 1, 2025
152dbdf
Annotation fixes for strong typechecking
apiology Oct 5, 2025
aa566bc
Merge branch 'handle_more_typechecking_self_situations' into run_stri…
apiology Oct 9, 2025
eb1de22
Merge branch 'overcommit_yardoc_bundle_fix' into run_strict_typecheck…
apiology Oct 9, 2025
7bdfa26
Merge branch 'drop_broken_namespaces_method' into run_strict_typechec…
apiology Oct 9, 2025
dfe6996
Merge branch 'try_again_removing_node_modules_stubs' into run_strict_…
apiology Oct 9, 2025
b2e4954
Merge branch 'annotations_2025' into run_strict_typechecking_in_ci
apiology Oct 9, 2025
2240ad7
Add @sg-ignores for issues covered by future PRs
apiology Oct 9, 2025
b0fb367
Add @sg-ignores for issues covered by future PRs
apiology Oct 9, 2025
ed23813
Reproduce solargraph-rspec rspec failure
apiology Nov 3, 2025
c6dbe4d
Trigger build
apiology Nov 15, 2025
9d26863
Fix new bundler issue
apiology Nov 15, 2025
87ec9b3
Debug
apiology Nov 15, 2025
6a14bd7
Turn off warning diagnostics in CLI
apiology Nov 15, 2025
5348f70
Merge branch 'method_pin' into solargraph_rspec_failure
apiology Nov 15, 2025
7e7604b
Debug
apiology Nov 15, 2025
91d3cd4
Fix pin merging bug
apiology Nov 15, 2025
652fcd2
Add @sg-ignore
apiology Nov 15, 2025
8359d06
Merge branch 'solargraph_rspec_failure' into run_strict_typechecking_…
apiology Nov 15, 2025
fe06cf3
Add @sg-ignore
apiology Nov 16, 2025
9b6aa30
Pull in solargraph-rspec fixes from another branch
apiology Nov 16, 2025
19eae82
Drop @sg-ignores
apiology Nov 16, 2025
482671b
Add @sg-ignore
apiology Nov 16, 2025
82c5680
Merge branch 'annotations_2025' into run_strict_typechecking_in_ci
apiology Nov 16, 2025
b1d0b21
Drop @sg-ignore
apiology Nov 16, 2025
973b512
Use consistent ruby versions for typechecking
apiology Nov 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 61 additions & 27 deletions .github/workflows/plugins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.0'
ruby-version: 3.4
bundler-cache: true
- uses: awalsh128/cache-apt-pkgs-action@latest
with:
Expand Down Expand Up @@ -54,7 +54,7 @@ jobs:
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.0'
ruby-version: 3.4
bundler-cache: false
- uses: awalsh128/cache-apt-pkgs-action@latest
with:
Expand Down Expand Up @@ -83,7 +83,7 @@ jobs:
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.0'
ruby-version: 3.4
bundler-cache: false
- uses: awalsh128/cache-apt-pkgs-action@latest
with:
Expand All @@ -105,30 +105,64 @@ jobs:
- name: Ensure specs still run
run: bundle exec rake spec

# run_solargraph_rspec_specs:
# # check out solargraph-rspec as well as this project, and point the former to use the latter as a local gem
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - name: clone https://github.com/lekemula/solargraph-rspec/
# run: |
# cd ..
# git clone https://github.com/lekemula/solargraph-rspec.git
# cd solargraph-rspec
# - name: Set up Ruby
# uses: ruby/setup-ruby@v1
# with:
# ruby-version: '3.0'
# bundler-cache: false
# - name: Install gems
# run: |
# cd ../solargraph-rspec
# echo "gem 'solargraph', path: '../solargraph'" >> Gemfile
# bundle install
# - name: Run specs
# run: |
# cd ../solargraph-rspec
# bundle exec rake spec
run_solargraph_rspec_specs:
# check out solargraph-rspec as well as this project, and point the former to use the latter as a local gem
runs-on: ubuntu-latest
env:
SOLARGRAPH_CACHE: ${{ github.workspace }}/../solargraph-rspec/vendor/solargraph/cache
BUNDLE_PATH: ${{ github.workspace }}/../solargraph-rspec/vendor/bundle
steps:
- uses: actions/checkout@v3
- name: clone https://github.com/lekemula/solargraph-rspec/
run: |
cd ..
# git clone https://github.com/lekemula/solargraph-rspec.git

# pending https://github.com/lekemula/solargraph-rspec/pull/30
git clone https://github.com/apiology/solargraph-rspec.git
cd solargraph-rspec
git checkout reset_closures
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.1'
rubygems: latest
bundler-cache: false
- name: Install gems
run: |
set -x

cd ../solargraph-rspec
echo "gem 'solargraph', path: '../solargraph'" >> Gemfile
bundle config path ${{ env.BUNDLE_PATH }}
bundle install --jobs 4 --retry 3
bundle exec appraisal install
# @todo some kind of appraisal/bundle conflict?
# https://github.com/castwide/solargraph/actions/runs/19038710934/job/54369767122?pr=1116
# /home/runner/work/solargraph/solargraph-rspec/vendor/bundle/ruby/3.1.0/gems/bundler-2.6.9/lib/bundler/runtime.rb:317:in
# `check_for_activated_spec!': You have already activated date
# 3.5.0, but your Gemfile requires date 3.4.1. Prepending
# `bundle exec` to your command may solve
# this. (Gem::LoadError)
bundle exec appraisal update date
# For some reason on ruby 3.1 it defaults to an old version: 1.3.2
# https://github.com/lekemula/solargraph-rspec/actions/runs/17814581205/job/50645370316?pr=22
# We update manually to the latest
bundle exec appraisal update rspec-rails
- name: Configure .solargraph.yml
run: |
cd ../solargraph-rspec
cp .solargraph.yml.example .solargraph.yml
- name: Solargraph generate RSpec gems YARD and RBS pins
run: |
cd ../solargraph-rspec
bundle exec appraisal rbs collection update
rspec_gems=$(bundle exec appraisal ruby -r './lib/solargraph-rspec' -e 'puts Solargraph::Rspec::Gems.gem_names.join(" ")' 2>/dev/null | tail -n1)
bundle exec appraisal solargraph gems $rspec_gems
- name: Run specs
run: |
cd ../solargraph-rspec
bundle exec appraisal rspec --format progress

run_solargraph_rails_specs:
# check out solargraph-rails as well as this project, and point the former to use the latter as a local gem
Expand Down
19 changes: 18 additions & 1 deletion .github/workflows/rspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,24 @@ jobs:
rbs-version: '3.9.4'
- ruby-version: '3.0'
rbs-version: '4.0.0.dev.4'
# Missing require in 'rbs collection update' - hopefully
# fixed in next RBS release
- ruby-version: 'head'
rbs-version: '4.0.0.dev.4'
- ruby-version: 'head'
rbs-version: '3.9.4'
- ruby-version: 'head'
rbs-version: '3.6.1'
steps:
- uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
# see https://github.com/castwide/solargraph/actions/runs/19391419903/job/55485410493?pr=1119
#
# match version in Gemfile.lock and use same version below
bundler: 2.5.23
bundler-cache: false
- name: Set rbs version
run: echo "gem 'rbs', '${{ matrix.rbs-version }}'" >> .Gemfile
Expand All @@ -46,8 +58,13 @@ jobs:
run: echo "gem 'tsort'" >> .Gemfile
- name: Install gems
run: |
bundle install
bundle _2.5.23_ install
bundle update rbs # use latest available for this Ruby version
bundle list
bundle exec solargraph pin 'Bundler::Dsl#source'
- name: Update types
run: |
bundle exec rbs collection update
- name: Run tests
run: bundle exec rake spec
undercover:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/typecheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ permissions:

jobs:
solargraph_typed:
name: Solargraph / typed
name: Solargraph / strong

runs-on: ubuntu-latest

Expand All @@ -36,4 +36,4 @@ jobs:
- name: Install gem types
run: bundle exec rbs collection install
- name: Typecheck self
run: SOLARGRAPH_ASSERTS=on bundle exec solargraph typecheck --level typed
run: SOLARGRAPH_ASSERTS=on bundle exec solargraph typecheck --level strong
13 changes: 0 additions & 13 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ Gemspec/OrderedDependencies:
# Configuration parameters: Severity.
Gemspec/RequireMFA:
Exclude:
- 'solargraph.gemspec'
- 'spec/fixtures/rdoc-lib/rdoc-lib.gemspec'
- 'spec/fixtures/rubocop-custom-version/specifications/rubocop-0.0.0.gemspec'

Expand Down Expand Up @@ -664,14 +663,6 @@ RSpec/LetBeforeExamples:
Exclude:
- 'spec/complex_type_spec.rb'

# Configuration parameters: EnforcedStyle.
# SupportedStyles: have_received, receive
RSpec/MessageSpies:
Exclude:
- 'spec/doc_map_spec.rb'
- 'spec/language_server/host/diagnoser_spec.rb'
- 'spec/language_server/host/message_worker_spec.rb'

RSpec/MissingExampleGroupArgument:
Exclude:
- 'spec/diagnostics/rubocop_helpers_spec.rb'
Expand Down Expand Up @@ -732,10 +723,6 @@ RSpec/ScatteredLet:
Exclude:
- 'spec/complex_type_spec.rb'

RSpec/StubbedMock:
Exclude:
- 'spec/language_server/host/message_worker_spec.rb'

# Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
RSpec/VerifiedDoubles:
Enabled: false
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ task :console do
end

desc "Run the type checker"
task typecheck: [:typecheck_typed]
task typecheck: [:typecheck_strong]

desc "Run the type checker at typed level - return code issues provable without annotations being correct"
task :typecheck_typed do
Expand Down
3 changes: 3 additions & 0 deletions bin/solargraph
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/usr/bin/env ruby

# turn off warning diagnostics from Ruby
$VERBOSE=nil

require 'solargraph'

Solargraph::Shell.start(ARGV)
28 changes: 6 additions & 22 deletions lib/solargraph/api_map.rb
Original file line number Diff line number Diff line change
Expand Up @@ -240,13 +240,6 @@ def keyword_pins
store.pins_by_class(Pin::Keyword)
end

# An array of namespace names defined in the ApiMap.
#
# @return [Set<String>]
def namespaces
store.namespaces
end

# True if the namespace exists.
#
# @param name [String] The namespace to match
Expand Down Expand Up @@ -537,7 +530,7 @@ def get_method_stack rooted_tag, name, scope: :instance, visibility: [:private,
# @deprecated Use #get_path_pins instead.
#
# @param path [String] The path to find
# @return [Enumerable<Solargraph::Pin::Base>]
# @return [Array<Solargraph::Pin::Base>]
def get_path_suggestions path
return [] if path.nil?
resolve_method_aliases store.get_path_pins(path)
Expand All @@ -546,7 +539,7 @@ def get_path_suggestions path
# Get an array of pins that match the specified path.
#
# @param path [String]
# @return [Enumerable<Pin::Base>]
# @return [Array<Pin::Base>]
def get_path_pins path
get_path_suggestions(path)
end
Expand Down Expand Up @@ -665,7 +658,7 @@ def super_and_sub?(sup, sub)
#
# @return [Boolean]
def type_include?(host_ns, module_ns)
store.get_includes(host_ns).map { |inc_tag| inc_tag.parametrized_tag.name }.include?(module_ns)
store.get_includes(host_ns).map { |inc_tag| inc_tag.type.name }.include?(module_ns)
end

# @param pins [Enumerable<Pin::Base>]
Expand Down Expand Up @@ -774,17 +767,8 @@ def inner_get_methods rooted_tag, scope, visibility, deep, skip, no_core = false

if scope == :instance
store.get_includes(fqns).reverse.each do |ref|
const = get_constants('', *ref.closure.gates).find { |pin| pin.path.end_with? ref.name }
if const.is_a?(Pin::Namespace)
result.concat inner_get_methods(const.path, scope, visibility, deep, skip, true)
elsif const.is_a?(Pin::Constant)
type = const.infer(self)
result.concat inner_get_methods(type.namespace, scope, visibility, deep, skip, true) if type.defined?
else
referenced_tag = ref.parametrized_tag
next unless referenced_tag.defined?
result.concat inner_get_methods_from_reference(referenced_tag.to_s, namespace_pin, rooted_type, scope, visibility, deep, skip, true)
end
in_tag = dereference(ref)
result.concat inner_get_methods_from_reference(in_tag, namespace_pin, rooted_type, scope, visibility, deep, skip, true)
end
rooted_sc_tag = qualify_superclass(rooted_tag)
unless rooted_sc_tag.nil?
Expand All @@ -793,7 +777,7 @@ def inner_get_methods rooted_tag, scope, visibility, deep, skip, no_core = false
else
logger.info { "ApiMap#inner_get_methods(#{fqns}, #{scope}, #{visibility}, #{deep}, #{skip}) - looking for get_extends() from #{fqns}" }
store.get_extends(fqns).reverse.each do |em|
fqem = store.constants.dereference(em)
fqem = dereference(em)
result.concat inner_get_methods(fqem, :instance, visibility, deep, skip, true) unless fqem.nil?
end
rooted_sc_tag = qualify_superclass(rooted_tag)
Expand Down
57 changes: 38 additions & 19 deletions lib/solargraph/api_map/constants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,23 @@ def initialize store

# Resolve a name to a fully qualified namespace or constant.
#
# `Constants#resolve` is similar to `Constants#qualify`` in that its
# purpose is to find fully qualified (absolute) namespaces, except
# `#resolve`` is only concerned with real namespaces. It disregards
# parametrized types and special types like literals, self, and Boolean.
# `Constants#resolve` finds fully qualified (absolute)
# namespaces based on relative names and the open gates
# (namespaces) provided. Names must be runtime-visible (erased)
# non-literal types, non-duck, non-signature types - e.g.,
# TrueClass, NilClass, Integer and Hash instead of true, nil,
# 96, or Hash{String => Symbol}
#
# @param name [String]
# @param gates [Array<Array<String>, String>]
# @return [String, nil]
# Note: You may want to be using #qualify. Notably, #resolve:
# - does not handle anything with type parameters
# - will not gracefully handle nil, self and Boolean
# - will return a constant name instead of following its assignment
#
# @param name [String] Namespace which may relative and not be rooted.
# @param gates [Array<Array<String>, String>] Namespaces to search while resolving the name
#
# @return [String, nil] fully qualified namespace (i.e., is
# absolute, but will not start with ::)
def resolve(name, *gates)
return store.get_path_pins(name[2..]).first&.path if name.start_with?('::')

Expand All @@ -39,7 +48,7 @@ def resolve(name, *gates)
# @param pin [Pin::Reference]
# @return [String, nil]
def dereference pin
resolve(pin.name, pin.reference_gates)
qualify_type(pin.type, *pin.reference_gates)&.tag
end

# Collect a list of all constants defined in the specified gates.
Expand All @@ -51,27 +60,37 @@ def collect(*gates)
cached_collect[flat] || collect_and_cache(flat)
end

# Determine a fully qualified namespace for a given name referenced
# from the specified open gates. This method will search in each gate
# until it finds a match for the name.
# Determine a fully qualified namespace for a given tag
# referenced from the specified open gates. This method will
# search in each gate until it finds a match for the name.
#
# @param name [String, nil] The namespace to match
# @param tag [String, nil] The type to match
# @param gates [Array<String>]
# @return [String, nil] fully qualified tag
def qualify name, *gates
return name if ['Boolean', 'self', nil].include?(name)
def qualify tag, *gates
type = ComplexType.try_parse(tag)
qualify_type(type, *gates)&.tag
end

# @param type [ComplexType, nil] The type to match
# @param gates [Array<String>]
#
# @return [ComplexType, nil] A new rooted ComplexType
def qualify_type type, *gates
return nil if type.nil?
return type if type.selfy? || type.literal? || type.tag == 'nil' || type.interface? ||
type.tag == 'Boolean'

gates.push '' unless gates.include?('')
fqns = resolve(name, gates)
fqns = resolve(type.rooted_namespace, *gates)
return unless fqns
pin = store.get_path_pins(fqns).first
if pin.is_a?(Pin::Constant)
const = Solargraph::Parser::NodeMethods.unpack_name(pin.assignment)
return unless const
resolve(const, pin.gates)
else
fqns
fqns = resolve(const, *pin.gates)
end
type.recreate(new_name: fqns, make_rooted: true)
end

# @return [void]
Expand Down Expand Up @@ -126,7 +145,7 @@ def complex_resolve name, gates, internal
resolved = simple_resolve(name, gate, internal)
return [resolved, gates[(idx + 1)..]] if resolved
store.get_ancestor_references(gate).each do |ref|
return ref.name.sub(/^::/, '') if ref.name.end_with?("::#{name}")
return ref.name.sub(/^::/, '') if ref.name.end_with?("::#{name}") && ref.name.start_with?('::')

mixin = resolve(ref.name, ref.reference_gates)
next unless mixin
Expand Down
Loading
Loading