From 168d7bd99d03241acfcecad84a6b02970eb9ea03 Mon Sep 17 00:00:00 2001 From: Kosuke Suzuki Date: Sat, 25 Nov 2023 18:12:31 +0900 Subject: [PATCH] gemspec dashes and required path slashes --- lib/solargraph/yard_map.rb | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/solargraph/yard_map.rb b/lib/solargraph/yard_map.rb index 89208a2bb..8ac8d12e3 100755 --- a/lib/solargraph/yard_map.rb +++ b/lib/solargraph/yard_map.rb @@ -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 @@ -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)