ruby-lsp 0.19.1 → 0.20.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/core_ext/uri.rb +2 -2
- data/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb +85 -36
- data/lib/ruby_indexer/lib/ruby_indexer/enhancement.rb +5 -1
- data/lib/ruby_indexer/lib/ruby_indexer/entry.rb +39 -98
- data/lib/ruby_indexer/lib/ruby_indexer/index.rb +2 -3
- data/lib/ruby_indexer/lib/ruby_indexer/location.rb +22 -0
- data/lib/ruby_indexer/lib/ruby_indexer/rbs_indexer.rb +2 -7
- data/lib/ruby_indexer/test/enhancements_test.rb +5 -7
- data/lib/ruby_indexer/test/global_variable_test.rb +49 -0
- data/lib/ruby_lsp/erb_document.rb +15 -2
- data/lib/ruby_lsp/listeners/definition.rb +20 -0
- data/lib/ruby_lsp/listeners/folding_ranges.rb +3 -3
- data/lib/ruby_lsp/requests/code_action_resolve.rb +8 -2
- data/lib/ruby_lsp/requests/completion.rb +1 -1
- data/lib/ruby_lsp/requests/definition.rb +2 -1
- data/lib/ruby_lsp/requests/document_highlight.rb +5 -1
- data/lib/ruby_lsp/requests/hover.rb +1 -1
- data/lib/ruby_lsp/requests/range_formatting.rb +4 -2
- data/lib/ruby_lsp/requests/references.rb +1 -1
- data/lib/ruby_lsp/requests/rename.rb +1 -1
- data/lib/ruby_lsp/requests/semantic_highlighting.rb +1 -1
- data/lib/ruby_lsp/requests/signature_help.rb +1 -1
- data/lib/ruby_lsp/requests/support/common.rb +1 -1
- data/lib/ruby_lsp/requests/support/rubocop_runner.rb +6 -6
- data/lib/ruby_lsp/response_builders/document_symbol.rb +2 -2
- data/lib/ruby_lsp/response_builders/hover.rb +2 -2
- data/lib/ruby_lsp/response_builders/semantic_highlighting.rb +14 -8
- data/lib/ruby_lsp/response_builders/signature_help.rb +2 -2
- data/lib/ruby_lsp/ruby_document.rb +33 -12
- data/lib/ruby_lsp/type_inferrer.rb +1 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d43d431cf15d817d80ebb8564f90a748b871ad3c2c278482d4b1b5c831b7bcd2
|
4
|
+
data.tar.gz: 28ab582396723d582f7909ad277300430b6e14e6a281408be21a71f4d768930f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73a87212da50592a6b201a5f21ea559de74fb12ed795428e06392a4375aa73015a103aedd56734b9b05a2f0a27fcb7366b16107ea9f1a080b3459e2eff1dcd88
|
7
|
+
data.tar.gz: 7ad77f3dccbabba9cb306c73ccefca4e84e9ff480bc0594d20a1c6e03727948119f7accefc522e5ed25d6de1d21fff03b18c704c7c8908b33eb92cfc5b2c665d
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.20.0
|
data/lib/core_ext/uri.rb
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
|
4
4
|
module URI
|
5
5
|
class Generic
|
6
|
+
extend T::Sig
|
7
|
+
|
6
8
|
# Avoid a deprecation warning with Ruby 3.4 where the default parser was changed to RFC3986.
|
7
9
|
# This condition must remain even after support for 3.4 has been dropped for users that have
|
8
10
|
# `uri` in their lockfile, decoupling it from the ruby version.
|
@@ -27,8 +29,6 @@ module URI
|
|
27
29
|
end
|
28
30
|
end
|
29
31
|
|
30
|
-
extend T::Sig
|
31
|
-
|
32
32
|
sig { returns(T.nilable(String)) }
|
33
33
|
def to_standardized_path
|
34
34
|
parsed_path = path
|
@@ -33,6 +33,10 @@ module RubyIndexer
|
|
33
33
|
T::Hash[Integer, Prism::Comment],
|
34
34
|
)
|
35
35
|
@inside_def = T.let(false, T::Boolean)
|
36
|
+
@code_units_cache = T.let(
|
37
|
+
parse_result.code_units_cache(@index.configuration.encoding),
|
38
|
+
T.any(T.proc.params(arg0: Integer).returns(Integer), Prism::CodeUnitsCache),
|
39
|
+
)
|
36
40
|
|
37
41
|
# The nesting stack we're currently inside. Used to determine the fully qualified name of constants, but only
|
38
42
|
# stored by unresolved aliases which need the original nesting to be lazily resolved
|
@@ -65,6 +69,11 @@ module RubyIndexer
|
|
65
69
|
:on_constant_or_write_node_enter,
|
66
70
|
:on_constant_and_write_node_enter,
|
67
71
|
:on_constant_operator_write_node_enter,
|
72
|
+
:on_global_variable_and_write_node_enter,
|
73
|
+
:on_global_variable_operator_write_node_enter,
|
74
|
+
:on_global_variable_or_write_node_enter,
|
75
|
+
:on_global_variable_target_node_enter,
|
76
|
+
:on_global_variable_write_node_enter,
|
68
77
|
:on_instance_variable_write_node_enter,
|
69
78
|
:on_instance_variable_and_write_node_enter,
|
70
79
|
:on_instance_variable_operator_write_node_enter,
|
@@ -106,10 +115,9 @@ module RubyIndexer
|
|
106
115
|
entry = Entry::Class.new(
|
107
116
|
nesting,
|
108
117
|
@file_path,
|
109
|
-
node.location,
|
110
|
-
constant_path.location,
|
118
|
+
Location.from_prism_location(node.location, @code_units_cache),
|
119
|
+
Location.from_prism_location(constant_path.location, @code_units_cache),
|
111
120
|
comments,
|
112
|
-
@index.configuration.encoding,
|
113
121
|
parent_class,
|
114
122
|
)
|
115
123
|
|
@@ -136,10 +144,9 @@ module RubyIndexer
|
|
136
144
|
entry = Entry::Module.new(
|
137
145
|
actual_nesting(name),
|
138
146
|
@file_path,
|
139
|
-
node.location,
|
140
|
-
constant_path.location,
|
147
|
+
Location.from_prism_location(node.location, @code_units_cache),
|
148
|
+
Location.from_prism_location(constant_path.location, @code_units_cache),
|
141
149
|
comments,
|
142
|
-
@index.configuration.encoding,
|
143
150
|
)
|
144
151
|
|
145
152
|
@owner_stack << entry
|
@@ -170,19 +177,17 @@ module RubyIndexer
|
|
170
177
|
if existing_entries
|
171
178
|
entry = T.must(existing_entries.first)
|
172
179
|
entry.update_singleton_information(
|
173
|
-
node.location,
|
174
|
-
expression.location,
|
180
|
+
Location.from_prism_location(node.location, @code_units_cache),
|
181
|
+
Location.from_prism_location(expression.location, @code_units_cache),
|
175
182
|
collect_comments(node),
|
176
|
-
@index.configuration.encoding,
|
177
183
|
)
|
178
184
|
else
|
179
185
|
entry = Entry::SingletonClass.new(
|
180
186
|
real_nesting,
|
181
187
|
@file_path,
|
182
|
-
node.location,
|
183
|
-
expression.location,
|
188
|
+
Location.from_prism_location(node.location, @code_units_cache),
|
189
|
+
Location.from_prism_location(expression.location, @code_units_cache),
|
184
190
|
collect_comments(node),
|
185
|
-
@index.configuration.encoding,
|
186
191
|
nil,
|
187
192
|
)
|
188
193
|
@index.add(entry, skip_prefix_tree: true)
|
@@ -310,7 +315,7 @@ module RubyIndexer
|
|
310
315
|
end
|
311
316
|
|
312
317
|
@enhancements.each do |enhancement|
|
313
|
-
enhancement.on_call_node(@index, @owner_stack.last, node, @file_path)
|
318
|
+
enhancement.on_call_node(@index, @owner_stack.last, node, @file_path, @code_units_cache)
|
314
319
|
rescue StandardError => e
|
315
320
|
@indexing_errors << "Indexing error in #{@file_path} with '#{enhancement.class.name}' enhancement: #{e.message}"
|
316
321
|
end
|
@@ -340,10 +345,9 @@ module RubyIndexer
|
|
340
345
|
@index.add(Entry::Method.new(
|
341
346
|
method_name,
|
342
347
|
@file_path,
|
343
|
-
node.location,
|
344
|
-
node.name_loc,
|
348
|
+
Location.from_prism_location(node.location, @code_units_cache),
|
349
|
+
Location.from_prism_location(node.name_loc, @code_units_cache),
|
345
350
|
comments,
|
346
|
-
@index.configuration.encoding,
|
347
351
|
[Entry::Signature.new(list_params(node.parameters))],
|
348
352
|
current_visibility,
|
349
353
|
@owner_stack.last,
|
@@ -357,10 +361,9 @@ module RubyIndexer
|
|
357
361
|
@index.add(Entry::Method.new(
|
358
362
|
method_name,
|
359
363
|
@file_path,
|
360
|
-
node.location,
|
361
|
-
node.name_loc,
|
364
|
+
Location.from_prism_location(node.location, @code_units_cache),
|
365
|
+
Location.from_prism_location(node.name_loc, @code_units_cache),
|
362
366
|
comments,
|
363
|
-
@index.configuration.encoding,
|
364
367
|
[Entry::Signature.new(list_params(node.parameters))],
|
365
368
|
current_visibility,
|
366
369
|
singleton,
|
@@ -382,6 +385,31 @@ module RubyIndexer
|
|
382
385
|
end
|
383
386
|
end
|
384
387
|
|
388
|
+
sig { params(node: Prism::GlobalVariableAndWriteNode).void }
|
389
|
+
def on_global_variable_and_write_node_enter(node)
|
390
|
+
handle_global_variable(node, node.name_loc)
|
391
|
+
end
|
392
|
+
|
393
|
+
sig { params(node: Prism::GlobalVariableOperatorWriteNode).void }
|
394
|
+
def on_global_variable_operator_write_node_enter(node)
|
395
|
+
handle_global_variable(node, node.name_loc)
|
396
|
+
end
|
397
|
+
|
398
|
+
sig { params(node: Prism::GlobalVariableOrWriteNode).void }
|
399
|
+
def on_global_variable_or_write_node_enter(node)
|
400
|
+
handle_global_variable(node, node.name_loc)
|
401
|
+
end
|
402
|
+
|
403
|
+
sig { params(node: Prism::GlobalVariableTargetNode).void }
|
404
|
+
def on_global_variable_target_node_enter(node)
|
405
|
+
handle_global_variable(node, node.location)
|
406
|
+
end
|
407
|
+
|
408
|
+
sig { params(node: Prism::GlobalVariableWriteNode).void }
|
409
|
+
def on_global_variable_write_node_enter(node)
|
410
|
+
handle_global_variable(node, node.name_loc)
|
411
|
+
end
|
412
|
+
|
385
413
|
sig { params(node: Prism::InstanceVariableWriteNode).void }
|
386
414
|
def on_instance_variable_write_node_enter(node)
|
387
415
|
handle_instance_variable(node, node.name_loc)
|
@@ -417,15 +445,38 @@ module RubyIndexer
|
|
417
445
|
node.old_name.slice,
|
418
446
|
@owner_stack.last,
|
419
447
|
@file_path,
|
420
|
-
node.new_name.location,
|
448
|
+
Location.from_prism_location(node.new_name.location, @code_units_cache),
|
421
449
|
comments,
|
422
|
-
@index.configuration.encoding,
|
423
450
|
),
|
424
451
|
)
|
425
452
|
end
|
426
453
|
|
427
454
|
private
|
428
455
|
|
456
|
+
sig do
|
457
|
+
params(
|
458
|
+
node: T.any(
|
459
|
+
Prism::GlobalVariableAndWriteNode,
|
460
|
+
Prism::GlobalVariableOperatorWriteNode,
|
461
|
+
Prism::GlobalVariableOrWriteNode,
|
462
|
+
Prism::GlobalVariableTargetNode,
|
463
|
+
Prism::GlobalVariableWriteNode,
|
464
|
+
),
|
465
|
+
loc: Prism::Location,
|
466
|
+
).void
|
467
|
+
end
|
468
|
+
def handle_global_variable(node, loc)
|
469
|
+
name = node.name.to_s
|
470
|
+
comments = collect_comments(node)
|
471
|
+
|
472
|
+
@index.add(Entry::GlobalVariable.new(
|
473
|
+
name,
|
474
|
+
@file_path,
|
475
|
+
Location.from_prism_location(loc, @code_units_cache),
|
476
|
+
comments,
|
477
|
+
))
|
478
|
+
end
|
479
|
+
|
429
480
|
sig do
|
430
481
|
params(
|
431
482
|
node: T.any(
|
@@ -453,9 +504,8 @@ module RubyIndexer
|
|
453
504
|
@index.add(Entry::InstanceVariable.new(
|
454
505
|
name,
|
455
506
|
@file_path,
|
456
|
-
loc,
|
507
|
+
Location.from_prism_location(loc, @code_units_cache),
|
457
508
|
collect_comments(node),
|
458
|
-
@index.configuration.encoding,
|
459
509
|
owner,
|
460
510
|
))
|
461
511
|
end
|
@@ -518,9 +568,8 @@ module RubyIndexer
|
|
518
568
|
old_name_value,
|
519
569
|
@owner_stack.last,
|
520
570
|
@file_path,
|
521
|
-
new_name.location,
|
571
|
+
Location.from_prism_location(new_name.location, @code_units_cache),
|
522
572
|
comments,
|
523
|
-
@index.configuration.encoding,
|
524
573
|
),
|
525
574
|
)
|
526
575
|
end
|
@@ -555,9 +604,8 @@ module RubyIndexer
|
|
555
604
|
@stack.dup,
|
556
605
|
name,
|
557
606
|
@file_path,
|
558
|
-
node.location,
|
607
|
+
Location.from_prism_location(node.location, @code_units_cache),
|
559
608
|
comments,
|
560
|
-
@index.configuration.encoding,
|
561
609
|
)
|
562
610
|
when Prism::ConstantWriteNode, Prism::ConstantAndWriteNode, Prism::ConstantOrWriteNode,
|
563
611
|
Prism::ConstantOperatorWriteNode
|
@@ -569,9 +617,8 @@ module RubyIndexer
|
|
569
617
|
@stack.dup,
|
570
618
|
name,
|
571
619
|
@file_path,
|
572
|
-
node.location,
|
620
|
+
Location.from_prism_location(node.location, @code_units_cache),
|
573
621
|
comments,
|
574
|
-
@index.configuration.encoding,
|
575
622
|
)
|
576
623
|
when Prism::ConstantPathWriteNode, Prism::ConstantPathOrWriteNode, Prism::ConstantPathOperatorWriteNode,
|
577
624
|
Prism::ConstantPathAndWriteNode
|
@@ -581,12 +628,16 @@ module RubyIndexer
|
|
581
628
|
@stack.dup,
|
582
629
|
name,
|
583
630
|
@file_path,
|
584
|
-
node.location,
|
631
|
+
Location.from_prism_location(node.location, @code_units_cache),
|
585
632
|
comments,
|
586
|
-
@index.configuration.encoding,
|
587
633
|
)
|
588
634
|
else
|
589
|
-
Entry::Constant.new(
|
635
|
+
Entry::Constant.new(
|
636
|
+
name,
|
637
|
+
@file_path,
|
638
|
+
Location.from_prism_location(node.location, @code_units_cache),
|
639
|
+
comments,
|
640
|
+
)
|
590
641
|
end,
|
591
642
|
)
|
592
643
|
end
|
@@ -652,9 +703,8 @@ module RubyIndexer
|
|
652
703
|
@index.add(Entry::Accessor.new(
|
653
704
|
name,
|
654
705
|
@file_path,
|
655
|
-
loc,
|
706
|
+
Location.from_prism_location(loc, @code_units_cache),
|
656
707
|
comments,
|
657
|
-
@index.configuration.encoding,
|
658
708
|
current_visibility,
|
659
709
|
@owner_stack.last,
|
660
710
|
))
|
@@ -665,9 +715,8 @@ module RubyIndexer
|
|
665
715
|
@index.add(Entry::Accessor.new(
|
666
716
|
"#{name}=",
|
667
717
|
@file_path,
|
668
|
-
loc,
|
718
|
+
Location.from_prism_location(loc, @code_units_cache),
|
669
719
|
comments,
|
670
|
-
@index.configuration.encoding,
|
671
720
|
current_visibility,
|
672
721
|
@owner_stack.last,
|
673
722
|
))
|
@@ -19,8 +19,12 @@ module RubyIndexer
|
|
19
19
|
owner: T.nilable(Entry::Namespace),
|
20
20
|
node: Prism::CallNode,
|
21
21
|
file_path: String,
|
22
|
+
code_units_cache: T.any(
|
23
|
+
T.proc.params(arg0: Integer).returns(Integer),
|
24
|
+
Prism::CodeUnitsCache,
|
25
|
+
),
|
22
26
|
).void
|
23
27
|
end
|
24
|
-
def on_call_node(index, owner, node, file_path); end
|
28
|
+
def on_call_node(index, owner, node, file_path, code_units_cache); end
|
25
29
|
end
|
26
30
|
end
|
@@ -31,30 +31,16 @@ module RubyIndexer
|
|
31
31
|
params(
|
32
32
|
name: String,
|
33
33
|
file_path: String,
|
34
|
-
location:
|
34
|
+
location: Location,
|
35
35
|
comments: T.nilable(String),
|
36
|
-
encoding: Encoding,
|
37
36
|
).void
|
38
37
|
end
|
39
|
-
def initialize(name, file_path, location, comments
|
38
|
+
def initialize(name, file_path, location, comments)
|
40
39
|
@name = name
|
41
40
|
@file_path = file_path
|
42
41
|
@comments = comments
|
43
42
|
@visibility = T.let(Visibility::PUBLIC, Visibility)
|
44
|
-
|
45
|
-
@location = T.let(
|
46
|
-
if location.is_a?(Prism::Location)
|
47
|
-
Location.new(
|
48
|
-
location.start_line,
|
49
|
-
location.end_line,
|
50
|
-
location.start_code_units_column(encoding),
|
51
|
-
location.end_code_units_column(encoding),
|
52
|
-
)
|
53
|
-
else
|
54
|
-
location
|
55
|
-
end,
|
56
|
-
RubyIndexer::Location,
|
57
|
-
)
|
43
|
+
@location = location
|
58
44
|
end
|
59
45
|
|
60
46
|
sig { returns(T::Boolean) }
|
@@ -152,32 +138,19 @@ module RubyIndexer
|
|
152
138
|
params(
|
153
139
|
nesting: T::Array[String],
|
154
140
|
file_path: String,
|
155
|
-
location:
|
156
|
-
name_location:
|
141
|
+
location: Location,
|
142
|
+
name_location: Location,
|
157
143
|
comments: T.nilable(String),
|
158
|
-
encoding: Encoding,
|
159
144
|
).void
|
160
145
|
end
|
161
|
-
def initialize(nesting, file_path, location, name_location, comments
|
146
|
+
def initialize(nesting, file_path, location, name_location, comments)
|
162
147
|
@name = T.let(nesting.join("::"), String)
|
163
148
|
# The original nesting where this namespace was discovered
|
164
149
|
@nesting = nesting
|
165
150
|
|
166
|
-
super(@name, file_path, location, comments
|
167
|
-
|
168
|
-
@name_location =
|
169
|
-
if name_location.is_a?(Prism::Location)
|
170
|
-
Location.new(
|
171
|
-
name_location.start_line,
|
172
|
-
name_location.end_line,
|
173
|
-
name_location.start_code_units_column(encoding),
|
174
|
-
name_location.end_code_units_column(encoding),
|
175
|
-
)
|
176
|
-
else
|
177
|
-
name_location
|
178
|
-
end,
|
179
|
-
RubyIndexer::Location,
|
180
|
-
)
|
151
|
+
super(@name, file_path, location, comments)
|
152
|
+
|
153
|
+
@name_location = name_location
|
181
154
|
end
|
182
155
|
|
183
156
|
sig { returns(T::Array[String]) }
|
@@ -214,15 +187,14 @@ module RubyIndexer
|
|
214
187
|
params(
|
215
188
|
nesting: T::Array[String],
|
216
189
|
file_path: String,
|
217
|
-
location:
|
218
|
-
name_location:
|
190
|
+
location: Location,
|
191
|
+
name_location: Location,
|
219
192
|
comments: T.nilable(String),
|
220
|
-
encoding: Encoding,
|
221
193
|
parent_class: T.nilable(String),
|
222
194
|
).void
|
223
195
|
end
|
224
|
-
def initialize(nesting, file_path, location, name_location, comments,
|
225
|
-
super(nesting, file_path, location, name_location, comments
|
196
|
+
def initialize(nesting, file_path, location, name_location, comments, parent_class) # rubocop:disable Metrics/ParameterLists
|
197
|
+
super(nesting, file_path, location, name_location, comments)
|
226
198
|
@parent_class = parent_class
|
227
199
|
end
|
228
200
|
|
@@ -237,26 +209,14 @@ module RubyIndexer
|
|
237
209
|
|
238
210
|
sig do
|
239
211
|
params(
|
240
|
-
location:
|
241
|
-
name_location:
|
212
|
+
location: Location,
|
213
|
+
name_location: Location,
|
242
214
|
comments: T.nilable(String),
|
243
|
-
encoding: Encoding,
|
244
215
|
).void
|
245
216
|
end
|
246
|
-
def update_singleton_information(location, name_location, comments
|
247
|
-
|
248
|
-
@
|
249
|
-
location.start_line,
|
250
|
-
location.end_line,
|
251
|
-
location.start_code_units_column(encoding),
|
252
|
-
location.end_code_units_column(encoding),
|
253
|
-
)
|
254
|
-
@name_location = Location.new(
|
255
|
-
name_location.start_line,
|
256
|
-
name_location.end_line,
|
257
|
-
name_location.start_code_units_column(encoding),
|
258
|
-
name_location.end_code_units_column(encoding),
|
259
|
-
)
|
217
|
+
def update_singleton_information(location, name_location, comments)
|
218
|
+
@location = location
|
219
|
+
@name_location = name_location
|
260
220
|
(@comments ||= +"") << comments if comments
|
261
221
|
end
|
262
222
|
end
|
@@ -373,15 +333,14 @@ module RubyIndexer
|
|
373
333
|
params(
|
374
334
|
name: String,
|
375
335
|
file_path: String,
|
376
|
-
location:
|
336
|
+
location: Location,
|
377
337
|
comments: T.nilable(String),
|
378
|
-
encoding: Encoding,
|
379
338
|
visibility: Visibility,
|
380
339
|
owner: T.nilable(Entry::Namespace),
|
381
340
|
).void
|
382
341
|
end
|
383
|
-
def initialize(name, file_path, location, comments,
|
384
|
-
super(name, file_path, location, comments
|
342
|
+
def initialize(name, file_path, location, comments, visibility, owner) # rubocop:disable Metrics/ParameterLists
|
343
|
+
super(name, file_path, location, comments)
|
385
344
|
@visibility = visibility
|
386
345
|
@owner = owner
|
387
346
|
end
|
@@ -441,31 +400,18 @@ module RubyIndexer
|
|
441
400
|
params(
|
442
401
|
name: String,
|
443
402
|
file_path: String,
|
444
|
-
location:
|
445
|
-
name_location:
|
403
|
+
location: Location,
|
404
|
+
name_location: Location,
|
446
405
|
comments: T.nilable(String),
|
447
|
-
encoding: Encoding,
|
448
406
|
signatures: T::Array[Signature],
|
449
407
|
visibility: Visibility,
|
450
408
|
owner: T.nilable(Entry::Namespace),
|
451
409
|
).void
|
452
410
|
end
|
453
|
-
def initialize(name, file_path, location, name_location, comments,
|
454
|
-
super(name, file_path, location, comments,
|
411
|
+
def initialize(name, file_path, location, name_location, comments, signatures, visibility, owner) # rubocop:disable Metrics/ParameterLists
|
412
|
+
super(name, file_path, location, comments, visibility, owner)
|
455
413
|
@signatures = signatures
|
456
|
-
@name_location =
|
457
|
-
if name_location.is_a?(Prism::Location)
|
458
|
-
Location.new(
|
459
|
-
name_location.start_line,
|
460
|
-
name_location.end_line,
|
461
|
-
name_location.start_code_units_column(encoding),
|
462
|
-
name_location.end_code_units_column(encoding),
|
463
|
-
)
|
464
|
-
else
|
465
|
-
name_location
|
466
|
-
end,
|
467
|
-
RubyIndexer::Location,
|
468
|
-
)
|
414
|
+
@name_location = name_location
|
469
415
|
end
|
470
416
|
end
|
471
417
|
|
@@ -494,13 +440,12 @@ module RubyIndexer
|
|
494
440
|
nesting: T::Array[String],
|
495
441
|
name: String,
|
496
442
|
file_path: String,
|
497
|
-
location:
|
443
|
+
location: Location,
|
498
444
|
comments: T.nilable(String),
|
499
|
-
encoding: Encoding,
|
500
445
|
).void
|
501
446
|
end
|
502
|
-
def initialize(target, nesting, name, file_path, location, comments
|
503
|
-
super(name, file_path, location, comments
|
447
|
+
def initialize(target, nesting, name, file_path, location, comments) # rubocop:disable Metrics/ParameterLists
|
448
|
+
super(name, file_path, location, comments)
|
504
449
|
|
505
450
|
@target = target
|
506
451
|
@nesting = nesting
|
@@ -514,14 +459,13 @@ module RubyIndexer
|
|
514
459
|
sig { returns(String) }
|
515
460
|
attr_reader :target
|
516
461
|
|
517
|
-
sig { params(target: String, unresolved_alias: UnresolvedConstantAlias
|
518
|
-
def initialize(target, unresolved_alias
|
462
|
+
sig { params(target: String, unresolved_alias: UnresolvedConstantAlias).void }
|
463
|
+
def initialize(target, unresolved_alias)
|
519
464
|
super(
|
520
465
|
unresolved_alias.name,
|
521
466
|
unresolved_alias.file_path,
|
522
467
|
unresolved_alias.location,
|
523
468
|
unresolved_alias.comments,
|
524
|
-
encoding
|
525
469
|
)
|
526
470
|
|
527
471
|
@visibility = unresolved_alias.visibility
|
@@ -541,14 +485,13 @@ module RubyIndexer
|
|
541
485
|
params(
|
542
486
|
name: String,
|
543
487
|
file_path: String,
|
544
|
-
location:
|
488
|
+
location: Location,
|
545
489
|
comments: T.nilable(String),
|
546
|
-
encoding: Encoding,
|
547
490
|
owner: T.nilable(Entry::Namespace),
|
548
491
|
).void
|
549
492
|
end
|
550
|
-
def initialize(name, file_path, location, comments,
|
551
|
-
super(name, file_path, location, comments
|
493
|
+
def initialize(name, file_path, location, comments, owner)
|
494
|
+
super(name, file_path, location, comments)
|
552
495
|
@owner = owner
|
553
496
|
end
|
554
497
|
end
|
@@ -571,13 +514,12 @@ module RubyIndexer
|
|
571
514
|
old_name: String,
|
572
515
|
owner: T.nilable(Entry::Namespace),
|
573
516
|
file_path: String,
|
574
|
-
location:
|
517
|
+
location: Location,
|
575
518
|
comments: T.nilable(String),
|
576
|
-
encoding: Encoding,
|
577
519
|
).void
|
578
520
|
end
|
579
|
-
def initialize(new_name, old_name, owner, file_path, location, comments
|
580
|
-
super(new_name, file_path, location, comments
|
521
|
+
def initialize(new_name, old_name, owner, file_path, location, comments) # rubocop:disable Metrics/ParameterLists
|
522
|
+
super(new_name, file_path, location, comments)
|
581
523
|
|
582
524
|
@new_name = new_name
|
583
525
|
@old_name = old_name
|
@@ -596,9 +538,9 @@ module RubyIndexer
|
|
596
538
|
attr_reader :owner
|
597
539
|
|
598
540
|
sig do
|
599
|
-
params(target: T.any(Member, MethodAlias), unresolved_alias: UnresolvedMethodAlias
|
541
|
+
params(target: T.any(Member, MethodAlias), unresolved_alias: UnresolvedMethodAlias).void
|
600
542
|
end
|
601
|
-
def initialize(target, unresolved_alias
|
543
|
+
def initialize(target, unresolved_alias)
|
602
544
|
full_comments = +"Alias for #{target.name}\n"
|
603
545
|
full_comments << "#{unresolved_alias.comments}\n"
|
604
546
|
full_comments << target.comments
|
@@ -608,7 +550,6 @@ module RubyIndexer
|
|
608
550
|
unresolved_alias.file_path,
|
609
551
|
unresolved_alias.location,
|
610
552
|
full_comments,
|
611
|
-
encoding
|
612
553
|
)
|
613
554
|
|
614
555
|
@target = target
|
@@ -665,7 +665,6 @@ module RubyIndexer
|
|
665
665
|
attached_ancestor.location,
|
666
666
|
attached_ancestor.name_location,
|
667
667
|
nil,
|
668
|
-
@configuration.encoding,
|
669
668
|
nil,
|
670
669
|
)
|
671
670
|
add(singleton, skip_prefix_tree: true)
|
@@ -859,7 +858,7 @@ module RubyIndexer
|
|
859
858
|
return entry unless target
|
860
859
|
|
861
860
|
target_name = T.must(target.first).name
|
862
|
-
resolved_alias = Entry::ConstantAlias.new(target_name, entry
|
861
|
+
resolved_alias = Entry::ConstantAlias.new(target_name, entry)
|
863
862
|
|
864
863
|
# Replace the UnresolvedAlias by a resolved one so that we don't have to do this again later
|
865
864
|
original_entries = T.must(@entries[alias_name])
|
@@ -1050,7 +1049,7 @@ module RubyIndexer
|
|
1050
1049
|
target_method_entries = resolve_method(entry.old_name, receiver_name, seen_names)
|
1051
1050
|
return entry unless target_method_entries
|
1052
1051
|
|
1053
|
-
resolved_alias = Entry::MethodAlias.new(T.must(target_method_entries.first), entry
|
1052
|
+
resolved_alias = Entry::MethodAlias.new(T.must(target_method_entries.first), entry)
|
1054
1053
|
original_entries = T.must(@entries[new_name])
|
1055
1054
|
original_entries.delete(entry)
|
1056
1055
|
original_entries << resolved_alias
|
@@ -5,6 +5,28 @@ module RubyIndexer
|
|
5
5
|
class Location
|
6
6
|
extend T::Sig
|
7
7
|
|
8
|
+
class << self
|
9
|
+
extend T::Sig
|
10
|
+
|
11
|
+
sig do
|
12
|
+
params(
|
13
|
+
prism_location: Prism::Location,
|
14
|
+
code_units_cache: T.any(
|
15
|
+
T.proc.params(arg0: Integer).returns(Integer),
|
16
|
+
Prism::CodeUnitsCache,
|
17
|
+
),
|
18
|
+
).returns(T.attached_class)
|
19
|
+
end
|
20
|
+
def from_prism_location(prism_location, code_units_cache)
|
21
|
+
new(
|
22
|
+
prism_location.start_line,
|
23
|
+
prism_location.end_line,
|
24
|
+
prism_location.cached_start_code_units_column(code_units_cache),
|
25
|
+
prism_location.cached_end_code_units_column(code_units_cache),
|
26
|
+
)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
8
30
|
sig { returns(Integer) }
|
9
31
|
attr_reader :start_line, :end_line, :start_column, :end_column
|
10
32
|
|
@@ -61,9 +61,9 @@ module RubyIndexer
|
|
61
61
|
comments = comments_to_string(declaration)
|
62
62
|
entry = if declaration.is_a?(RBS::AST::Declarations::Class)
|
63
63
|
parent_class = declaration.super_class&.name&.name&.to_s
|
64
|
-
Entry::Class.new(nesting, file_path, location, location, comments,
|
64
|
+
Entry::Class.new(nesting, file_path, location, location, comments, parent_class)
|
65
65
|
else
|
66
|
-
Entry::Module.new(nesting, file_path, location, location, comments
|
66
|
+
Entry::Module.new(nesting, file_path, location, location, comments)
|
67
67
|
end
|
68
68
|
add_declaration_mixins_to_entry(declaration, entry)
|
69
69
|
@index.add(entry)
|
@@ -136,7 +136,6 @@ module RubyIndexer
|
|
136
136
|
location,
|
137
137
|
location,
|
138
138
|
comments,
|
139
|
-
@index.configuration.encoding,
|
140
139
|
signatures,
|
141
140
|
visibility,
|
142
141
|
real_owner,
|
@@ -269,7 +268,6 @@ module RubyIndexer
|
|
269
268
|
file_path,
|
270
269
|
to_ruby_indexer_location(declaration.location),
|
271
270
|
comments_to_string(declaration),
|
272
|
-
@index.configuration.encoding,
|
273
271
|
))
|
274
272
|
end
|
275
273
|
|
@@ -279,14 +277,12 @@ module RubyIndexer
|
|
279
277
|
file_path = pathname.to_s
|
280
278
|
location = to_ruby_indexer_location(declaration.location)
|
281
279
|
comments = comments_to_string(declaration)
|
282
|
-
encoding = @index.configuration.encoding
|
283
280
|
|
284
281
|
@index.add(Entry::GlobalVariable.new(
|
285
282
|
name,
|
286
283
|
file_path,
|
287
284
|
location,
|
288
285
|
comments,
|
289
|
-
encoding,
|
290
286
|
))
|
291
287
|
end
|
292
288
|
|
@@ -302,7 +298,6 @@ module RubyIndexer
|
|
302
298
|
file_path,
|
303
299
|
to_ruby_indexer_location(member.location),
|
304
300
|
comments,
|
305
|
-
@index.configuration.encoding,
|
306
301
|
)
|
307
302
|
|
308
303
|
@index.add(entry)
|