ruby-lsp 0.23.11 → 0.26.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/VERSION +1 -1
  4. data/exe/ruby-lsp +10 -4
  5. data/exe/ruby-lsp-check +0 -4
  6. data/exe/ruby-lsp-launcher +46 -22
  7. data/exe/ruby-lsp-test-exec +6 -0
  8. data/lib/rubocop/cop/ruby_lsp/use_language_server_aliases.rb +1 -2
  9. data/lib/rubocop/cop/ruby_lsp/use_register_with_handler_method.rb +3 -6
  10. data/lib/ruby_indexer/lib/ruby_indexer/configuration.rb +85 -118
  11. data/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb +159 -183
  12. data/lib/ruby_indexer/lib/ruby_indexer/enhancement.rb +10 -14
  13. data/lib/ruby_indexer/lib/ruby_indexer/entry.rb +130 -253
  14. data/lib/ruby_indexer/lib/ruby_indexer/index.rb +189 -285
  15. data/lib/ruby_indexer/lib/ruby_indexer/location.rb +4 -27
  16. data/lib/ruby_indexer/lib/ruby_indexer/prefix_tree.rb +23 -27
  17. data/lib/ruby_indexer/lib/ruby_indexer/rbs_indexer.rb +31 -59
  18. data/lib/ruby_indexer/lib/ruby_indexer/reference_finder.rb +58 -68
  19. data/lib/ruby_indexer/lib/ruby_indexer/uri.rb +17 -19
  20. data/lib/ruby_indexer/lib/ruby_indexer/visibility_scope.rb +7 -11
  21. data/lib/ruby_lsp/addon.rb +88 -86
  22. data/lib/ruby_lsp/base_server.rb +79 -65
  23. data/lib/ruby_lsp/client_capabilities.rb +16 -13
  24. data/lib/ruby_lsp/document.rb +205 -104
  25. data/lib/ruby_lsp/erb_document.rb +45 -47
  26. data/lib/ruby_lsp/global_state.rb +134 -86
  27. data/lib/ruby_lsp/internal.rb +8 -3
  28. data/lib/ruby_lsp/listeners/code_lens.rb +82 -89
  29. data/lib/ruby_lsp/listeners/completion.rb +81 -76
  30. data/lib/ruby_lsp/listeners/definition.rb +78 -72
  31. data/lib/ruby_lsp/listeners/document_highlight.rb +149 -151
  32. data/lib/ruby_lsp/listeners/document_link.rb +93 -86
  33. data/lib/ruby_lsp/listeners/document_symbol.rb +38 -52
  34. data/lib/ruby_lsp/listeners/folding_ranges.rb +40 -43
  35. data/lib/ruby_lsp/listeners/hover.rb +109 -117
  36. data/lib/ruby_lsp/listeners/inlay_hints.rb +8 -13
  37. data/lib/ruby_lsp/listeners/semantic_highlighting.rb +54 -56
  38. data/lib/ruby_lsp/listeners/signature_help.rb +12 -27
  39. data/lib/ruby_lsp/listeners/spec_style.rb +231 -0
  40. data/lib/ruby_lsp/listeners/test_discovery.rb +107 -0
  41. data/lib/ruby_lsp/listeners/test_style.rb +207 -95
  42. data/lib/ruby_lsp/node_context.rb +12 -39
  43. data/lib/ruby_lsp/rbs_document.rb +10 -11
  44. data/lib/ruby_lsp/requests/code_action_resolve.rb +92 -66
  45. data/lib/ruby_lsp/requests/code_actions.rb +34 -31
  46. data/lib/ruby_lsp/requests/code_lens.rb +31 -21
  47. data/lib/ruby_lsp/requests/completion.rb +8 -21
  48. data/lib/ruby_lsp/requests/completion_resolve.rb +14 -12
  49. data/lib/ruby_lsp/requests/definition.rb +8 -20
  50. data/lib/ruby_lsp/requests/diagnostics.rb +8 -11
  51. data/lib/ruby_lsp/requests/discover_tests.rb +20 -7
  52. data/lib/ruby_lsp/requests/document_highlight.rb +6 -16
  53. data/lib/ruby_lsp/requests/document_link.rb +6 -17
  54. data/lib/ruby_lsp/requests/document_symbol.rb +5 -8
  55. data/lib/ruby_lsp/requests/folding_ranges.rb +7 -15
  56. data/lib/ruby_lsp/requests/formatting.rb +6 -9
  57. data/lib/ruby_lsp/requests/go_to_relevant_file.rb +139 -0
  58. data/lib/ruby_lsp/requests/hover.rb +12 -25
  59. data/lib/ruby_lsp/requests/inlay_hints.rb +8 -19
  60. data/lib/ruby_lsp/requests/on_type_formatting.rb +32 -40
  61. data/lib/ruby_lsp/requests/prepare_rename.rb +5 -10
  62. data/lib/ruby_lsp/requests/prepare_type_hierarchy.rb +5 -15
  63. data/lib/ruby_lsp/requests/range_formatting.rb +5 -6
  64. data/lib/ruby_lsp/requests/references.rb +17 -57
  65. data/lib/ruby_lsp/requests/rename.rb +27 -51
  66. data/lib/ruby_lsp/requests/request.rb +13 -25
  67. data/lib/ruby_lsp/requests/selection_ranges.rb +7 -7
  68. data/lib/ruby_lsp/requests/semantic_highlighting.rb +16 -35
  69. data/lib/ruby_lsp/requests/show_syntax_tree.rb +7 -8
  70. data/lib/ruby_lsp/requests/signature_help.rb +9 -27
  71. data/lib/ruby_lsp/requests/support/annotation.rb +4 -10
  72. data/lib/ruby_lsp/requests/support/common.rb +23 -61
  73. data/lib/ruby_lsp/requests/support/formatter.rb +16 -15
  74. data/lib/ruby_lsp/requests/support/package_url.rb +414 -0
  75. data/lib/ruby_lsp/requests/support/rubocop_diagnostic.rb +27 -35
  76. data/lib/ruby_lsp/requests/support/rubocop_formatter.rb +13 -16
  77. data/lib/ruby_lsp/requests/support/rubocop_runner.rb +34 -36
  78. data/lib/ruby_lsp/requests/support/selection_range.rb +1 -3
  79. data/lib/ruby_lsp/requests/support/sorbet.rb +29 -38
  80. data/lib/ruby_lsp/requests/support/source_uri.rb +22 -33
  81. data/lib/ruby_lsp/requests/support/syntax_tree_formatter.rb +12 -19
  82. data/lib/ruby_lsp/requests/support/test_item.rb +16 -14
  83. data/lib/ruby_lsp/requests/type_hierarchy_supertypes.rb +5 -6
  84. data/lib/ruby_lsp/requests/workspace_symbol.rb +24 -16
  85. data/lib/ruby_lsp/response_builders/collection_response_builder.rb +6 -9
  86. data/lib/ruby_lsp/response_builders/document_symbol.rb +15 -21
  87. data/lib/ruby_lsp/response_builders/hover.rb +12 -18
  88. data/lib/ruby_lsp/response_builders/response_builder.rb +6 -7
  89. data/lib/ruby_lsp/response_builders/semantic_highlighting.rb +62 -91
  90. data/lib/ruby_lsp/response_builders/signature_help.rb +6 -8
  91. data/lib/ruby_lsp/response_builders/test_collection.rb +35 -13
  92. data/lib/ruby_lsp/ruby_document.rb +32 -98
  93. data/lib/ruby_lsp/scope.rb +7 -11
  94. data/lib/ruby_lsp/scripts/compose_bundle.rb +7 -5
  95. data/lib/ruby_lsp/server.rb +305 -198
  96. data/lib/ruby_lsp/setup_bundler.rb +160 -97
  97. data/lib/ruby_lsp/static_docs.rb +12 -7
  98. data/lib/ruby_lsp/store.rb +21 -49
  99. data/lib/ruby_lsp/test_helper.rb +3 -16
  100. data/lib/ruby_lsp/test_reporters/lsp_reporter.rb +241 -0
  101. data/lib/ruby_lsp/test_reporters/minitest_reporter.rb +145 -0
  102. data/lib/ruby_lsp/test_reporters/test_unit_reporter.rb +92 -0
  103. data/lib/ruby_lsp/type_inferrer.rb +13 -14
  104. data/lib/ruby_lsp/utils.rb +138 -93
  105. data/static_docs/break.md +103 -0
  106. metadata +15 -34
  107. data/lib/ruby_indexer/test/class_variables_test.rb +0 -140
  108. data/lib/ruby_indexer/test/classes_and_modules_test.rb +0 -745
  109. data/lib/ruby_indexer/test/configuration_test.rb +0 -239
  110. data/lib/ruby_indexer/test/constant_test.rb +0 -402
  111. data/lib/ruby_indexer/test/enhancements_test.rb +0 -325
  112. data/lib/ruby_indexer/test/global_variable_test.rb +0 -49
  113. data/lib/ruby_indexer/test/index_test.rb +0 -2186
  114. data/lib/ruby_indexer/test/instance_variables_test.rb +0 -240
  115. data/lib/ruby_indexer/test/method_test.rb +0 -947
  116. data/lib/ruby_indexer/test/prefix_tree_test.rb +0 -150
  117. data/lib/ruby_indexer/test/rbs_indexer_test.rb +0 -386
  118. data/lib/ruby_indexer/test/reference_finder_test.rb +0 -330
  119. data/lib/ruby_indexer/test/test_case.rb +0 -51
  120. data/lib/ruby_indexer/test/uri_test.rb +0 -72
  121. data/lib/ruby_lsp/load_sorbet.rb +0 -62
