Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversion between dashes in gemspec name and slashes in required paths #697

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
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
18 changes: 13 additions & 5 deletions lib/solargraph/yard_map.rb
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,11 @@ def pins_for_require r, already_errored
result = []
begin
name = r.split('/').first.to_s
return [] if name.empty? || @source_gems.include?(name) || @gem_paths.key?(name)
spec = spec_for_require(name)
@gem_paths[name] = spec.full_gem_path
return [] if name.empty?

spec = spec_for_require(r)
return [] if @source_gems.include?(spec.name) || @gem_paths.key?(spec.name)
@gem_paths[spec.name] = spec.full_gem_path

yd = yardoc_file_for_spec(spec)
# YARD detects gems for certain libraries that do not have a yardoc
Expand Down Expand Up @@ -282,8 +284,14 @@ def yardoc_file_for_spec spec
# @param path [String]
# @return [Gem::Specification]
def spec_for_require path
name = path.split('/').first.to_s
spec = Gem::Specification.find_by_name(name, @gemset[name])
relatives = path.split('/')
spec = nil
while spec.nil? && !relatives.empty?
name = relatives.join('-')
spec = Gem::Specification.find_by_name(name, @gemset[name])
relatives.pop
end
raise Gem::LoadError if spec.nil?

# Avoid loading the spec again if it's going to be skipped anyway
return spec if @source_gems.include?(spec.name)
Expand Down