@@ -13,9 +13,13 @@ class IndexingEnhancement
13
13
owner : T . nilable ( RubyIndexer ::Entry ::Namespace ) ,
14
14
node : Prism ::CallNode ,
15
15
file_path : String ,
16
+ code_units_cache : T . any (
17
+ T . proc . params ( arg0 : Integer ) . returns ( Integer ) ,
18
+ Prism ::CodeUnitsCache ,
19
+ ) ,
16
20
) . void
17
21
end
18
- def on_call_node ( index , owner , node , file_path )
22
+ def on_call_node ( index , owner , node , file_path , code_units_cache )
19
23
return unless owner
20
24
21
25
name = node . name
@@ -24,7 +28,7 @@ def on_call_node(index, owner, node, file_path)
24
28
when :extend
25
29
handle_concern_extend ( index , owner , node )
26
30
when :has_one , :has_many , :belongs_to , :has_and_belongs_to_many
27
- handle_association ( index , owner , node , file_path )
31
+ handle_association ( index , owner , node , file_path , code_units_cache )
28
32
end
29
33
end
30
34
@@ -36,9 +40,13 @@ def on_call_node(index, owner, node, file_path)
36
40
owner : RubyIndexer ::Entry ::Namespace ,
37
41
node : Prism ::CallNode ,
38
42
file_path : String ,
43
+ code_units_cache : T . any (
44
+ T . proc . params ( arg0 : Integer ) . returns ( Integer ) ,
45
+ Prism ::CodeUnitsCache ,
46
+ ) ,
39
47
) . void
40
48
end
41
- def handle_association ( index , owner , node , file_path )
49
+ def handle_association ( index , owner , node , file_path , code_units_cache )
42
50
arguments = node . arguments &.arguments
43
51
return unless arguments
44
52
@@ -53,14 +61,15 @@ def handle_association(index, owner, node, file_path)
53
61
54
62
return unless name
55
63
64
+ loc = RubyIndexer ::Location . from_prism_location ( name_arg . location , code_units_cache )
65
+
56
66
# Reader
57
67
index . add ( RubyIndexer ::Entry ::Method . new (
58
68
name ,
59
69
file_path ,
60
- name_arg . location ,
61
- name_arg . location ,
70
+ loc ,
71
+ loc ,
62
72
nil ,
63
- index . configuration . encoding ,
64
73
[ RubyIndexer ::Entry ::Signature . new ( [ ] ) ] ,
65
74
RubyIndexer ::Entry ::Visibility ::PUBLIC ,
66
75
owner ,
@@ -70,10 +79,9 @@ def handle_association(index, owner, node, file_path)
70
79
index . add ( RubyIndexer ::Entry ::Method . new (
71
80
"#{ name } =" ,
72
81
file_path ,
73
- name_arg . location ,
74
- name_arg . location ,
82
+ loc ,
83
+ loc ,
75
84
nil ,
76
- index . configuration . encoding ,
77
85
[ RubyIndexer ::Entry ::Signature . new ( [ RubyIndexer ::Entry ::RequiredParameter . new ( name : name . to_sym ) ] ) ] ,
78
86
RubyIndexer ::Entry ::Visibility ::PUBLIC ,
79
87
owner ,
0 commit comments