Skip to content

Commit

Permalink
node.slice replaced with node.full_name
Browse files Browse the repository at this point in the history
  • Loading branch information
haiderashfaq committed Feb 7, 2024
1 parent a1673df commit 143c0ce
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/ruby_lsp/listeners/completion.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def on_string_node_enter(node)
def on_constant_read_node_enter(node)
return if DependencyDetector.instance.typechecker

name = node.slice
name = constant_name(node)
candidates = @index.prefix_search(name, @nesting)
candidates.each do |entries|
complete_name = T.must(entries.first).name
Expand All @@ -62,7 +62,7 @@ def on_constant_read_node_enter(node)
def on_constant_path_node_enter(node)
return if DependencyDetector.instance.typechecker

name = node.slice
name = constant_name(node)

top_level_reference = if name.start_with?("::")
name = name.delete_prefix("::")
Expand Down
4 changes: 2 additions & 2 deletions lib/ruby_lsp/listeners/definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ def on_call_node_enter(node)

sig { params(node: Prism::ConstantPathNode).void }
def on_constant_path_node_enter(node)
find_in_index(node.slice)
find_in_index(constant_name(node))
end

sig { params(node: Prism::ConstantReadNode).void }
def on_constant_read_node_enter(node)
find_in_index(node.slice)
find_in_index(constant_name(node))
end

private
Expand Down
4 changes: 2 additions & 2 deletions lib/ruby_lsp/listeners/hover.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def initialize(response_builder, uri, nesting, index, dispatcher, typechecker_en
def on_constant_read_node_enter(node)
return if @typechecker_enabled

generate_hover(node.slice, node.location)
generate_hover(constant_name(node), node.location)
end

sig { params(node: Prism::ConstantWriteNode).void }
Expand All @@ -69,7 +69,7 @@ def on_constant_write_node_enter(node)
def on_constant_path_node_enter(node)
return if DependencyDetector.instance.typechecker

generate_hover(node.slice, node.location)
generate_hover(constant_name(node), node.location)
end

sig { params(node: Prism::CallNode).void }
Expand Down
7 changes: 7 additions & 0 deletions lib/ruby_lsp/requests/support/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@ def markdown_from_index_entries(title, entries)
#{content}
MARKDOWN
end

sig { params(node: Prism::Node).returns(T.nilable(String)) }
def constant_name(node)
node.full_name
rescue Prism::ConstantPathNode::DynamicPartsInConstantPathError
nil
end
end
end
end
Expand Down

0 comments on commit 143c0ce

Please sign in to comment.