Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
andyw8 committed May 23, 2024
1 parent d8f7b89 commit 93121c7
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
7 changes: 7 additions & 0 deletions lib/ruby_lsp/custom_dispatcher.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# typed: strict
# frozen_string_literal: true

module RubyLsp
class CustomDispatcher < Prism::Dispatcher
end
end
3 changes: 2 additions & 1 deletion lib/ruby_lsp/listeners/definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ def initialize(response_builder, global_state, uri, nesting, dispatcher, typeche

sig { params(node: Prism::SymbolNode).void }
def on_symbol_node_enter(node)
binding.break
# binding.break
# methods = @index.resolve_method(message, @nesting.join("::"))
end

sig { params(node: Prism::CallNode).void }
Expand Down
8 changes: 5 additions & 3 deletions lib/ruby_lsp/requests/definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module Requests
# - Constants
# - Require paths
# - Methods invoked on self only
# - Symbol literals (for addons to provide custom behavior, e.g. Rails DSLs)
#
# # Example
#
Expand Down Expand Up @@ -49,15 +50,16 @@ def initialize(document, global_state, position, dispatcher, typechecker_enabled
target, parent, nesting = document.locate_node(
position,
node_types: [
Prism::SymbolNode,
Prism::CallNode,
Prism::ConstantReadNode,
Prism::ConstantPathNode,
Prism::BlockArgumentNode,
Prism::SymbolNode,
],
)

if target.is_a?(Prism::ConstantReadNode) && parent.is_a?(Prism::ConstantPathNode)
if target.is_a?(Prism::SymbolNode) && parent.is_a?(Prism::CallNode)
binding.break
elsif target.is_a?(Prism::ConstantReadNode) && parent.is_a?(Prism::ConstantPathNode)
# If the target is part of a constant path node, we need to find the exact portion of the constant that the
# user is requesting to go to definition for
target = determine_target(
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/prism
1 change: 1 addition & 0 deletions test/requests/definition_expectations_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ def foo; end
method: "textDocument/definition",
params: { textDocument: { uri: uri }, position: { character: 10, line: 4 } },
)
binding.break
assert_equal(uri.to_s, server.pop_response.response.first.attributes[:uri])
end
end
Expand Down

0 comments on commit 93121c7

Please sign in to comment.