ruby-lsp 0.18.4 → 0.19.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 +9 -4
- data/lib/ruby_indexer/lib/ruby_indexer/configuration.rb +6 -0
- data/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb +66 -8
- data/lib/ruby_indexer/lib/ruby_indexer/entry.rb +56 -32
- data/lib/ruby_indexer/lib/ruby_indexer/index.rb +3 -2
- data/lib/ruby_indexer/lib/ruby_indexer/rbs_indexer.rb +18 -4
- data/lib/ruby_indexer/lib/ruby_indexer/reference_finder.rb +262 -0
- data/lib/ruby_indexer/ruby_indexer.rb +1 -0
- data/lib/ruby_indexer/test/classes_and_modules_test.rb +11 -0
- data/lib/ruby_indexer/test/constant_test.rb +8 -0
- data/lib/ruby_indexer/test/enhancements_test.rb +2 -0
- data/lib/ruby_indexer/test/instance_variables_test.rb +12 -0
- data/lib/ruby_indexer/test/method_test.rb +10 -0
- data/lib/ruby_indexer/test/reference_finder_test.rb +86 -0
- data/lib/ruby_lsp/addon.rb +69 -7
- data/lib/ruby_lsp/erb_document.rb +3 -2
- data/lib/ruby_lsp/global_state.rb +8 -0
- data/lib/ruby_lsp/internal.rb +2 -0
- data/lib/ruby_lsp/listeners/completion.rb +1 -1
- data/lib/ruby_lsp/listeners/hover.rb +19 -0
- data/lib/ruby_lsp/requests/completion_resolve.rb +29 -0
- data/lib/ruby_lsp/requests/rename.rb +189 -0
- data/lib/ruby_lsp/requests/support/source_uri.rb +8 -1
- data/lib/ruby_lsp/server.rb +35 -8
- data/lib/ruby_lsp/static_docs.rb +15 -0
- data/lib/ruby_lsp/store.rb +12 -0
- data/lib/ruby_lsp/test_helper.rb +1 -1
- data/lib/ruby_lsp/type_inferrer.rb +6 -1
- data/static_docs/yield.md +81 -0
- metadata +18 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1d89f4c5d5724a4b8c17002986c64d9f3ea2951282e4a35d96d50b0dd699ba9
|
4
|
+
data.tar.gz: f3513888e58fbde4a85d93a2ef58ae124e02c354729693ae5e928a66548cd058
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57b44fec7c55b57408e042a9c40fe900c2445aa9fefa811223aa3154f5a4e1e8b1d0f11cf306548b13653f3a61877bcb8d01df7beeadb4766f2094b27786653b
|
7
|
+
data.tar.gz: cf769828221a3a1cb65e906b2b9c5c0c8fac8feee265e5f31b90fb96813f10a225798da1b3746165e11fd4591f7bd0620ab177233c2214d939986e22a1e3709b
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.19.0
|
data/lib/core_ext/uri.rb
CHANGED
@@ -3,6 +3,11 @@
|
|
3
3
|
|
4
4
|
module URI
|
5
5
|
class Generic
|
6
|
+
# Avoid a deprecation warning with Ruby 3.4 where the default parser was changed to RFC3986.
|
7
|
+
# This condition must remain even after support for 3.4 has been dropped for users that have
|
8
|
+
# `uri` in their lockfile, decoupling it from the ruby version.
|
9
|
+
PARSER = T.let(const_defined?(:RFC2396_PARSER) ? RFC2396_PARSER : DEFAULT_PARSER, RFC2396_Parser)
|
10
|
+
|
6
11
|
class << self
|
7
12
|
extend T::Sig
|
8
13
|
|
@@ -10,12 +15,12 @@ module URI
|
|
10
15
|
def from_path(path:, fragment: nil, scheme: "file")
|
11
16
|
# On Windows, if the path begins with the disk name, we need to add a leading slash to make it a valid URI
|
12
17
|
escaped_path = if /^[A-Z]:/i.match?(path)
|
13
|
-
|
18
|
+
PARSER.escape("/#{path}")
|
14
19
|
elsif path.start_with?("//?/")
|
15
20
|
# Some paths on Windows start with "//?/". This is a special prefix that allows for long file paths
|
16
|
-
|
21
|
+
PARSER.escape(path.delete_prefix("//?"))
|
17
22
|
else
|
18
|
-
|
23
|
+
PARSER.escape(path)
|
19
24
|
end
|
20
25
|
|
21
26
|
build(scheme: scheme, path: escaped_path, fragment: fragment)
|
@@ -29,7 +34,7 @@ module URI
|
|
29
34
|
parsed_path = path
|
30
35
|
return unless parsed_path
|
31
36
|
|
32
|
-
unescaped_path =
|
37
|
+
unescaped_path = PARSER.unescape(parsed_path)
|
33
38
|
|
34
39
|
# On Windows, when we're getting the file system path back from the URI, we need to remove the leading forward
|
35
40
|
# slash
|
@@ -19,9 +19,13 @@ module RubyIndexer
|
|
19
19
|
sig { params(workspace_path: String).void }
|
20
20
|
attr_writer :workspace_path
|
21
21
|
|
22
|
+
sig { returns(Encoding) }
|
23
|
+
attr_accessor :encoding
|
24
|
+
|
22
25
|
sig { void }
|
23
26
|
def initialize
|
24
27
|
@workspace_path = T.let(Dir.pwd, String)
|
28
|
+
@encoding = T.let(Encoding::UTF_8, Encoding)
|
25
29
|
@excluded_gems = T.let(initial_excluded_gems, T::Array[String])
|
26
30
|
@included_gems = T.let([], T::Array[String])
|
27
31
|
@excluded_patterns = T.let([File.join("**", "*_test.rb"), File.join("tmp", "**", "*")], T::Array[String])
|
@@ -235,6 +239,8 @@ module RubyIndexer
|
|
235
239
|
|
236
240
|
excluded.uniq!
|
237
241
|
excluded.map(&:name)
|
242
|
+
rescue Bundler::GemfileNotFound
|
243
|
+
[]
|
238
244
|
end
|
239
245
|
end
|
240
246
|
end
|
@@ -109,6 +109,7 @@ module RubyIndexer
|
|
109
109
|
node.location,
|
110
110
|
constant_path.location,
|
111
111
|
comments,
|
112
|
+
@index.configuration.encoding,
|
112
113
|
parent_class,
|
113
114
|
)
|
114
115
|
|
@@ -132,7 +133,14 @@ module RubyIndexer
|
|
132
133
|
|
133
134
|
comments = collect_comments(node)
|
134
135
|
|
135
|
-
entry = Entry::Module.new(
|
136
|
+
entry = Entry::Module.new(
|
137
|
+
actual_nesting(name),
|
138
|
+
@file_path,
|
139
|
+
node.location,
|
140
|
+
constant_path.location,
|
141
|
+
comments,
|
142
|
+
@index.configuration.encoding,
|
143
|
+
)
|
136
144
|
|
137
145
|
@owner_stack << entry
|
138
146
|
@index.add(entry)
|
@@ -161,7 +169,12 @@ module RubyIndexer
|
|
161
169
|
|
162
170
|
if existing_entries
|
163
171
|
entry = T.must(existing_entries.first)
|
164
|
-
entry.update_singleton_information(
|
172
|
+
entry.update_singleton_information(
|
173
|
+
node.location,
|
174
|
+
expression.location,
|
175
|
+
collect_comments(node),
|
176
|
+
@index.configuration.encoding,
|
177
|
+
)
|
165
178
|
else
|
166
179
|
entry = Entry::SingletonClass.new(
|
167
180
|
real_nesting,
|
@@ -169,6 +182,7 @@ module RubyIndexer
|
|
169
182
|
node.location,
|
170
183
|
expression.location,
|
171
184
|
collect_comments(node),
|
185
|
+
@index.configuration.encoding,
|
172
186
|
nil,
|
173
187
|
)
|
174
188
|
@index.add(entry, skip_prefix_tree: true)
|
@@ -329,6 +343,7 @@ module RubyIndexer
|
|
329
343
|
node.location,
|
330
344
|
node.name_loc,
|
331
345
|
comments,
|
346
|
+
@index.configuration.encoding,
|
332
347
|
[Entry::Signature.new(list_params(node.parameters))],
|
333
348
|
current_visibility,
|
334
349
|
@owner_stack.last,
|
@@ -345,6 +360,7 @@ module RubyIndexer
|
|
345
360
|
node.location,
|
346
361
|
node.name_loc,
|
347
362
|
comments,
|
363
|
+
@index.configuration.encoding,
|
348
364
|
[Entry::Signature.new(list_params(node.parameters))],
|
349
365
|
current_visibility,
|
350
366
|
singleton,
|
@@ -403,6 +419,7 @@ module RubyIndexer
|
|
403
419
|
@file_path,
|
404
420
|
node.new_name.location,
|
405
421
|
comments,
|
422
|
+
@index.configuration.encoding,
|
406
423
|
),
|
407
424
|
)
|
408
425
|
end
|
@@ -433,7 +450,14 @@ module RubyIndexer
|
|
433
450
|
owner = @index.existing_or_new_singleton_class(owner.name)
|
434
451
|
end
|
435
452
|
|
436
|
-
@index.add(Entry::InstanceVariable.new(
|
453
|
+
@index.add(Entry::InstanceVariable.new(
|
454
|
+
name,
|
455
|
+
@file_path,
|
456
|
+
loc,
|
457
|
+
collect_comments(node),
|
458
|
+
@index.configuration.encoding,
|
459
|
+
owner,
|
460
|
+
))
|
437
461
|
end
|
438
462
|
|
439
463
|
sig { params(node: Prism::CallNode).void }
|
@@ -496,6 +520,7 @@ module RubyIndexer
|
|
496
520
|
@file_path,
|
497
521
|
new_name.location,
|
498
522
|
comments,
|
523
|
+
@index.configuration.encoding,
|
499
524
|
),
|
500
525
|
)
|
501
526
|
end
|
@@ -525,19 +550,43 @@ module RubyIndexer
|
|
525
550
|
@index.add(
|
526
551
|
case value
|
527
552
|
when Prism::ConstantReadNode, Prism::ConstantPathNode
|
528
|
-
Entry::UnresolvedConstantAlias.new(
|
553
|
+
Entry::UnresolvedConstantAlias.new(
|
554
|
+
value.slice,
|
555
|
+
@stack.dup,
|
556
|
+
name,
|
557
|
+
@file_path,
|
558
|
+
node.location,
|
559
|
+
comments,
|
560
|
+
@index.configuration.encoding,
|
561
|
+
)
|
529
562
|
when Prism::ConstantWriteNode, Prism::ConstantAndWriteNode, Prism::ConstantOrWriteNode,
|
530
563
|
Prism::ConstantOperatorWriteNode
|
531
564
|
|
532
565
|
# If the right hand side is another constant assignment, we need to visit it because that constant has to be
|
533
566
|
# indexed too
|
534
|
-
Entry::UnresolvedConstantAlias.new(
|
567
|
+
Entry::UnresolvedConstantAlias.new(
|
568
|
+
value.name.to_s,
|
569
|
+
@stack.dup,
|
570
|
+
name,
|
571
|
+
@file_path,
|
572
|
+
node.location,
|
573
|
+
comments,
|
574
|
+
@index.configuration.encoding,
|
575
|
+
)
|
535
576
|
when Prism::ConstantPathWriteNode, Prism::ConstantPathOrWriteNode, Prism::ConstantPathOperatorWriteNode,
|
536
577
|
Prism::ConstantPathAndWriteNode
|
537
578
|
|
538
|
-
Entry::UnresolvedConstantAlias.new(
|
579
|
+
Entry::UnresolvedConstantAlias.new(
|
580
|
+
value.target.slice,
|
581
|
+
@stack.dup,
|
582
|
+
name,
|
583
|
+
@file_path,
|
584
|
+
node.location,
|
585
|
+
comments,
|
586
|
+
@index.configuration.encoding,
|
587
|
+
)
|
539
588
|
else
|
540
|
-
Entry::Constant.new(name, @file_path, node.location, comments)
|
589
|
+
Entry::Constant.new(name, @file_path, node.location, comments, @index.configuration.encoding)
|
541
590
|
end,
|
542
591
|
)
|
543
592
|
end
|
@@ -600,7 +649,15 @@ module RubyIndexer
|
|
600
649
|
next unless name && loc
|
601
650
|
|
602
651
|
if reader
|
603
|
-
@index.add(Entry::Accessor.new(
|
652
|
+
@index.add(Entry::Accessor.new(
|
653
|
+
name,
|
654
|
+
@file_path,
|
655
|
+
loc,
|
656
|
+
comments,
|
657
|
+
@index.configuration.encoding,
|
658
|
+
current_visibility,
|
659
|
+
@owner_stack.last,
|
660
|
+
))
|
604
661
|
end
|
605
662
|
|
606
663
|
next unless writer
|
@@ -610,6 +667,7 @@ module RubyIndexer
|
|
610
667
|
@file_path,
|
611
668
|
loc,
|
612
669
|
comments,
|
670
|
+
@index.configuration.encoding,
|
613
671
|
current_visibility,
|
614
672
|
@owner_stack.last,
|
615
673
|
))
|
@@ -33,9 +33,10 @@ module RubyIndexer
|
|
33
33
|
file_path: String,
|
34
34
|
location: T.any(Prism::Location, RubyIndexer::Location),
|
35
35
|
comments: T.nilable(String),
|
36
|
+
encoding: Encoding,
|
36
37
|
).void
|
37
38
|
end
|
38
|
-
def initialize(name, file_path, location, comments)
|
39
|
+
def initialize(name, file_path, location, comments, encoding)
|
39
40
|
@name = name
|
40
41
|
@file_path = file_path
|
41
42
|
@comments = comments
|
@@ -46,8 +47,8 @@ module RubyIndexer
|
|
46
47
|
Location.new(
|
47
48
|
location.start_line,
|
48
49
|
location.end_line,
|
49
|
-
location.
|
50
|
-
location.
|
50
|
+
location.start_code_units_column(encoding),
|
51
|
+
location.end_code_units_column(encoding),
|
51
52
|
)
|
52
53
|
else
|
53
54
|
location
|
@@ -150,22 +151,23 @@ module RubyIndexer
|
|
150
151
|
location: T.any(Prism::Location, RubyIndexer::Location),
|
151
152
|
name_location: T.any(Prism::Location, Location),
|
152
153
|
comments: T.nilable(String),
|
154
|
+
encoding: Encoding,
|
153
155
|
).void
|
154
156
|
end
|
155
|
-
def initialize(nesting, file_path, location, name_location, comments)
|
157
|
+
def initialize(nesting, file_path, location, name_location, comments, encoding) # rubocop:disable Metrics/ParameterLists
|
156
158
|
@name = T.let(nesting.join("::"), String)
|
157
159
|
# The original nesting where this namespace was discovered
|
158
160
|
@nesting = nesting
|
159
161
|
|
160
|
-
super(@name, file_path, location, comments)
|
162
|
+
super(@name, file_path, location, comments, encoding)
|
161
163
|
|
162
164
|
@name_location = T.let(
|
163
165
|
if name_location.is_a?(Prism::Location)
|
164
166
|
Location.new(
|
165
167
|
name_location.start_line,
|
166
168
|
name_location.end_line,
|
167
|
-
name_location.
|
168
|
-
name_location.
|
169
|
+
name_location.start_code_units_column(encoding),
|
170
|
+
name_location.end_code_units_column(encoding),
|
169
171
|
)
|
170
172
|
else
|
171
173
|
name_location
|
@@ -211,11 +213,12 @@ module RubyIndexer
|
|
211
213
|
location: T.any(Prism::Location, RubyIndexer::Location),
|
212
214
|
name_location: T.any(Prism::Location, Location),
|
213
215
|
comments: T.nilable(String),
|
216
|
+
encoding: Encoding,
|
214
217
|
parent_class: T.nilable(String),
|
215
218
|
).void
|
216
219
|
end
|
217
|
-
def initialize(nesting, file_path, location, name_location, comments, parent_class) # rubocop:disable Metrics/ParameterLists
|
218
|
-
super(nesting, file_path, location, name_location, comments)
|
220
|
+
def initialize(nesting, file_path, location, name_location, comments, encoding, parent_class) # rubocop:disable Metrics/ParameterLists
|
221
|
+
super(nesting, file_path, location, name_location, comments, encoding)
|
219
222
|
@parent_class = parent_class
|
220
223
|
end
|
221
224
|
|
@@ -228,20 +231,27 @@ module RubyIndexer
|
|
228
231
|
class SingletonClass < Class
|
229
232
|
extend T::Sig
|
230
233
|
|
231
|
-
sig
|
232
|
-
|
234
|
+
sig do
|
235
|
+
params(
|
236
|
+
location: Prism::Location,
|
237
|
+
name_location: Prism::Location,
|
238
|
+
comments: T.nilable(String),
|
239
|
+
encoding: Encoding,
|
240
|
+
).void
|
241
|
+
end
|
242
|
+
def update_singleton_information(location, name_location, comments, encoding)
|
233
243
|
# Create a new RubyIndexer::Location object from the Prism location
|
234
244
|
@location = Location.new(
|
235
245
|
location.start_line,
|
236
246
|
location.end_line,
|
237
|
-
location.
|
238
|
-
location.
|
247
|
+
location.start_code_units_column(encoding),
|
248
|
+
location.end_code_units_column(encoding),
|
239
249
|
)
|
240
250
|
@name_location = Location.new(
|
241
251
|
name_location.start_line,
|
242
252
|
name_location.end_line,
|
243
|
-
name_location.
|
244
|
-
name_location.
|
253
|
+
name_location.start_code_units_column(encoding),
|
254
|
+
name_location.end_code_units_column(encoding),
|
245
255
|
)
|
246
256
|
(@comments ||= +"") << comments if comments
|
247
257
|
end
|
@@ -361,12 +371,13 @@ module RubyIndexer
|
|
361
371
|
file_path: String,
|
362
372
|
location: T.any(Prism::Location, RubyIndexer::Location),
|
363
373
|
comments: T.nilable(String),
|
374
|
+
encoding: Encoding,
|
364
375
|
visibility: Visibility,
|
365
376
|
owner: T.nilable(Entry::Namespace),
|
366
377
|
).void
|
367
378
|
end
|
368
|
-
def initialize(name, file_path, location, comments, visibility, owner) # rubocop:disable Metrics/ParameterLists
|
369
|
-
super(name, file_path, location, comments)
|
379
|
+
def initialize(name, file_path, location, comments, encoding, visibility, owner) # rubocop:disable Metrics/ParameterLists
|
380
|
+
super(name, file_path, location, comments, encoding)
|
370
381
|
@visibility = visibility
|
371
382
|
@owner = owner
|
372
383
|
end
|
@@ -429,21 +440,22 @@ module RubyIndexer
|
|
429
440
|
location: T.any(Prism::Location, RubyIndexer::Location),
|
430
441
|
name_location: T.any(Prism::Location, Location),
|
431
442
|
comments: T.nilable(String),
|
443
|
+
encoding: Encoding,
|
432
444
|
signatures: T::Array[Signature],
|
433
445
|
visibility: Visibility,
|
434
446
|
owner: T.nilable(Entry::Namespace),
|
435
447
|
).void
|
436
448
|
end
|
437
|
-
def initialize(name, file_path, location, name_location, comments, signatures, visibility, owner) # rubocop:disable Metrics/ParameterLists
|
438
|
-
super(name, file_path, location, comments, visibility, owner)
|
449
|
+
def initialize(name, file_path, location, name_location, comments, encoding, signatures, visibility, owner) # rubocop:disable Metrics/ParameterLists
|
450
|
+
super(name, file_path, location, comments, encoding, visibility, owner)
|
439
451
|
@signatures = signatures
|
440
452
|
@name_location = T.let(
|
441
453
|
if name_location.is_a?(Prism::Location)
|
442
454
|
Location.new(
|
443
455
|
name_location.start_line,
|
444
456
|
name_location.end_line,
|
445
|
-
name_location.
|
446
|
-
name_location.
|
457
|
+
name_location.start_code_units_column(encoding),
|
458
|
+
name_location.end_code_units_column(encoding),
|
447
459
|
)
|
448
460
|
else
|
449
461
|
name_location
|
@@ -480,10 +492,11 @@ module RubyIndexer
|
|
480
492
|
file_path: String,
|
481
493
|
location: T.any(Prism::Location, RubyIndexer::Location),
|
482
494
|
comments: T.nilable(String),
|
495
|
+
encoding: Encoding,
|
483
496
|
).void
|
484
497
|
end
|
485
|
-
def initialize(target, nesting, name, file_path, location, comments) # rubocop:disable Metrics/ParameterLists
|
486
|
-
super(name, file_path, location, comments)
|
498
|
+
def initialize(target, nesting, name, file_path, location, comments, encoding) # rubocop:disable Metrics/ParameterLists
|
499
|
+
super(name, file_path, location, comments, encoding)
|
487
500
|
|
488
501
|
@target = target
|
489
502
|
@nesting = nesting
|
@@ -497,9 +510,15 @@ module RubyIndexer
|
|
497
510
|
sig { returns(String) }
|
498
511
|
attr_reader :target
|
499
512
|
|
500
|
-
sig { params(target: String, unresolved_alias: UnresolvedConstantAlias).void }
|
501
|
-
def initialize(target, unresolved_alias)
|
502
|
-
super(
|
513
|
+
sig { params(target: String, unresolved_alias: UnresolvedConstantAlias, encoding: Encoding).void }
|
514
|
+
def initialize(target, unresolved_alias, encoding)
|
515
|
+
super(
|
516
|
+
unresolved_alias.name,
|
517
|
+
unresolved_alias.file_path,
|
518
|
+
unresolved_alias.location,
|
519
|
+
unresolved_alias.comments,
|
520
|
+
encoding
|
521
|
+
)
|
503
522
|
|
504
523
|
@visibility = unresolved_alias.visibility
|
505
524
|
@target = target
|
@@ -517,11 +536,12 @@ module RubyIndexer
|
|
517
536
|
file_path: String,
|
518
537
|
location: T.any(Prism::Location, RubyIndexer::Location),
|
519
538
|
comments: T.nilable(String),
|
539
|
+
encoding: Encoding,
|
520
540
|
owner: T.nilable(Entry::Namespace),
|
521
541
|
).void
|
522
542
|
end
|
523
|
-
def initialize(name, file_path, location, comments, owner)
|
524
|
-
super(name, file_path, location, comments)
|
543
|
+
def initialize(name, file_path, location, comments, encoding, owner) # rubocop:disable Metrics/ParameterLists
|
544
|
+
super(name, file_path, location, comments, encoding)
|
525
545
|
@owner = owner
|
526
546
|
end
|
527
547
|
end
|
@@ -546,10 +566,11 @@ module RubyIndexer
|
|
546
566
|
file_path: String,
|
547
567
|
location: T.any(Prism::Location, RubyIndexer::Location),
|
548
568
|
comments: T.nilable(String),
|
569
|
+
encoding: Encoding,
|
549
570
|
).void
|
550
571
|
end
|
551
|
-
def initialize(new_name, old_name, owner, file_path, location, comments) # rubocop:disable Metrics/ParameterLists
|
552
|
-
super(new_name, file_path, location, comments)
|
572
|
+
def initialize(new_name, old_name, owner, file_path, location, comments, encoding) # rubocop:disable Metrics/ParameterLists
|
573
|
+
super(new_name, file_path, location, comments, encoding)
|
553
574
|
|
554
575
|
@new_name = new_name
|
555
576
|
@old_name = old_name
|
@@ -567,8 +588,10 @@ module RubyIndexer
|
|
567
588
|
sig { returns(T.nilable(Entry::Namespace)) }
|
568
589
|
attr_reader :owner
|
569
590
|
|
570
|
-
sig
|
571
|
-
|
591
|
+
sig do
|
592
|
+
params(target: T.any(Member, MethodAlias), unresolved_alias: UnresolvedMethodAlias, encoding: Encoding).void
|
593
|
+
end
|
594
|
+
def initialize(target, unresolved_alias, encoding)
|
572
595
|
full_comments = +"Alias for #{target.name}\n"
|
573
596
|
full_comments << "#{unresolved_alias.comments}\n"
|
574
597
|
full_comments << target.comments
|
@@ -578,6 +601,7 @@ module RubyIndexer
|
|
578
601
|
unresolved_alias.file_path,
|
579
602
|
unresolved_alias.location,
|
580
603
|
full_comments,
|
604
|
+
encoding
|
581
605
|
)
|
582
606
|
|
583
607
|
@target = target
|
@@ -665,6 +665,7 @@ module RubyIndexer
|
|
665
665
|
attached_ancestor.location,
|
666
666
|
attached_ancestor.name_location,
|
667
667
|
nil,
|
668
|
+
@configuration.encoding,
|
668
669
|
nil,
|
669
670
|
)
|
670
671
|
add(singleton, skip_prefix_tree: true)
|
@@ -856,7 +857,7 @@ module RubyIndexer
|
|
856
857
|
return entry unless target
|
857
858
|
|
858
859
|
target_name = T.must(target.first).name
|
859
|
-
resolved_alias = Entry::ConstantAlias.new(target_name, entry)
|
860
|
+
resolved_alias = Entry::ConstantAlias.new(target_name, entry, @configuration.encoding)
|
860
861
|
|
861
862
|
# Replace the UnresolvedAlias by a resolved one so that we don't have to do this again later
|
862
863
|
original_entries = T.must(@entries[alias_name])
|
@@ -1047,7 +1048,7 @@ module RubyIndexer
|
|
1047
1048
|
target_method_entries = resolve_method(entry.old_name, receiver_name, seen_names)
|
1048
1049
|
return entry unless target_method_entries
|
1049
1050
|
|
1050
|
-
resolved_alias = Entry::MethodAlias.new(T.must(target_method_entries.first), entry)
|
1051
|
+
resolved_alias = Entry::MethodAlias.new(T.must(target_method_entries.first), entry, @configuration.encoding)
|
1051
1052
|
original_entries = T.must(@entries[new_name])
|
1052
1053
|
original_entries.delete(entry)
|
1053
1054
|
original_entries << resolved_alias
|
@@ -5,6 +5,8 @@ module RubyIndexer
|
|
5
5
|
class RBSIndexer
|
6
6
|
extend T::Sig
|
7
7
|
|
8
|
+
HAS_UNTYPED_FUNCTION = T.let(!!defined?(RBS::Types::UntypedFunction), T::Boolean)
|
9
|
+
|
8
10
|
sig { params(index: Index).void }
|
9
11
|
def initialize(index)
|
10
12
|
@index = index
|
@@ -57,9 +59,9 @@ module RubyIndexer
|
|
57
59
|
comments = comments_to_string(declaration)
|
58
60
|
entry = if declaration.is_a?(RBS::AST::Declarations::Class)
|
59
61
|
parent_class = declaration.super_class&.name&.name&.to_s
|
60
|
-
Entry::Class.new(nesting, file_path, location, location, comments, parent_class)
|
62
|
+
Entry::Class.new(nesting, file_path, location, location, comments, @index.configuration.encoding, parent_class)
|
61
63
|
else
|
62
|
-
Entry::Module.new(nesting, file_path, location, location, comments)
|
64
|
+
Entry::Module.new(nesting, file_path, location, location, comments, @index.configuration.encoding)
|
63
65
|
end
|
64
66
|
add_declaration_mixins_to_entry(declaration, entry)
|
65
67
|
@index.add(entry)
|
@@ -126,7 +128,17 @@ module RubyIndexer
|
|
126
128
|
|
127
129
|
real_owner = member.singleton? ? @index.existing_or_new_singleton_class(owner.name) : owner
|
128
130
|
signatures = signatures(member)
|
129
|
-
@index.add(Entry::Method.new(
|
131
|
+
@index.add(Entry::Method.new(
|
132
|
+
name,
|
133
|
+
file_path,
|
134
|
+
location,
|
135
|
+
location,
|
136
|
+
comments,
|
137
|
+
@index.configuration.encoding,
|
138
|
+
signatures,
|
139
|
+
visibility,
|
140
|
+
real_owner,
|
141
|
+
))
|
130
142
|
end
|
131
143
|
|
132
144
|
sig { params(member: RBS::AST::Members::MethodDefinition).returns(T::Array[Entry::Signature]) }
|
@@ -151,7 +163,7 @@ module RubyIndexer
|
|
151
163
|
|
152
164
|
# Untyped functions are a new RBS feature (since v3.6.0) to declare methods that accept any parameters. For our
|
153
165
|
# purposes, accepting any argument is equivalent to `...`
|
154
|
-
if
|
166
|
+
if HAS_UNTYPED_FUNCTION && function.is_a?(RBS::Types::UntypedFunction)
|
155
167
|
[Entry::ForwardingParameter.new]
|
156
168
|
else
|
157
169
|
[]
|
@@ -255,6 +267,7 @@ module RubyIndexer
|
|
255
267
|
file_path,
|
256
268
|
to_ruby_indexer_location(declaration.location),
|
257
269
|
comments_to_string(declaration),
|
270
|
+
@index.configuration.encoding,
|
258
271
|
))
|
259
272
|
end
|
260
273
|
|
@@ -270,6 +283,7 @@ module RubyIndexer
|
|
270
283
|
file_path,
|
271
284
|
to_ruby_indexer_location(member.location),
|
272
285
|
comments,
|
286
|
+
@index.configuration.encoding,
|
273
287
|
)
|
274
288
|
|
275
289
|
@index.add(entry)
|