solargraph 0.58.1 → 0.59.0.dev.1
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.
- checksums.yaml +4 -4
- data/.envrc +3 -0
- data/.github/workflows/linting.yml +4 -5
- data/.github/workflows/plugins.yml +40 -36
- data/.github/workflows/rspec.yml +45 -13
- data/.github/workflows/typecheck.yml +2 -2
- data/.rubocop_todo.yml +27 -49
- data/README.md +3 -3
- data/Rakefile +1 -0
- data/lib/solargraph/api_map/cache.rb +110 -110
- data/lib/solargraph/api_map/constants.rb +289 -279
- data/lib/solargraph/api_map/index.rb +204 -193
- data/lib/solargraph/api_map/source_to_yard.rb +109 -97
- data/lib/solargraph/api_map/store.rb +387 -384
- data/lib/solargraph/api_map.rb +1000 -945
- data/lib/solargraph/complex_type/conformance.rb +176 -0
- data/lib/solargraph/complex_type/type_methods.rb +242 -228
- data/lib/solargraph/complex_type/unique_type.rb +632 -482
- data/lib/solargraph/complex_type.rb +549 -444
- data/lib/solargraph/convention/data_definition/data_definition_node.rb +93 -91
- data/lib/solargraph/convention/data_definition.rb +108 -105
- data/lib/solargraph/convention/struct_definition/struct_assignment_node.rb +62 -61
- data/lib/solargraph/convention/struct_definition/struct_definition_node.rb +103 -102
- data/lib/solargraph/convention/struct_definition.rb +168 -164
- data/lib/solargraph/diagnostics/require_not_found.rb +54 -53
- data/lib/solargraph/diagnostics/rubocop.rb +119 -118
- data/lib/solargraph/diagnostics/rubocop_helpers.rb +70 -68
- data/lib/solargraph/diagnostics/type_check.rb +56 -55
- data/lib/solargraph/doc_map.rb +200 -439
- data/lib/solargraph/equality.rb +34 -34
- data/lib/solargraph/gem_pins.rb +97 -98
- data/lib/solargraph/language_server/host/dispatch.rb +131 -130
- data/lib/solargraph/language_server/host/message_worker.rb +113 -112
- data/lib/solargraph/language_server/host/sources.rb +100 -99
- data/lib/solargraph/language_server/host.rb +883 -878
- data/lib/solargraph/language_server/message/extended/check_gem_version.rb +109 -114
- data/lib/solargraph/language_server/message/extended/document.rb +24 -23
- data/lib/solargraph/language_server/message/text_document/completion.rb +58 -56
- data/lib/solargraph/language_server/message/text_document/definition.rb +42 -40
- data/lib/solargraph/language_server/message/text_document/document_symbol.rb +28 -26
- data/lib/solargraph/language_server/message/text_document/formatting.rb +150 -148
- data/lib/solargraph/language_server/message/text_document/hover.rb +60 -58
- data/lib/solargraph/language_server/message/text_document/signature_help.rb +25 -24
- data/lib/solargraph/language_server/message/text_document/type_definition.rb +27 -25
- data/lib/solargraph/language_server/message/workspace/workspace_symbol.rb +25 -23
- data/lib/solargraph/library.rb +729 -683
- data/lib/solargraph/location.rb +87 -82
- data/lib/solargraph/logging.rb +57 -37
- data/lib/solargraph/parser/comment_ripper.rb +76 -69
- data/lib/solargraph/parser/flow_sensitive_typing.rb +483 -255
- data/lib/solargraph/parser/node_processor/base.rb +122 -92
- data/lib/solargraph/parser/node_processor.rb +63 -62
- data/lib/solargraph/parser/parser_gem/class_methods.rb +167 -149
- data/lib/solargraph/parser/parser_gem/node_chainer.rb +191 -166
- data/lib/solargraph/parser/parser_gem/node_methods.rb +506 -486
- data/lib/solargraph/parser/parser_gem/node_processors/and_node.rb +22 -22
- data/lib/solargraph/parser/parser_gem/node_processors/args_node.rb +61 -59
- data/lib/solargraph/parser/parser_gem/node_processors/begin_node.rb +24 -15
- data/lib/solargraph/parser/parser_gem/node_processors/block_node.rb +46 -46
- data/lib/solargraph/parser/parser_gem/node_processors/def_node.rb +60 -53
- data/lib/solargraph/parser/parser_gem/node_processors/if_node.rb +53 -23
- data/lib/solargraph/parser/parser_gem/node_processors/ivasgn_node.rb +41 -40
- data/lib/solargraph/parser/parser_gem/node_processors/lvasgn_node.rb +30 -29
- data/lib/solargraph/parser/parser_gem/node_processors/masgn_node.rb +61 -59
- data/lib/solargraph/parser/parser_gem/node_processors/opasgn_node.rb +98 -98
- data/lib/solargraph/parser/parser_gem/node_processors/or_node.rb +22 -0
- data/lib/solargraph/parser/parser_gem/node_processors/orasgn_node.rb +17 -17
- data/lib/solargraph/parser/parser_gem/node_processors/resbody_node.rb +39 -38
- data/lib/solargraph/parser/parser_gem/node_processors/sclass_node.rb +53 -52
- data/lib/solargraph/parser/parser_gem/node_processors/send_node.rb +296 -291
- data/lib/solargraph/parser/parser_gem/node_processors/when_node.rb +23 -0
- data/lib/solargraph/parser/parser_gem/node_processors/while_node.rb +33 -29
- data/lib/solargraph/parser/parser_gem/node_processors.rb +74 -70
- data/lib/solargraph/parser/region.rb +75 -69
- data/lib/solargraph/parser/snippet.rb +17 -17
- data/lib/solargraph/pin/base.rb +761 -729
- data/lib/solargraph/pin/base_variable.rb +418 -126
- data/lib/solargraph/pin/block.rb +126 -104
- data/lib/solargraph/pin/breakable.rb +13 -9
- data/lib/solargraph/pin/callable.rb +278 -231
- data/lib/solargraph/pin/closure.rb +68 -72
- data/lib/solargraph/pin/common.rb +94 -79
- data/lib/solargraph/pin/compound_statement.rb +55 -0
- data/lib/solargraph/pin/conversions.rb +124 -123
- data/lib/solargraph/pin/delegated_method.rb +131 -120
- data/lib/solargraph/pin/documenting.rb +115 -114
- data/lib/solargraph/pin/instance_variable.rb +38 -34
- data/lib/solargraph/pin/keyword.rb +16 -20
- data/lib/solargraph/pin/local_variable.rb +31 -75
- data/lib/solargraph/pin/method.rb +720 -672
- data/lib/solargraph/pin/method_alias.rb +42 -34
- data/lib/solargraph/pin/namespace.rb +121 -115
- data/lib/solargraph/pin/parameter.rb +338 -275
- data/lib/solargraph/pin/proxy_type.rb +40 -39
- data/lib/solargraph/pin/reference/override.rb +47 -47
- data/lib/solargraph/pin/reference/superclass.rb +17 -15
- data/lib/solargraph/pin/reference.rb +41 -39
- data/lib/solargraph/pin/search.rb +62 -61
- data/lib/solargraph/pin/signature.rb +69 -61
- data/lib/solargraph/pin/symbol.rb +53 -53
- data/lib/solargraph/pin/until.rb +18 -18
- data/lib/solargraph/pin/while.rb +18 -18
- data/lib/solargraph/pin.rb +46 -44
- data/lib/solargraph/pin_cache.rb +665 -245
- data/lib/solargraph/position.rb +118 -119
- data/lib/solargraph/range.rb +112 -112
- data/lib/solargraph/rbs_map/conversions.rb +846 -823
- data/lib/solargraph/rbs_map/core_map.rb +65 -58
- data/lib/solargraph/rbs_map/stdlib_map.rb +72 -43
- data/lib/solargraph/rbs_map.rb +217 -163
- data/lib/solargraph/shell.rb +397 -352
- data/lib/solargraph/source/chain/call.rb +372 -337
- data/lib/solargraph/source/chain/constant.rb +28 -26
- data/lib/solargraph/source/chain/hash.rb +35 -34
- data/lib/solargraph/source/chain/if.rb +29 -28
- data/lib/solargraph/source/chain/instance_variable.rb +34 -13
- data/lib/solargraph/source/chain/literal.rb +53 -48
- data/lib/solargraph/source/chain/or.rb +31 -23
- data/lib/solargraph/source/chain.rb +294 -291
- data/lib/solargraph/source/change.rb +89 -82
- data/lib/solargraph/source/cursor.rb +172 -166
- data/lib/solargraph/source/source_chainer.rb +204 -194
- data/lib/solargraph/source/updater.rb +59 -55
- data/lib/solargraph/source.rb +524 -498
- data/lib/solargraph/source_map/clip.rb +237 -226
- data/lib/solargraph/source_map/data.rb +37 -34
- data/lib/solargraph/source_map/mapper.rb +282 -259
- data/lib/solargraph/source_map.rb +220 -212
- data/lib/solargraph/type_checker/problem.rb +34 -32
- data/lib/solargraph/type_checker/rules.rb +157 -84
- data/lib/solargraph/type_checker.rb +895 -814
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/workspace/config.rb +257 -255
- data/lib/solargraph/workspace/gemspecs.rb +367 -0
- data/lib/solargraph/workspace/require_paths.rb +98 -97
- data/lib/solargraph/workspace.rb +362 -220
- data/lib/solargraph/yard_map/helpers.rb +45 -44
- data/lib/solargraph/yard_map/mapper/to_method.rb +134 -130
- data/lib/solargraph/yard_map/mapper/to_namespace.rb +32 -31
- data/lib/solargraph/yard_map/mapper.rb +84 -79
- data/lib/solargraph/yardoc.rb +97 -87
- data/lib/solargraph.rb +126 -105
- data/rbs/fills/rubygems/0/dependency.rbs +193 -0
- data/rbs/fills/tuple/tuple.rbs +28 -0
- data/rbs/shims/ast/0/node.rbs +5 -0
- data/rbs/shims/diff-lcs/1.5/diff-lcs.rbs +11 -0
- data/rbs_collection.yaml +1 -1
- data/solargraph.gemspec +2 -1
- metadata +22 -17
- data/lib/solargraph/type_checker/checks.rb +0 -124
- data/lib/solargraph/type_checker/param_def.rb +0 -37
- data/lib/solargraph/yard_map/to_method.rb +0 -89
- data/sig/shims/ast/0/node.rbs +0 -5
- /data/{sig → rbs}/shims/ast/2.4/.rbs_meta.yaml +0 -0
- /data/{sig → rbs}/shims/ast/2.4/ast.rbs +0 -0
- /data/{sig → rbs}/shims/parser/3.2.0.1/builders/default.rbs +0 -0
- /data/{sig → rbs}/shims/parser/3.2.0.1/manifest.yaml +0 -0
- /data/{sig → rbs}/shims/parser/3.2.0.1/parser.rbs +0 -0
- /data/{sig → rbs}/shims/parser/3.2.0.1/polyfill.rbs +0 -0
- /data/{sig → rbs}/shims/thor/1.2.0.1/.rbs_meta.yaml +0 -0
- /data/{sig → rbs}/shims/thor/1.2.0.1/manifest.yaml +0 -0
- /data/{sig → rbs}/shims/thor/1.2.0.1/thor.rbs +0 -0
|
@@ -1,444 +1,549 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Solargraph
|
|
4
|
-
# A container for type data based on YARD type tags.
|
|
5
|
-
#
|
|
6
|
-
class ComplexType
|
|
7
|
-
GENERIC_TAG_NAME = 'generic'.freeze
|
|
8
|
-
# @!parse
|
|
9
|
-
# include TypeMethods
|
|
10
|
-
include Equality
|
|
11
|
-
|
|
12
|
-
autoload :
|
|
13
|
-
autoload :
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
# @
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
items.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
@
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
# @
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
# @
|
|
85
|
-
#
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
# @
|
|
92
|
-
# @
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
# @param
|
|
110
|
-
# @param
|
|
111
|
-
# @param
|
|
112
|
-
# @param
|
|
113
|
-
# @
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
# @
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
# @
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
return @items.first.
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
# @param
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
#
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
#
|
|
208
|
-
# @
|
|
209
|
-
#
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
def
|
|
274
|
-
|
|
275
|
-
end
|
|
276
|
-
|
|
277
|
-
#
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
# @return [
|
|
292
|
-
def
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
# @
|
|
411
|
-
#
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solargraph
|
|
4
|
+
# A container for type data based on YARD type tags.
|
|
5
|
+
#
|
|
6
|
+
class ComplexType
|
|
7
|
+
GENERIC_TAG_NAME = 'generic'.freeze
|
|
8
|
+
# @!parse
|
|
9
|
+
# include TypeMethods
|
|
10
|
+
include Equality
|
|
11
|
+
|
|
12
|
+
autoload :Conformance, 'solargraph/complex_type/conformance'
|
|
13
|
+
autoload :TypeMethods, 'solargraph/complex_type/type_methods'
|
|
14
|
+
autoload :UniqueType, 'solargraph/complex_type/unique_type'
|
|
15
|
+
|
|
16
|
+
# @param types [Array<UniqueType, ComplexType>]
|
|
17
|
+
def initialize types = [UniqueType::UNDEFINED]
|
|
18
|
+
# @todo @items here should not need an annotation
|
|
19
|
+
# @type [Array<UniqueType>]
|
|
20
|
+
items = types.flat_map(&:items).uniq(&:to_s)
|
|
21
|
+
if items.any? { |i| i.name == 'false' } && items.any? { |i| i.name == 'true' }
|
|
22
|
+
items.delete_if { |i| i.name == 'false' || i.name == 'true' }
|
|
23
|
+
items.unshift(UniqueType::BOOLEAN)
|
|
24
|
+
end
|
|
25
|
+
# @type [Array<UniqueType>]
|
|
26
|
+
items = [UniqueType::UNDEFINED] if items.any?(&:undefined?)
|
|
27
|
+
# @todo shouldn't need this cast - if statement above adds an 'Array' type
|
|
28
|
+
# @type [Array<UniqueType>]
|
|
29
|
+
@items = items
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
protected def equality_fields
|
|
33
|
+
[self.class, items]
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# @param api_map [ApiMap]
|
|
37
|
+
# @param context [String]
|
|
38
|
+
# @return [ComplexType]
|
|
39
|
+
def qualify api_map, *gates
|
|
40
|
+
red = reduce_object
|
|
41
|
+
types = red.items.map do |t|
|
|
42
|
+
next t if ['nil', 'void', 'undefined'].include?(t.name)
|
|
43
|
+
next t if ['::Boolean'].include?(t.rooted_name)
|
|
44
|
+
t.qualify api_map, *gates
|
|
45
|
+
end
|
|
46
|
+
ComplexType.new(types).reduce_object
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# @param generics_to_resolve [Enumerable<String>]]
|
|
50
|
+
# @param context_type [ComplexType, ComplexType::UniqueType, nil]
|
|
51
|
+
# @param resolved_generic_values [Hash{String => ComplexType}] Added to as types are encountered or resolved
|
|
52
|
+
# @return [self]
|
|
53
|
+
def resolve_generics_from_context generics_to_resolve, context_type, resolved_generic_values: {}
|
|
54
|
+
return self unless generic?
|
|
55
|
+
|
|
56
|
+
ComplexType.new(@items.map { |i| i.resolve_generics_from_context(generics_to_resolve, context_type, resolved_generic_values: resolved_generic_values) })
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# @return [UniqueType]
|
|
60
|
+
def first
|
|
61
|
+
@items.first
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# @return [String]
|
|
65
|
+
def to_rbs
|
|
66
|
+
((@items.length > 1 ? '(' : '') +
|
|
67
|
+
@items.map(&:to_rbs).join(' | ') +
|
|
68
|
+
(@items.length > 1 ? ')' : ''))
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# @param dst [ComplexType, ComplexType::UniqueType]
|
|
72
|
+
# @return [ComplexType]
|
|
73
|
+
def self_to_type dst
|
|
74
|
+
object_type_dst = dst.reduce_class_type
|
|
75
|
+
transform do |t|
|
|
76
|
+
next t if t.name != 'self'
|
|
77
|
+
object_type_dst
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# @yieldparam [UniqueType]
|
|
82
|
+
# @yieldreturn [UniqueType]
|
|
83
|
+
# @return [Array<UniqueType>]
|
|
84
|
+
# @sg-ignore Declared return type
|
|
85
|
+
# ::Array<::Solargraph::ComplexType::UniqueType> does not match
|
|
86
|
+
# inferred type ::Array<::Proc> for Solargraph::ComplexType#map
|
|
87
|
+
def map(&block)
|
|
88
|
+
@items.map(&block)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# @yieldparam [UniqueType]
|
|
92
|
+
# @return [Enumerable<UniqueType>]
|
|
93
|
+
def each &block
|
|
94
|
+
@items.each &block
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
# @yieldparam [UniqueType]
|
|
98
|
+
# @return [void]
|
|
99
|
+
# @overload each_unique_type()
|
|
100
|
+
# @return [Enumerator<UniqueType>]
|
|
101
|
+
def each_unique_type &block
|
|
102
|
+
return enum_for(__method__) unless block_given?
|
|
103
|
+
|
|
104
|
+
@items.each do |item|
|
|
105
|
+
item.each_unique_type &block
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# @param new_name [String, nil]
|
|
110
|
+
# @param make_rooted [Boolean, nil]
|
|
111
|
+
# @param new_key_types [Array<ComplexType>, nil]
|
|
112
|
+
# @param rooted [Boolean, nil]
|
|
113
|
+
# @param new_subtypes [Array<ComplexType>, nil]
|
|
114
|
+
# @return [self]
|
|
115
|
+
def recreate(new_name: nil, make_rooted: nil, new_key_types: nil, new_subtypes: nil)
|
|
116
|
+
ComplexType.new(map do |ut|
|
|
117
|
+
ut.recreate(new_name: new_name,
|
|
118
|
+
make_rooted: make_rooted,
|
|
119
|
+
new_key_types: new_key_types,
|
|
120
|
+
new_subtypes: new_subtypes)
|
|
121
|
+
end)
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
# @return [Integer]
|
|
125
|
+
def length
|
|
126
|
+
@items.length
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
# @return [Array<UniqueType>]
|
|
130
|
+
def to_a
|
|
131
|
+
@items
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
# @param index [Integer]
|
|
135
|
+
# @return [UniqueType]
|
|
136
|
+
def [](index)
|
|
137
|
+
@items[index]
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
# @return [Array<UniqueType>]
|
|
141
|
+
def select &block
|
|
142
|
+
@items.select &block
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
# @return [String]
|
|
146
|
+
def namespace
|
|
147
|
+
# cache this attr for high frequency call
|
|
148
|
+
@namespace ||= method_missing(:namespace).to_s
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
# @return [Array<String>]
|
|
152
|
+
def namespaces
|
|
153
|
+
@items.map(&:namespace)
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
# @param name [Symbol]
|
|
157
|
+
# @return [Object, nil]
|
|
158
|
+
def method_missing name, *args, &block
|
|
159
|
+
return if @items.first.nil?
|
|
160
|
+
return @items.first.send(name, *args, &block) if respond_to_missing?(name)
|
|
161
|
+
super
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
# @param name [Symbol]
|
|
165
|
+
# @param include_private [Boolean]
|
|
166
|
+
def respond_to_missing?(name, include_private = false)
|
|
167
|
+
TypeMethods.public_instance_methods.include?(name) || super
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
def to_s
|
|
171
|
+
map(&:tag).join(', ')
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
# @return [String]
|
|
175
|
+
def tags
|
|
176
|
+
map(&:tag).join(', ')
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
# @return [String]
|
|
180
|
+
def simple_tags
|
|
181
|
+
simplify_literals.tags
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
def literal?
|
|
185
|
+
@items.any?(&:literal?)
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
# @return [ComplexType]
|
|
189
|
+
def downcast_to_literal_if_possible
|
|
190
|
+
ComplexType.new(items.map(&:downcast_to_literal_if_possible))
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
# @return [String]
|
|
194
|
+
def desc
|
|
195
|
+
rooted_tags
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
# @param api_map [ApiMap]
|
|
199
|
+
# @param expected [ComplexType, ComplexType::UniqueType]
|
|
200
|
+
# @param situation [:method_call, :return_type, :assignment]
|
|
201
|
+
# @param allow_subtype_skew [Boolean] if false, check if any
|
|
202
|
+
# subtypes of the expected type match the inferred type
|
|
203
|
+
# @param allow_reverse_match [Boolean] if true, check if any subtypes
|
|
204
|
+
# of the expected type match the inferred type
|
|
205
|
+
# @param allow_empty_params [Boolean] if true, allow a general
|
|
206
|
+
# inferred type without parameters to conform to a more specific
|
|
207
|
+
# expected type
|
|
208
|
+
# @param allow_any_match [Boolean] if true, any unique type
|
|
209
|
+
# matched in the inferred qualifies as a match
|
|
210
|
+
# @param allow_undefined [Boolean] if true, treat undefined as a
|
|
211
|
+
# wildcard that matches anything
|
|
212
|
+
# @param rules [Array<:allow_subtype_skew, :allow_empty_params, :allow_reverse_match, :allow_any_match, :allow_undefined, :allow_unresolved_generic, :allow_unmatched_interface>]
|
|
213
|
+
# @param variance [:invariant, :covariant, :contravariant]
|
|
214
|
+
# @return [Boolean]
|
|
215
|
+
def conforms_to?(api_map, expected,
|
|
216
|
+
situation,
|
|
217
|
+
rules = [],
|
|
218
|
+
variance: erased_variance(situation))
|
|
219
|
+
expected = expected.downcast_to_literal_if_possible
|
|
220
|
+
inferred = downcast_to_literal_if_possible
|
|
221
|
+
|
|
222
|
+
return duck_types_match?(api_map, expected, inferred) if expected.duck_type?
|
|
223
|
+
|
|
224
|
+
if rules.include? :allow_any_match
|
|
225
|
+
inferred.any? do |inf|
|
|
226
|
+
inf.conforms_to?(api_map, expected, situation, rules,
|
|
227
|
+
variance: variance)
|
|
228
|
+
end
|
|
229
|
+
else
|
|
230
|
+
inferred.all? do |inf|
|
|
231
|
+
inf.conforms_to?(api_map, expected, situation, rules,
|
|
232
|
+
variance: variance)
|
|
233
|
+
end
|
|
234
|
+
end
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
# @param api_map [ApiMap]
|
|
238
|
+
# @param expected [ComplexType, UniqueType]
|
|
239
|
+
# @param inferred [ComplexType, UniqueType]
|
|
240
|
+
# @return [Boolean]
|
|
241
|
+
def duck_types_match? api_map, expected, inferred
|
|
242
|
+
raise ArgumentError, 'Expected type must be duck type' unless expected.duck_type?
|
|
243
|
+
expected.each do |exp|
|
|
244
|
+
next unless exp.duck_type?
|
|
245
|
+
quack = exp.to_s[1..]
|
|
246
|
+
# @sg-ignore Need to add nil check here
|
|
247
|
+
return false if api_map.get_method_stack(inferred.namespace, quack, scope: inferred.scope).empty?
|
|
248
|
+
end
|
|
249
|
+
true
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
# @return [String]
|
|
253
|
+
def rooted_tags
|
|
254
|
+
map(&:rooted_tag).join(', ')
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
# @yieldparam [UniqueType]
|
|
258
|
+
def all? &block
|
|
259
|
+
@items.all? &block
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
# @yieldparam [UniqueType]
|
|
263
|
+
# @yieldreturn [Boolean]
|
|
264
|
+
# @return [Boolean]
|
|
265
|
+
def any? &block
|
|
266
|
+
@items.compact.any? &block
|
|
267
|
+
end
|
|
268
|
+
|
|
269
|
+
def selfy?
|
|
270
|
+
@items.any?(&:selfy?)
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
def generic?
|
|
274
|
+
any?(&:generic?)
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
# @return [self]
|
|
278
|
+
def simplify_literals
|
|
279
|
+
ComplexType.new(map(&:simplify_literals))
|
|
280
|
+
end
|
|
281
|
+
|
|
282
|
+
# @param new_name [String, nil]
|
|
283
|
+
# @yieldparam t [UniqueType]
|
|
284
|
+
# @yieldreturn [UniqueType]
|
|
285
|
+
# @return [ComplexType]
|
|
286
|
+
def transform(new_name = nil, &transform_type)
|
|
287
|
+
raise "Please remove leading :: and set rooted with recreate() instead - #{new_name}" if new_name&.start_with?('::')
|
|
288
|
+
ComplexType.new(map { |ut| ut.transform(new_name, &transform_type) })
|
|
289
|
+
end
|
|
290
|
+
|
|
291
|
+
# @return [self]
|
|
292
|
+
def force_rooted
|
|
293
|
+
transform do |t|
|
|
294
|
+
t.recreate(make_rooted: true)
|
|
295
|
+
end
|
|
296
|
+
end
|
|
297
|
+
|
|
298
|
+
# @param definitions [Pin::Namespace, Pin::Method]
|
|
299
|
+
# @param context_type [ComplexType]
|
|
300
|
+
# @return [ComplexType]
|
|
301
|
+
def resolve_generics definitions, context_type
|
|
302
|
+
result = @items.map { |i| i.resolve_generics(definitions, context_type) }
|
|
303
|
+
ComplexType.new(result)
|
|
304
|
+
end
|
|
305
|
+
|
|
306
|
+
def nullable?
|
|
307
|
+
@items.any?(&:nil_type?)
|
|
308
|
+
end
|
|
309
|
+
|
|
310
|
+
# @return [ComplexType]
|
|
311
|
+
def without_nil
|
|
312
|
+
new_items = @items.reject(&:nil_type?)
|
|
313
|
+
return ComplexType::UNDEFINED if new_items.empty?
|
|
314
|
+
ComplexType.new(new_items)
|
|
315
|
+
end
|
|
316
|
+
|
|
317
|
+
# @return [Array<ComplexType>]
|
|
318
|
+
def all_params
|
|
319
|
+
@items.first.all_params || []
|
|
320
|
+
end
|
|
321
|
+
|
|
322
|
+
# @return [ComplexType]
|
|
323
|
+
def reduce_class_type
|
|
324
|
+
new_items = items.flat_map do |type|
|
|
325
|
+
next type unless ['Module', 'Class'].include?(type.name)
|
|
326
|
+
next type if type.all_params.empty?
|
|
327
|
+
|
|
328
|
+
type.all_params
|
|
329
|
+
end
|
|
330
|
+
ComplexType.new(new_items)
|
|
331
|
+
end
|
|
332
|
+
|
|
333
|
+
# every type and subtype in this union have been resolved to be
|
|
334
|
+
# fully qualified
|
|
335
|
+
def all_rooted?
|
|
336
|
+
all?(&:all_rooted?)
|
|
337
|
+
end
|
|
338
|
+
|
|
339
|
+
# @param other [ComplexType, UniqueType]
|
|
340
|
+
def erased_version_of?(other)
|
|
341
|
+
return false if items.length != 1 || other.items.length != 1
|
|
342
|
+
|
|
343
|
+
@items.first.erased_version_of?(other.items.first)
|
|
344
|
+
end
|
|
345
|
+
|
|
346
|
+
# every top-level type has resolved to be fully qualified; see
|
|
347
|
+
# #all_rooted? to check their subtypes as well
|
|
348
|
+
def rooted?
|
|
349
|
+
all?(&:rooted?)
|
|
350
|
+
end
|
|
351
|
+
|
|
352
|
+
attr_reader :items
|
|
353
|
+
|
|
354
|
+
def rooted?
|
|
355
|
+
@items.all?(&:rooted?)
|
|
356
|
+
end
|
|
357
|
+
|
|
358
|
+
# @param exclude_types [ComplexType, nil]
|
|
359
|
+
# @param api_map [ApiMap]
|
|
360
|
+
# @return [ComplexType, self]
|
|
361
|
+
def exclude exclude_types, api_map
|
|
362
|
+
return self if exclude_types.nil?
|
|
363
|
+
|
|
364
|
+
types = items - exclude_types.items
|
|
365
|
+
types = [ComplexType::UniqueType::UNDEFINED] if types.empty?
|
|
366
|
+
ComplexType.new(types)
|
|
367
|
+
end
|
|
368
|
+
|
|
369
|
+
# @see https://en.wikipedia.org/wiki/Intersection_type
|
|
370
|
+
#
|
|
371
|
+
# @param intersection_type [ComplexType, ComplexType::UniqueType, nil]
|
|
372
|
+
# @param api_map [ApiMap]
|
|
373
|
+
# @return [self, ComplexType::UniqueType]
|
|
374
|
+
def intersect_with intersection_type, api_map
|
|
375
|
+
return self if intersection_type.nil?
|
|
376
|
+
return intersection_type if undefined?
|
|
377
|
+
types = []
|
|
378
|
+
# try to find common types via conformance
|
|
379
|
+
items.each do |ut|
|
|
380
|
+
intersection_type.each do |int_type|
|
|
381
|
+
if int_type.conforms_to?(api_map, ut, :assignment)
|
|
382
|
+
types << int_type
|
|
383
|
+
elsif ut.conforms_to?(api_map, int_type, :assignment)
|
|
384
|
+
types << ut
|
|
385
|
+
end
|
|
386
|
+
end
|
|
387
|
+
end
|
|
388
|
+
types = [ComplexType::UniqueType::UNDEFINED] if types.empty?
|
|
389
|
+
ComplexType.new(types)
|
|
390
|
+
end
|
|
391
|
+
|
|
392
|
+
protected
|
|
393
|
+
|
|
394
|
+
# @return [ComplexType]
|
|
395
|
+
def reduce_object
|
|
396
|
+
new_items = items.flat_map do |ut|
|
|
397
|
+
next [ut] if ut.name != 'Object' || ut.subtypes.empty?
|
|
398
|
+
ut.subtypes
|
|
399
|
+
end
|
|
400
|
+
ComplexType.new(new_items)
|
|
401
|
+
end
|
|
402
|
+
|
|
403
|
+
def bottom?
|
|
404
|
+
@items.all?(&:bot?)
|
|
405
|
+
end
|
|
406
|
+
|
|
407
|
+
class << self
|
|
408
|
+
# Parse type strings into a ComplexType.
|
|
409
|
+
#
|
|
410
|
+
# @example
|
|
411
|
+
# ComplexType.parse 'String', 'Foo', 'nil' #=> [String, Foo, nil]
|
|
412
|
+
#
|
|
413
|
+
# @note
|
|
414
|
+
# The `partial` parameter is used to indicate that the method is
|
|
415
|
+
# receiving a string that will be used inside another ComplexType.
|
|
416
|
+
# It returns arrays of ComplexTypes instead of a single cohesive one.
|
|
417
|
+
# Consumers should not need to use this parameter; it should only be
|
|
418
|
+
# used internally.
|
|
419
|
+
#
|
|
420
|
+
# @param strings [Array<String>] The type definitions to parse
|
|
421
|
+
# @return [ComplexType]
|
|
422
|
+
# # @overload parse(*strings, partial: false)
|
|
423
|
+
# # @todo Need ability to use a literal true as a type below
|
|
424
|
+
# # @param partial [Boolean] True if the string is part of a another type
|
|
425
|
+
# # @return [Array<UniqueType>]
|
|
426
|
+
# @sg-ignore To be able to select the right signature above,
|
|
427
|
+
# Chain::Call needs to know the decl type (:arg, :optarg,
|
|
428
|
+
# :kwarg, etc) of the arguments given, instead of just having
|
|
429
|
+
# an array of Chains as the arguments.
|
|
430
|
+
def parse *strings, partial: false
|
|
431
|
+
# @type [Hash{Array<String> => ComplexType, Array<ComplexType::UniqueType>}]
|
|
432
|
+
@cache ||= {}
|
|
433
|
+
unless partial
|
|
434
|
+
cached = @cache[strings]
|
|
435
|
+
return cached unless cached.nil?
|
|
436
|
+
end
|
|
437
|
+
# @types [Array<ComplexType::UniqueType>]
|
|
438
|
+
types = []
|
|
439
|
+
key_types = nil
|
|
440
|
+
strings.each do |type_string|
|
|
441
|
+
point_stack = 0
|
|
442
|
+
curly_stack = 0
|
|
443
|
+
paren_stack = 0
|
|
444
|
+
base = String.new
|
|
445
|
+
subtype_string = String.new
|
|
446
|
+
# @param char [String]
|
|
447
|
+
type_string&.each_char do |char|
|
|
448
|
+
if char == '='
|
|
449
|
+
#raise ComplexTypeError, "Invalid = in type #{type_string}" unless curly_stack > 0
|
|
450
|
+
elsif char == '<'
|
|
451
|
+
point_stack += 1
|
|
452
|
+
elsif char == '>'
|
|
453
|
+
if subtype_string.end_with?('=') && curly_stack > 0
|
|
454
|
+
subtype_string += char
|
|
455
|
+
elsif base.end_with?('=')
|
|
456
|
+
raise ComplexTypeError, "Invalid hash thing" unless key_types.nil?
|
|
457
|
+
# types.push ComplexType.new([UniqueType.new(base[0..-2].strip)])
|
|
458
|
+
# @sg-ignore Need to add nil check here
|
|
459
|
+
types.push UniqueType.parse(base[0..-2].strip, subtype_string)
|
|
460
|
+
# @todo this should either expand key_type's type
|
|
461
|
+
# automatically or complain about not being
|
|
462
|
+
# compatible with key_type's type in type checking
|
|
463
|
+
key_types = types
|
|
464
|
+
types = []
|
|
465
|
+
base.clear
|
|
466
|
+
subtype_string.clear
|
|
467
|
+
next
|
|
468
|
+
else
|
|
469
|
+
raise ComplexTypeError, "Invalid close in type #{type_string}" if point_stack == 0
|
|
470
|
+
point_stack -= 1
|
|
471
|
+
subtype_string += char
|
|
472
|
+
end
|
|
473
|
+
next
|
|
474
|
+
elsif char == '{'
|
|
475
|
+
curly_stack += 1
|
|
476
|
+
elsif char == '}'
|
|
477
|
+
curly_stack -= 1
|
|
478
|
+
subtype_string += char
|
|
479
|
+
raise ComplexTypeError, "Invalid close in type #{type_string}" if curly_stack < 0
|
|
480
|
+
next
|
|
481
|
+
elsif char == '('
|
|
482
|
+
paren_stack += 1
|
|
483
|
+
elsif char == ')'
|
|
484
|
+
paren_stack -= 1
|
|
485
|
+
subtype_string += char
|
|
486
|
+
raise ComplexTypeError, "Invalid close in type #{type_string}" if paren_stack < 0
|
|
487
|
+
next
|
|
488
|
+
elsif char == ',' && point_stack == 0 && curly_stack == 0 && paren_stack == 0
|
|
489
|
+
# types.push ComplexType.new([UniqueType.new(base.strip, subtype_string.strip)])
|
|
490
|
+
types.push UniqueType.parse(base.strip, subtype_string.strip)
|
|
491
|
+
base.clear
|
|
492
|
+
subtype_string.clear
|
|
493
|
+
next
|
|
494
|
+
end
|
|
495
|
+
if point_stack == 0 && curly_stack == 0 && paren_stack == 0
|
|
496
|
+
base.concat char
|
|
497
|
+
else
|
|
498
|
+
subtype_string.concat char
|
|
499
|
+
end
|
|
500
|
+
end
|
|
501
|
+
raise ComplexTypeError, "Unclosed subtype in #{type_string}" if point_stack != 0 || curly_stack != 0 || paren_stack != 0
|
|
502
|
+
# types.push ComplexType.new([UniqueType.new(base, subtype_string)])
|
|
503
|
+
types.push UniqueType.parse(base.strip, subtype_string.strip)
|
|
504
|
+
end
|
|
505
|
+
unless key_types.nil?
|
|
506
|
+
raise ComplexTypeError, "Invalid use of key/value parameters" unless partial
|
|
507
|
+
return key_types if types.empty?
|
|
508
|
+
return [key_types, types]
|
|
509
|
+
end
|
|
510
|
+
result = partial ? types : ComplexType.new(types)
|
|
511
|
+
@cache[strings] = result unless partial
|
|
512
|
+
result
|
|
513
|
+
end
|
|
514
|
+
|
|
515
|
+
# @param strings [Array<String>]
|
|
516
|
+
# @return [ComplexType]
|
|
517
|
+
def try_parse *strings
|
|
518
|
+
parse *strings
|
|
519
|
+
rescue ComplexTypeError => e
|
|
520
|
+
Solargraph.logger.info "Error parsing complex type `#{strings.join(', ')}`: #{e.message}"
|
|
521
|
+
ComplexType::UNDEFINED
|
|
522
|
+
end
|
|
523
|
+
end
|
|
524
|
+
|
|
525
|
+
VOID = ComplexType.parse('void')
|
|
526
|
+
UNDEFINED = ComplexType.parse('undefined')
|
|
527
|
+
SYMBOL = ComplexType.parse('::Symbol')
|
|
528
|
+
ROOT = ComplexType.parse('::Class<>')
|
|
529
|
+
NIL = ComplexType.parse('nil')
|
|
530
|
+
SELF = ComplexType.parse('self')
|
|
531
|
+
BOOLEAN = ComplexType.parse('::Boolean')
|
|
532
|
+
BOT = ComplexType.parse('bot')
|
|
533
|
+
|
|
534
|
+
private
|
|
535
|
+
|
|
536
|
+
# @todo This is a quick and dirty hack that forces `self` keywords
|
|
537
|
+
# to reference an instance of their class and never the class itself.
|
|
538
|
+
# This behavior may change depending on which result is expected
|
|
539
|
+
# from YARD conventions. See https://github.com/lsegal/yard/issues/1257
|
|
540
|
+
# @param dst [String]
|
|
541
|
+
# @return [String]
|
|
542
|
+
def reduce_class dst
|
|
543
|
+
while dst =~ /^(Class|Module)\<(.*?)\>$/
|
|
544
|
+
dst = dst.sub(/^(Class|Module)\</, '').sub(/\>$/, '')
|
|
545
|
+
end
|
|
546
|
+
dst
|
|
547
|
+
end
|
|
548
|
+
end
|
|
549
|
+
end
|