ruby-lsp-ree 0.1.1 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,83 +0,0 @@
1
- require_relative "ree_lsp_utils"
2
- require_relative "parsing/parsed_link_node"
3
-
4
- module RubyLsp
5
- module Ree
6
- class Definition
7
- include Requests::Support::Common
8
- include RubyLsp::Ree::ReeLspUtils
9
-
10
- def initialize(response_builder, node_context, index, dispatcher, uri)
11
- @response_builder = response_builder
12
- @node_context = node_context
13
- @nesting = node_context.nesting
14
- @index = index
15
- @uri = uri
16
-
17
- dispatcher.register(self, :on_call_node_enter, :on_symbol_node_enter, :on_string_node_enter)
18
- end
19
-
20
- def on_call_node_enter(node)
21
- message = node.message
22
- $stderr.puts("definition on_call_node_enter #{message}")
23
-
24
- return unless message
25
-
26
- method = @index[message].detect{ !_1.location.nil? }
27
-
28
- return unless method
29
-
30
- @response_builder << Interface::Location.new(
31
- uri: method.uri.to_s,
32
- range: Interface::Range.new(
33
- start: Interface::Position.new(line: 0, character: 0),
34
- end: Interface::Position.new(line: 0, character: 0),
35
- ),
36
- )
37
-
38
- nil
39
- end
40
-
41
- def on_symbol_node_enter(node)
42
- parent_node = @node_context.parent
43
- return unless parent_node.name == :link
44
-
45
- link_node = RubyLsp::Ree::ParsedLinkNode.new(parent_node, package_name_from_uri(@uri))
46
- package_name = link_node.link_package_name
47
-
48
- method_candidates = @index[node.unescaped]
49
- return if !method_candidates || method_candidates.size == 0
50
-
51
- method = method_candidates.detect{ package_name_from_uri(_1.uri) == package_name }
52
- return unless method
53
-
54
- @response_builder << Interface::Location.new(
55
- uri: method.uri.to_s,
56
- range: Interface::Range.new(
57
- start: Interface::Position.new(line: 0, character: 0),
58
- end: Interface::Position.new(line: 0, character: 0),
59
- ),
60
- )
61
-
62
- nil
63
- end
64
-
65
- def on_string_node_enter(node)
66
- file_name = node.unescaped + ".rb"
67
- local_path = Dir[File.join('**', file_name)].first
68
-
69
- if local_path
70
- @response_builder << Interface::Location.new(
71
- uri: File.join(Dir.pwd, local_path),
72
- range: Interface::Range.new(
73
- start: Interface::Position.new(line: 0, character: 0),
74
- end: Interface::Position.new(line: 0, character: 0),
75
- ),
76
- )
77
- end
78
-
79
- nil
80
- end
81
- end
82
- end
83
- end