@@ -1,330 +0,0 @@
1
- # typed: true
2
- # frozen_string_literal: true
3
-
4
- require "test_helper"
5
-
6
- module RubyIndexer
7
- class ReferenceFinderTest < Minitest::Test
8
- def test_finds_constant_references
9
- refs = find_const_references("Foo::Bar", <<~RUBY)
10
- module Foo
11
- class Bar
12
- end
13
-
14
- Bar
15
- end
16
-
17
- Foo::Bar
18
- RUBY
19
-
20
- assert_equal("Bar", refs[0].name)
21
- assert_equal(2, refs[0].location.start_line)
22
-
23
- assert_equal("Bar", refs[1].name)
24
- assert_equal(5, refs[1].location.start_line)
25
-
26
- assert_equal("Foo::Bar", refs[2].name)
27
- assert_equal(8, refs[2].location.start_line)
28
- end
29
-
30
- def test_finds_constant_references_inside_singleton_contexts
31
- refs = find_const_references("Foo::<Class:Foo>::Bar", <<~RUBY)
32
- class Foo
33
- class << self
34
- class Bar
35
- end
36
-
37
- Bar
38
- end
39
- end
40
- RUBY
41
-
42
- assert_equal("Bar", refs[0].name)
43
- assert_equal(3, refs[0].location.start_line)
44
-
45
- assert_equal("Bar", refs[1].name)
46
- assert_equal(6, refs[1].location.start_line)
47
- end
48
-
49
- def test_finds_top_level_constant_references
50
- refs = find_const_references("Bar", <<~RUBY)
51
- class Bar
52
- end
53
-
54
- class Foo
55
- ::Bar
56
-
57
- class << self
58
- ::Bar
59
- end
60
- end
61
- RUBY
62
-
63
- assert_equal("Bar", refs[0].name)
64
- assert_equal(1, refs[0].location.start_line)
65
-
66
- assert_equal("::Bar", refs[1].name)
67
- assert_equal(5, refs[1].location.start_line)
68
-
69
- assert_equal("::Bar", refs[2].name)
70
- assert_equal(8, refs[2].location.start_line)
71
- end
72
-
73
- def test_finds_method_references
74
- refs = find_method_references("foo", <<~RUBY)
75
- class Bar
76
- def foo
77
- end
78
-
79
- def baz
80
- foo
81
- end
82
- end
83
- RUBY
84
-
85
- assert_equal(2, refs.size)
86
-
87
- assert_equal("foo", refs[0].name)
88
- assert_equal(2, refs[0].location.start_line)
89
-
90
- assert_equal("foo", refs[1].name)
91
- assert_equal(6, refs[1].location.start_line)
92
- end
93
-
94
- def test_does_not_mismatch_on_readers_and_writers
95
- refs = find_method_references("foo", <<~RUBY)
96
- class Bar
97
- def foo
98
- end
99
-
100
- def foo=(value)
101
- end
102
-
103
- def baz
104
- self.foo = 1
105
- self.foo
106
- end
107
- end
108
- RUBY
109
-
110
- # We want to match `foo` but not `foo=`
111
- assert_equal(2, refs.size)
112
-
113
- assert_equal("foo", refs[0].name)
114
- assert_equal(2, refs[0].location.start_line)
115
-
116
- assert_equal("foo", refs[1].name)
117
- assert_equal(10, refs[1].location.start_line)
118
- end
119
-
120
- def test_matches_writers
121
- refs = find_method_references("foo=", <<~RUBY)
122
- class Bar
123
- def foo
124
- end
125
-
126
- def foo=(value)
127
- end
128
-
129
- def baz
130
- self.foo = 1
131
- self.foo
132
- end
133
- end
134
- RUBY
135
-
136
- # We want to match `foo=` but not `foo`
137
- assert_equal(2, refs.size)
138
-
139
- assert_equal("foo=", refs[0].name)
140
- assert_equal(5, refs[0].location.start_line)
141
-
142
- assert_equal("foo=", refs[1].name)
143
- assert_equal(9, refs[1].location.start_line)
144
- end
145
-
146
- def test_find_inherited_methods
147
- refs = find_method_references("foo", <<~RUBY)
148
- class Bar
149
- def foo
150
- end
151
- end
152
-
153
- class Baz < Bar
154
- super.foo
155
- end
156
- RUBY
157
-
158
- assert_equal(2, refs.size)
159
-
160
- assert_equal("foo", refs[0].name)
161
- assert_equal(2, refs[0].location.start_line)
162
-
163
- assert_equal("foo", refs[1].name)
164
- assert_equal(7, refs[1].location.start_line)
165
- end
166
-
167
- def test_finds_methods_created_in_mixins
168
- refs = find_method_references("foo", <<~RUBY)
169
- module Mixin
170
- def foo
171
- end
172
- end
173
-
174
- class Bar
175
- include Mixin
176
- end
177
-
178
- Bar.foo
179
- RUBY
180
-
181
- assert_equal(2, refs.size)
182
-
183
- assert_equal("foo", refs[0].name)
184
- assert_equal(2, refs[0].location.start_line)
185
-
186
- assert_equal("foo", refs[1].name)
187
- assert_equal(10, refs[1].location.start_line)
188
- end
189
-
190
- def test_finds_singleton_methods
191
- # The current implementation matches on both `Bar.foo` and `Bar#foo` even though they are different
192
-
193
- refs = find_method_references("foo", <<~RUBY)
194
- class Bar
195
- class << self
196
- def foo
197
- end
198
- end
199
-
200
- def foo
201
- end
202
- end
203
-
204
- Bar.foo
205
- RUBY
206
-
207
- assert_equal(3, refs.size)
208
-
209
- assert_equal("foo", refs[0].name)
210
- assert_equal(3, refs[0].location.start_line)
211
-
212
- assert_equal("foo", refs[1].name)
213
- assert_equal(7, refs[1].location.start_line)
214
-
215
- assert_equal("foo", refs[2].name)
216
- assert_equal(11, refs[2].location.start_line)
217
- end
218
-
219
- def test_finds_instance_variable_read_references
220
- refs = find_instance_variable_references("@foo", <<~RUBY)
221
- class Foo
222
- def foo
223
- @foo
224
- end
225
- end
226
- RUBY
227
- assert_equal(1, refs.size)
228
-
229
- assert_equal("@foo", refs[0].name)
230
- assert_equal(3, refs[0].location.start_line)
231
- end
232
-
233
- def test_finds_instance_variable_write_references
234
- refs = find_instance_variable_references("@foo", <<~RUBY)
235
- class Foo
236
- def write
237
- @foo = 1
238
- @foo &&= 2
239
- @foo ||= 3
240
- @foo += 4
241
- @foo, @bar = []
242
- end
243
- end
244
- RUBY
245
- assert_equal(5, refs.size)
246
-
247
- assert_equal(["@foo"], refs.map(&:name).uniq)
248
- assert_equal(3, refs[0].location.start_line)
249
- assert_equal(4, refs[1].location.start_line)
250
- assert_equal(5, refs[2].location.start_line)
251
- assert_equal(6, refs[3].location.start_line)
252
- assert_equal(7, refs[4].location.start_line)
253
- end
254
-
255
- def test_finds_instance_variable_references_ignore_context
256
- refs = find_instance_variable_references("@name", <<~RUBY)
257
- class Foo
258
- def name
259
- @name = "foo"
260
- end
261
- end
262
- class Bar
263
- def name
264
- @name = "bar"
265
- end
266
- end
267
- RUBY
268
- assert_equal(2, refs.size)
269
-
270
- assert_equal("@name", refs[0].name)
271
- assert_equal(3, refs[0].location.start_line)
272
-
273
- assert_equal("@name", refs[1].name)
274
- assert_equal(8, refs[1].location.start_line)
275
- end
276
-
277
- def test_accounts_for_reopened_classes
278
- refs = find_const_references("Foo", <<~RUBY)
279
- class Foo
280
- end
281
- class Foo
282
- class Bar
283
- end
284
- end
285
-
286
- Foo.new
287
- RUBY
288
-
289
- assert_equal(3, refs.size)
290
-
291
- assert_equal("Foo", refs[0].name)
292
- assert_equal(1, refs[0].location.start_line)
293
-
294
- assert_equal("Foo", refs[1].name)
295
- assert_equal(3, refs[1].location.start_line)
296
-
297
- assert_equal("Foo", refs[2].name)
298
- assert_equal(8, refs[2].location.start_line)
299
- end
300
-
301
- private
302
-
303
- def find_const_references(const_name, source)
304
- target = ReferenceFinder::ConstTarget.new(const_name)
305
- find_references(target, source)
306
- end
307
-
308
- def find_method_references(method_name, source)
309
- target = ReferenceFinder::MethodTarget.new(method_name)
310
- find_references(target, source)
311
- end
312
-
313
- def find_instance_variable_references(instance_variable_name, source)
314
- target = ReferenceFinder::InstanceVariableTarget.new(instance_variable_name)
315
- find_references(target, source)
316
- end
317
-
318
- def find_references(target, source)
319
- file_path = "/fake.rb"
320
- uri = URI::Generic.from_path(path: file_path)
321
- index = Index.new
322
- index.index_single(uri, source)
323
- parse_result = Prism.parse(source)
324
- dispatcher = Prism::Dispatcher.new
325
- finder = ReferenceFinder.new(target, index, dispatcher, uri)
326
- dispatcher.visit(parse_result.value)
327
- finder.references
328
- end
329
- end
330
- end
@@ -1,51 +0,0 @@
1
- # typed: true
2
- # frozen_string_literal: true
3
-
4
- require "test_helper"
5
-
6
- module RubyIndexer
7
- class TestCase < Minitest::Test
8
- def setup
9
- @index = Index.new
10
- RBSIndexer.new(@index).index_ruby_core
11
- @default_indexed_entries = @index.instance_variable_get(:@entries).dup
12
- end
13
-
14
- private
15
-
16
- def index(source, uri: URI::Generic.from_path(path: "/fake/path/foo.rb"))
17
- @index.index_single(uri, source)
18
- end
19
-
20
- def assert_entry(expected_name, type, expected_location, visibility: nil)
21
- entries = @index[expected_name]
22
- refute_nil(entries, "Expected #{expected_name} to be indexed")
23
- refute_empty(entries, "Expected #{expected_name} to be indexed")
24
-
25
- entry = entries.first
26
- assert_instance_of(type, entry, "Expected #{expected_name} to be a #{type}")
27
-
28
- location = entry.location
29
- location_string =
30
- "#{entry.file_path}:#{location.start_line - 1}-#{location.start_column}" \
31
- ":#{location.end_line - 1}-#{location.end_column}"
32
-
33
- assert_equal(expected_location, location_string)
34
-
35
- assert_equal(visibility, entry.visibility) if visibility
36
- end
37
-
38
- def refute_entry(expected_name)
39
- entries = @index[expected_name]
40
- assert_nil(entries, "Expected #{expected_name} to not be indexed")
41
- end
42
-
43
- def assert_no_indexed_entries
44
- assert_equal(@default_indexed_entries, @index.instance_variable_get(:@entries))
45
- end
46
-
47
- def assert_no_entry(entry)
48
- refute(@index.indexed?(entry), "Expected '#{entry}' to not be indexed")
49
- end
50
- end
51
- end
@@ -1,72 +0,0 @@
1
- # typed: true
2
- # frozen_string_literal: true
3
-
4
- require "test_helper"
5
-
6
- module RubyIndexer
7
- class URITest < Minitest::Test
8
- def test_from_path_on_unix
9
- uri = URI::Generic.from_path(path: "/some/unix/path/to/file.rb")
10
- assert_equal("/some/unix/path/to/file.rb", uri.path)
11
- end
12
-
13
- def test_from_path_on_windows
14
- uri = URI::Generic.from_path(path: "C:/some/windows/path/to/file.rb")
15
- assert_equal("/C:/some/windows/path/to/file.rb", uri.path)
16
- end
17
-
18
- def test_from_path_on_windows_with_lowercase_drive
19
- uri = URI::Generic.from_path(path: "c:/some/windows/path/to/file.rb")
20
- assert_equal("/c:/some/windows/path/to/file.rb", uri.path)
21
- end
22
-
23
- def test_to_standardized_path_on_unix
24
- uri = URI::Generic.from_path(path: "/some/unix/path/to/file.rb")
25
- assert_equal(uri.path, uri.to_standardized_path)
26
- end
27
-
28
- def test_to_standardized_path_on_windows
29
- uri = URI::Generic.from_path(path: "C:/some/windows/path/to/file.rb")
30
- assert_equal("C:/some/windows/path/to/file.rb", uri.to_standardized_path)
31
- end
32
-
33
- def test_to_standardized_path_on_windows_with_lowercase_drive
34
- uri = URI::Generic.from_path(path: "c:/some/windows/path/to/file.rb")
35
- assert_equal("c:/some/windows/path/to/file.rb", uri.to_standardized_path)
36
- end
37
-
38
- def test_to_standardized_path_on_windows_with_received_uri
39
- uri = URI("file:///c%3A/some/windows/path/to/file.rb")
40
- assert_equal("c:/some/windows/path/to/file.rb", uri.to_standardized_path)
41
- end
42
-
43
- def test_plus_signs_are_properly_unescaped
44
- path = "/opt/rubies/3.3.0/lib/ruby/3.3.0+0/pathname.rb"
45
- uri = URI::Generic.from_path(path: path)
46
- assert_equal(path, uri.to_standardized_path)
47
- end
48
-
49
- def test_from_path_with_fragment
50
- uri = URI::Generic.from_path(path: "/some/unix/path/to/file.rb", fragment: "L1,3-2,9")
51
- assert_equal("file:///some/unix/path/to/file.rb#L1,3-2,9", uri.to_s)
52
- end
53
-
54
- def test_from_path_windows_long_file_paths
55
- uri = URI::Generic.from_path(path: "//?/C:/hostedtoolcache/windows/Ruby/3.3.1/x64/lib/ruby/3.3.0/open-uri.rb")
56
- assert_equal("C:/hostedtoolcache/windows/Ruby/3.3.1/x64/lib/ruby/3.3.0/open-uri.rb", uri.to_standardized_path)
57
- end
58
-
59
- def test_from_path_computes_require_path_when_load_path_entry_is_given
60
- uri = URI::Generic.from_path(path: "/some/unix/path/to/file.rb", load_path_entry: "/some/unix/path")
61
- assert_equal("to/file", uri.require_path)
62
- end
63
-
64
- def test_allows_adding_require_path_with_load_path_entry
65
- uri = URI::Generic.from_path(path: "/some/unix/path/to/file.rb")
66
- assert_nil(uri.require_path)
67
-
68
- uri.add_require_path_from_load_entry("/some/unix/path")
69
- assert_equal("to/file", uri.require_path)
70
- end
71
- end
72
- end
@@ -1,62 +0,0 @@
1
- # typed: true
2
- # frozen_string_literal: true
3
-
4
- require "sorbet-runtime"
5
-
6
- begin
7
- T::Configuration.default_checked_level = :never
8
- # Suppresses call validation errors
9
- T::Configuration.call_validation_error_handler = ->(*arg) {}
10
- # Suppresses errors caused by T.cast, T.let, T.must, etc.
11
- T::Configuration.inline_type_error_handler = ->(*arg) {}
12
- # Suppresses errors caused by incorrect parameter ordering
13
- T::Configuration.sig_validation_error_handler = ->(*arg) {}
14
- rescue
15
- # Need this rescue so that if another gem has
16
- # already set the checked level by the time we
17
- # get to it, we don't fail outright.
18
- nil
19
- end
20
-
21
- module RubyLsp
22
- # No-op all inline type assertions defined in T
23
- module InlineTypeAssertions
24
- def absurd(value)
25
- value
26
- end
27
-
28
- def any(type_a, type_b, *types)
29
- T::Types::Union.new([type_a, type_b, *types])
30
- end
31
-
32
- def assert_type!(value, type, checked: true)
33
- value
34
- end
35
-
36
- def bind(value, type, checked: true)
37
- value
38
- end
39
-
40
- def cast(value, type, checked: true)
41
- value
42
- end
43
-
44
- def let(value, type, checked: true)
45
- value
46
- end
47
-
48
- def must(arg)
49
- arg
50
- end
51
-
52
- def nilable(type)
53
- T::Types::Union.new([type, T::Utils::Nilable::NIL_TYPE])
54
- end
55
-
56
- def unsafe(value)
57
- value
58
- end
59
-
60
- T.singleton_class.prepend(self)
61
- end
62
- end