3
3
4
4
module RubyLsp
5
5
module Rails
6
- class IndexingEnhancement
6
+ class IndexingEnhancement < RubyIndexer :: Enhancement
7
7
extend T ::Sig
8
- include RubyIndexer ::Enhancement
9
8
10
9
sig do
11
10
override . params (
12
- index : RubyIndexer ::Index ,
13
11
owner : T . nilable ( RubyIndexer ::Entry ::Namespace ) ,
14
12
node : Prism ::CallNode ,
15
13
file_path : String ,
@@ -19,24 +17,23 @@ class IndexingEnhancement
19
17
) ,
20
18
) . void
21
19
end
22
- def on_call_node ( index , owner , node , file_path , code_units_cache )
20
+ def on_call_node_enter ( owner , node , file_path , code_units_cache )
23
21
return unless owner
24
22
25
23
name = node . name
26
24
27
25
case name
28
26
when :extend
29
- handle_concern_extend ( index , owner , node )
27
+ handle_concern_extend ( owner , node )
30
28
when :has_one , :has_many , :belongs_to , :has_and_belongs_to_many
31
- handle_association ( index , owner , node , file_path , code_units_cache )
29
+ handle_association ( owner , node , file_path , code_units_cache )
32
30
end
33
31
end
34
32
35
33
private
36
34
37
35
sig do
38
36
params (
39
- index : RubyIndexer ::Index ,
40
37
owner : RubyIndexer ::Entry ::Namespace ,
41
38
node : Prism ::CallNode ,
42
39
file_path : String ,
@@ -46,7 +43,7 @@ def on_call_node(index, owner, node, file_path, code_units_cache)
46
43
) ,
47
44
) . void
48
45
end
49
- def handle_association ( index , owner , node , file_path , code_units_cache )
46
+ def handle_association ( owner , node , file_path , code_units_cache )
50
47
arguments = node . arguments &.arguments
51
48
return unless arguments
52
49
@@ -64,7 +61,7 @@ def handle_association(index, owner, node, file_path, code_units_cache)
64
61
loc = RubyIndexer ::Location . from_prism_location ( name_arg . location , code_units_cache )
65
62
66
63
# Reader
67
- index . add ( RubyIndexer ::Entry ::Method . new (
64
+ @ index. add ( RubyIndexer ::Entry ::Method . new (
68
65
name ,
69
66
file_path ,
70
67
loc ,
@@ -76,7 +73,7 @@ def handle_association(index, owner, node, file_path, code_units_cache)
76
73
) )
77
74
78
75
# Writer
79
- index . add ( RubyIndexer ::Entry ::Method . new (
76
+ @ index. add ( RubyIndexer ::Entry ::Method . new (
80
77
"#{ name } =" ,
81
78
file_path ,
82
79
loc ,
@@ -90,12 +87,11 @@ def handle_association(index, owner, node, file_path, code_units_cache)
90
87
91
88
sig do
92
89
params (
93
- index : RubyIndexer ::Index ,
94
90
owner : RubyIndexer ::Entry ::Namespace ,
95
91
node : Prism ::CallNode ,
96
92
) . void
97
93
end
98
- def handle_concern_extend ( index , owner , node )
94
+ def handle_concern_extend ( owner , node )
99
95
arguments = node . arguments &.arguments
100
96
return unless arguments
101
97
@@ -105,7 +101,7 @@ def handle_concern_extend(index, owner, node)
105
101
module_name = node . full_name
106
102
next unless module_name == "ActiveSupport::Concern"
107
103
108
- index . register_included_hook ( owner . name ) do |index , base |
104
+ @ index. register_included_hook ( owner . name ) do |index , base |
109
105
class_methods_name = "#{ owner . name } ::ClassMethods"
110
106
111
107
if index . indexed? ( class_methods_name )
0 commit comments