Skip to content
Merged
Show file tree
Hide file tree
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
9 changes: 6 additions & 3 deletions lib/ruby_lsp/requests/code_lens.rb
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,13 @@ def add_test_code_lens(node, name:, command:, kind:)

sig { params(node: SyntaxTree::Command).returns(T.nilable(String)) }
def resolve_gem_remote(node)
gem_statement = node.arguments.parts.flat_map(&:child_nodes).first
return unless gem_statement
gem_statement = node.arguments.parts.first
return unless gem_statement.is_a?(SyntaxTree::StringLiteral)

spec = Gem::Specification.stubs.find { |gem| gem.name == gem_statement.value }&.to_spec
gem_name = gem_statement.parts.first
return unless gem_name.is_a?(SyntaxTree::TStringContent)

spec = Gem::Specification.stubs.find { |gem| gem.name == gem_name.value }&.to_spec
return if spec.nil?

[spec.homepage, spec.metadata["source_code_uri"]].compact.find do |page|
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/Gemfile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@

# Make sure we don't break as the user is typing
gem ""

gem something_that_isnt_a_string