rbi 0.2.2 → 0.3.3
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/Gemfile +2 -1
- data/lib/rbi/formatter.rb +9 -20
- data/lib/rbi/index.rb +49 -43
- data/lib/rbi/loc.rb +7 -19
- data/lib/rbi/model.rb +246 -584
- data/lib/rbi/parser.rb +227 -98
- data/lib/rbi/printer.rb +173 -108
- data/lib/rbi/rbs/method_type_translator.rb +120 -0
- data/lib/rbi/rbs/type_translator.rb +181 -0
- data/lib/rbi/rbs_printer.rb +273 -150
- data/lib/rbi/rewriters/add_sig_templates.rb +7 -10
- data/lib/rbi/rewriters/annotate.rb +6 -9
- data/lib/rbi/rewriters/attr_to_methods.rb +16 -32
- data/lib/rbi/rewriters/deannotate.rb +5 -8
- data/lib/rbi/rewriters/filter_versions.rb +7 -12
- data/lib/rbi/rewriters/flatten_singleton_methods.rb +5 -7
- data/lib/rbi/rewriters/flatten_visibilities.rb +6 -9
- data/lib/rbi/rewriters/group_nodes.rb +6 -11
- data/lib/rbi/rewriters/merge_trees.rb +84 -132
- data/lib/rbi/rewriters/nest_non_public_members.rb +5 -10
- data/lib/rbi/rewriters/nest_singleton_methods.rb +3 -6
- data/lib/rbi/rewriters/nest_top_level_members.rb +5 -8
- data/lib/rbi/rewriters/remove_known_definitions.rb +13 -23
- data/lib/rbi/rewriters/sort_nodes.rb +10 -11
- data/lib/rbi/rewriters/translate_rbs_sigs.rb +87 -0
- data/lib/rbi/type.rb +135 -137
- data/lib/rbi/type_parser.rb +51 -27
- data/lib/rbi/type_visitor.rb +19 -21
- data/lib/rbi/version.rb +1 -1
- data/lib/rbi/visitor.rb +55 -46
- data/lib/rbi.rb +7 -3
- data/rbi/rbi.rbi +3686 -0
- metadata +21 -7
data/lib/rbi/model.rb
CHANGED
@@ -5,24 +5,23 @@ module RBI
|
|
5
5
|
class ReplaceNodeError < Error; end
|
6
6
|
|
7
7
|
class Node
|
8
|
-
extend T::Sig
|
9
8
|
extend T::Helpers
|
10
9
|
|
11
10
|
abstract!
|
12
11
|
|
13
|
-
|
12
|
+
#: Tree?
|
14
13
|
attr_accessor :parent_tree
|
15
14
|
|
16
|
-
|
15
|
+
#: Loc?
|
17
16
|
attr_accessor :loc
|
18
17
|
|
19
|
-
|
18
|
+
#: (?loc: Loc?) -> void
|
20
19
|
def initialize(loc: nil)
|
21
20
|
@parent_tree = nil
|
22
21
|
@loc = loc
|
23
22
|
end
|
24
23
|
|
25
|
-
|
24
|
+
#: -> void
|
26
25
|
def detach
|
27
26
|
tree = parent_tree
|
28
27
|
return unless tree
|
@@ -31,7 +30,7 @@ module RBI
|
|
31
30
|
self.parent_tree = nil
|
32
31
|
end
|
33
32
|
|
34
|
-
|
33
|
+
#: (Node node) -> void
|
35
34
|
def replace(node)
|
36
35
|
tree = parent_tree
|
37
36
|
raise ReplaceNodeError, "Can't replace #{self} without a parent tree" unless tree
|
@@ -44,27 +43,25 @@ module RBI
|
|
44
43
|
self.parent_tree = nil
|
45
44
|
end
|
46
45
|
|
47
|
-
|
46
|
+
#: -> Scope?
|
48
47
|
def parent_scope
|
49
|
-
parent =
|
48
|
+
parent = parent_tree #: Tree?
|
50
49
|
parent = parent.parent_tree until parent.is_a?(Scope) || parent.nil?
|
51
50
|
parent
|
52
51
|
end
|
53
52
|
end
|
54
53
|
|
55
54
|
class Comment < Node
|
56
|
-
|
57
|
-
|
58
|
-
sig { returns(String) }
|
55
|
+
#: String
|
59
56
|
attr_accessor :text
|
60
57
|
|
61
|
-
|
58
|
+
#: (String text, ?loc: Loc?) -> void
|
62
59
|
def initialize(text, loc: nil)
|
63
60
|
super(loc: loc)
|
64
61
|
@text = text
|
65
62
|
end
|
66
63
|
|
67
|
-
|
64
|
+
#: (Object other) -> bool
|
68
65
|
def ==(other)
|
69
66
|
return false unless other.is_a?(Comment)
|
70
67
|
|
@@ -74,100 +71,93 @@ module RBI
|
|
74
71
|
|
75
72
|
# An arbitrary blank line that can be added both in trees and comments
|
76
73
|
class BlankLine < Comment
|
77
|
-
|
78
|
-
|
79
|
-
sig { params(loc: T.nilable(Loc)).void }
|
74
|
+
#: (?loc: Loc?) -> void
|
80
75
|
def initialize(loc: nil)
|
81
76
|
super("", loc: loc)
|
82
77
|
end
|
83
78
|
end
|
84
79
|
|
80
|
+
# A comment representing a RBS type prefixed with `#:`
|
81
|
+
class RBSComment < Comment
|
82
|
+
#: (Object other) -> bool
|
83
|
+
def ==(other)
|
84
|
+
return false unless other.is_a?(RBSComment)
|
85
|
+
|
86
|
+
text == other.text
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
85
90
|
class NodeWithComments < Node
|
86
|
-
extend T::Sig
|
87
91
|
extend T::Helpers
|
88
92
|
|
89
93
|
abstract!
|
90
94
|
|
91
|
-
|
95
|
+
#: Array[Comment]
|
92
96
|
attr_accessor :comments
|
93
97
|
|
94
|
-
|
98
|
+
#: (?loc: Loc?, ?comments: Array[Comment]) -> void
|
95
99
|
def initialize(loc: nil, comments: [])
|
96
100
|
super(loc: loc)
|
97
101
|
@comments = comments
|
98
102
|
end
|
99
103
|
|
100
|
-
|
104
|
+
#: -> Array[String]
|
101
105
|
def annotations
|
102
106
|
comments
|
103
107
|
.select { |comment| comment.text.start_with?("@") }
|
104
|
-
.map
|
108
|
+
.map do |comment|
|
109
|
+
comment.text[1..] #: as !nil
|
110
|
+
end
|
105
111
|
end
|
106
112
|
end
|
107
113
|
|
108
114
|
class Tree < NodeWithComments
|
109
|
-
|
110
|
-
|
111
|
-
sig { returns(T::Array[Node]) }
|
115
|
+
#: Array[Node]
|
112
116
|
attr_reader :nodes
|
113
117
|
|
114
|
-
|
115
|
-
params(
|
116
|
-
loc: T.nilable(Loc),
|
117
|
-
comments: T::Array[Comment],
|
118
|
-
block: T.nilable(T.proc.params(node: Tree).void),
|
119
|
-
).void
|
120
|
-
end
|
118
|
+
#: (?loc: Loc?, ?comments: Array[Comment]) ?{ (Tree node) -> void } -> void
|
121
119
|
def initialize(loc: nil, comments: [], &block)
|
122
120
|
super(loc: loc, comments: comments)
|
123
|
-
@nodes =
|
121
|
+
@nodes = [] #: Array[Node]
|
124
122
|
block&.call(self)
|
125
123
|
end
|
126
124
|
|
127
|
-
|
125
|
+
#: (Node node) -> void
|
128
126
|
def <<(node)
|
129
127
|
node.parent_tree = self
|
130
128
|
@nodes << node
|
131
129
|
end
|
132
130
|
|
133
|
-
|
131
|
+
#: -> bool
|
134
132
|
def empty?
|
135
133
|
nodes.empty?
|
136
134
|
end
|
137
135
|
end
|
138
136
|
|
139
137
|
class File
|
140
|
-
|
141
|
-
|
142
|
-
sig { returns(Tree) }
|
138
|
+
#: Tree
|
143
139
|
attr_accessor :root
|
144
140
|
|
145
|
-
|
141
|
+
#: String?
|
146
142
|
attr_accessor :strictness
|
147
143
|
|
148
|
-
|
144
|
+
#: Array[Comment]
|
149
145
|
attr_accessor :comments
|
150
146
|
|
151
|
-
|
152
|
-
params(
|
153
|
-
strictness: T.nilable(String),
|
154
|
-
comments: T::Array[Comment],
|
155
|
-
block: T.nilable(T.proc.params(file: File).void),
|
156
|
-
).void
|
157
|
-
end
|
147
|
+
#: (?strictness: String?, ?comments: Array[Comment]) ?{ (File file) -> void } -> void
|
158
148
|
def initialize(strictness: nil, comments: [], &block)
|
159
|
-
@root =
|
149
|
+
@root = Tree.new #: Tree
|
160
150
|
@strictness = strictness
|
161
151
|
@comments = comments
|
162
152
|
block&.call(self)
|
163
153
|
end
|
164
154
|
|
165
|
-
|
155
|
+
#: (Node node) -> void
|
166
156
|
def <<(node)
|
167
157
|
@root << node
|
168
158
|
end
|
169
159
|
|
170
|
-
|
160
|
+
#: -> bool
|
171
161
|
def empty?
|
172
162
|
@root.empty?
|
173
163
|
end
|
@@ -176,6 +166,7 @@ module RBI
|
|
176
166
|
# Scopes
|
177
167
|
|
178
168
|
class Scope < Tree
|
169
|
+
extend T::Sig
|
179
170
|
extend T::Helpers
|
180
171
|
|
181
172
|
abstract!
|
@@ -183,33 +174,26 @@ module RBI
|
|
183
174
|
sig { abstract.returns(String) }
|
184
175
|
def fully_qualified_name; end
|
185
176
|
|
186
|
-
|
177
|
+
# @override
|
178
|
+
#: -> String
|
187
179
|
def to_s
|
188
180
|
fully_qualified_name
|
189
181
|
end
|
190
182
|
end
|
191
183
|
|
192
184
|
class Module < Scope
|
193
|
-
|
194
|
-
|
195
|
-
sig { returns(String) }
|
185
|
+
#: String
|
196
186
|
attr_accessor :name
|
197
187
|
|
198
|
-
|
199
|
-
params(
|
200
|
-
name: String,
|
201
|
-
loc: T.nilable(Loc),
|
202
|
-
comments: T::Array[Comment],
|
203
|
-
block: T.nilable(T.proc.params(node: Module).void),
|
204
|
-
).void
|
205
|
-
end
|
188
|
+
#: (String name, ?loc: Loc?, ?comments: Array[Comment]) ?{ (Module node) -> void } -> void
|
206
189
|
def initialize(name, loc: nil, comments: [], &block)
|
207
190
|
super(loc: loc, comments: comments) {}
|
208
191
|
@name = name
|
209
192
|
block&.call(self)
|
210
193
|
end
|
211
194
|
|
212
|
-
|
195
|
+
# @override
|
196
|
+
#: -> String
|
213
197
|
def fully_qualified_name
|
214
198
|
return name if name.start_with?("::")
|
215
199
|
|
@@ -218,23 +202,13 @@ module RBI
|
|
218
202
|
end
|
219
203
|
|
220
204
|
class Class < Scope
|
221
|
-
|
222
|
-
|
223
|
-
sig { returns(String) }
|
205
|
+
#: String
|
224
206
|
attr_accessor :name
|
225
207
|
|
226
|
-
|
208
|
+
#: String?
|
227
209
|
attr_accessor :superclass_name
|
228
210
|
|
229
|
-
|
230
|
-
params(
|
231
|
-
name: String,
|
232
|
-
superclass_name: T.nilable(String),
|
233
|
-
loc: T.nilable(Loc),
|
234
|
-
comments: T::Array[Comment],
|
235
|
-
block: T.nilable(T.proc.params(node: Class).void),
|
236
|
-
).void
|
237
|
-
end
|
211
|
+
#: (String name, ?superclass_name: String?, ?loc: Loc?, ?comments: Array[Comment]) ?{ (Class node) -> void } -> void
|
238
212
|
def initialize(name, superclass_name: nil, loc: nil, comments: [], &block)
|
239
213
|
super(loc: loc, comments: comments) {}
|
240
214
|
@name = name
|
@@ -242,7 +216,8 @@ module RBI
|
|
242
216
|
block&.call(self)
|
243
217
|
end
|
244
218
|
|
245
|
-
|
219
|
+
# @override
|
220
|
+
#: -> String
|
246
221
|
def fully_qualified_name
|
247
222
|
return name if name.start_with?("::")
|
248
223
|
|
@@ -251,48 +226,30 @@ module RBI
|
|
251
226
|
end
|
252
227
|
|
253
228
|
class SingletonClass < Scope
|
254
|
-
|
255
|
-
|
256
|
-
sig do
|
257
|
-
params(
|
258
|
-
loc: T.nilable(Loc),
|
259
|
-
comments: T::Array[Comment],
|
260
|
-
block: T.nilable(T.proc.params(node: SingletonClass).void),
|
261
|
-
).void
|
262
|
-
end
|
229
|
+
#: (?loc: Loc?, ?comments: Array[Comment]) ?{ (SingletonClass node) -> void } -> void
|
263
230
|
def initialize(loc: nil, comments: [], &block)
|
264
|
-
super
|
231
|
+
super {}
|
265
232
|
block&.call(self)
|
266
233
|
end
|
267
234
|
|
268
|
-
|
235
|
+
# @override
|
236
|
+
#: -> String
|
269
237
|
def fully_qualified_name
|
270
238
|
"#{parent_scope&.fully_qualified_name}::<self>"
|
271
239
|
end
|
272
240
|
end
|
273
241
|
|
274
242
|
class Struct < Scope
|
275
|
-
|
276
|
-
|
277
|
-
sig { returns(String) }
|
243
|
+
#: String
|
278
244
|
attr_accessor :name
|
279
245
|
|
280
|
-
|
246
|
+
#: Array[Symbol]
|
281
247
|
attr_accessor :members
|
282
248
|
|
283
|
-
|
249
|
+
#: bool
|
284
250
|
attr_accessor :keyword_init
|
285
251
|
|
286
|
-
|
287
|
-
params(
|
288
|
-
name: String,
|
289
|
-
members: T::Array[Symbol],
|
290
|
-
keyword_init: T::Boolean,
|
291
|
-
loc: T.nilable(Loc),
|
292
|
-
comments: T::Array[Comment],
|
293
|
-
block: T.nilable(T.proc.params(struct: Struct).void),
|
294
|
-
).void
|
295
|
-
end
|
252
|
+
#: (String name, ?members: Array[Symbol], ?keyword_init: bool, ?loc: Loc?, ?comments: Array[Comment]) ?{ (Struct struct) -> void } -> void
|
296
253
|
def initialize(name, members: [], keyword_init: false, loc: nil, comments: [], &block)
|
297
254
|
super(loc: loc, comments: comments) {}
|
298
255
|
@name = name
|
@@ -301,7 +258,8 @@ module RBI
|
|
301
258
|
block&.call(self)
|
302
259
|
end
|
303
260
|
|
304
|
-
|
261
|
+
# @override
|
262
|
+
#: -> String
|
305
263
|
def fully_qualified_name
|
306
264
|
return name if name.start_with?("::")
|
307
265
|
|
@@ -312,20 +270,10 @@ module RBI
|
|
312
270
|
# Consts
|
313
271
|
|
314
272
|
class Const < NodeWithComments
|
315
|
-
|
316
|
-
|
317
|
-
sig { returns(String) }
|
273
|
+
#: String
|
318
274
|
attr_reader :name, :value
|
319
275
|
|
320
|
-
|
321
|
-
params(
|
322
|
-
name: String,
|
323
|
-
value: String,
|
324
|
-
loc: T.nilable(Loc),
|
325
|
-
comments: T::Array[Comment],
|
326
|
-
block: T.nilable(T.proc.params(node: Const).void),
|
327
|
-
).void
|
328
|
-
end
|
276
|
+
#: (String name, String value, ?loc: Loc?, ?comments: Array[Comment]) ?{ (Const node) -> void } -> void
|
329
277
|
def initialize(name, value, loc: nil, comments: [], &block)
|
330
278
|
super(loc: loc, comments: comments)
|
331
279
|
@name = name
|
@@ -333,14 +281,15 @@ module RBI
|
|
333
281
|
block&.call(self)
|
334
282
|
end
|
335
283
|
|
336
|
-
|
284
|
+
#: -> String
|
337
285
|
def fully_qualified_name
|
338
286
|
return name if name.start_with?("::")
|
339
287
|
|
340
288
|
"#{parent_scope&.fully_qualified_name}::#{name}"
|
341
289
|
end
|
342
290
|
|
343
|
-
|
291
|
+
# @override
|
292
|
+
#: -> String
|
344
293
|
def to_s
|
345
294
|
fully_qualified_name
|
346
295
|
end
|
@@ -354,28 +303,19 @@ module RBI
|
|
354
303
|
|
355
304
|
abstract!
|
356
305
|
|
357
|
-
|
306
|
+
#: Array[Symbol]
|
358
307
|
attr_reader :names
|
359
308
|
|
360
|
-
|
309
|
+
#: Visibility
|
361
310
|
attr_accessor :visibility
|
362
311
|
|
363
|
-
|
312
|
+
#: Array[Sig]
|
364
313
|
attr_reader :sigs
|
365
314
|
|
366
|
-
|
367
|
-
params(
|
368
|
-
name: Symbol,
|
369
|
-
names: T::Array[Symbol],
|
370
|
-
visibility: Visibility,
|
371
|
-
sigs: T::Array[Sig],
|
372
|
-
loc: T.nilable(Loc),
|
373
|
-
comments: T::Array[Comment],
|
374
|
-
).void
|
375
|
-
end
|
315
|
+
#: (Symbol name, Array[Symbol] names, ?visibility: Visibility, ?sigs: Array[Sig], ?loc: Loc?, ?comments: Array[Comment]) -> void
|
376
316
|
def initialize(name, names, visibility: Public.new, sigs: [], loc: nil, comments: [])
|
377
317
|
super(loc: loc, comments: comments)
|
378
|
-
@names =
|
318
|
+
@names = [name, *names] #: Array[Symbol]
|
379
319
|
@visibility = visibility
|
380
320
|
@sigs = sigs
|
381
321
|
end
|
@@ -385,31 +325,21 @@ module RBI
|
|
385
325
|
end
|
386
326
|
|
387
327
|
class AttrAccessor < Attr
|
388
|
-
|
389
|
-
|
390
|
-
sig do
|
391
|
-
params(
|
392
|
-
name: Symbol,
|
393
|
-
names: Symbol,
|
394
|
-
visibility: Visibility,
|
395
|
-
sigs: T::Array[Sig],
|
396
|
-
loc: T.nilable(Loc),
|
397
|
-
comments: T::Array[Comment],
|
398
|
-
block: T.nilable(T.proc.params(node: AttrAccessor).void),
|
399
|
-
).void
|
400
|
-
end
|
328
|
+
#: (Symbol name, *Symbol names, ?visibility: Visibility, ?sigs: Array[Sig], ?loc: Loc?, ?comments: Array[Comment]) ?{ (AttrAccessor node) -> void } -> void
|
401
329
|
def initialize(name, *names, visibility: Public.new, sigs: [], loc: nil, comments: [], &block)
|
402
330
|
super(name, names, loc: loc, visibility: visibility, sigs: sigs, comments: comments)
|
403
331
|
block&.call(self)
|
404
332
|
end
|
405
333
|
|
406
|
-
|
334
|
+
# @override
|
335
|
+
#: -> Array[String]
|
407
336
|
def fully_qualified_names
|
408
337
|
parent_name = parent_scope&.fully_qualified_name
|
409
338
|
names.flat_map { |name| ["#{parent_name}##{name}", "#{parent_name}##{name}="] }
|
410
339
|
end
|
411
340
|
|
412
|
-
|
341
|
+
# @override
|
342
|
+
#: -> String
|
413
343
|
def to_s
|
414
344
|
symbols = names.map { |name| ":#{name}" }.join(", ")
|
415
345
|
"#{parent_scope&.fully_qualified_name}.attr_accessor(#{symbols})"
|
@@ -417,31 +347,21 @@ module RBI
|
|
417
347
|
end
|
418
348
|
|
419
349
|
class AttrReader < Attr
|
420
|
-
|
421
|
-
|
422
|
-
sig do
|
423
|
-
params(
|
424
|
-
name: Symbol,
|
425
|
-
names: Symbol,
|
426
|
-
visibility: Visibility,
|
427
|
-
sigs: T::Array[Sig],
|
428
|
-
loc: T.nilable(Loc),
|
429
|
-
comments: T::Array[Comment],
|
430
|
-
block: T.nilable(T.proc.params(node: AttrReader).void),
|
431
|
-
).void
|
432
|
-
end
|
350
|
+
#: (Symbol name, *Symbol names, ?visibility: Visibility, ?sigs: Array[Sig], ?loc: Loc?, ?comments: Array[Comment]) ?{ (AttrReader node) -> void } -> void
|
433
351
|
def initialize(name, *names, visibility: Public.new, sigs: [], loc: nil, comments: [], &block)
|
434
352
|
super(name, names, loc: loc, visibility: visibility, sigs: sigs, comments: comments)
|
435
353
|
block&.call(self)
|
436
354
|
end
|
437
355
|
|
438
|
-
|
356
|
+
# @override
|
357
|
+
#: -> Array[String]
|
439
358
|
def fully_qualified_names
|
440
359
|
parent_name = parent_scope&.fully_qualified_name
|
441
360
|
names.map { |name| "#{parent_name}##{name}" }
|
442
361
|
end
|
443
362
|
|
444
|
-
|
363
|
+
# @override
|
364
|
+
#: -> String
|
445
365
|
def to_s
|
446
366
|
symbols = names.map { |name| ":#{name}" }.join(", ")
|
447
367
|
"#{parent_scope&.fully_qualified_name}.attr_reader(#{symbols})"
|
@@ -449,31 +369,21 @@ module RBI
|
|
449
369
|
end
|
450
370
|
|
451
371
|
class AttrWriter < Attr
|
452
|
-
|
453
|
-
|
454
|
-
sig do
|
455
|
-
params(
|
456
|
-
name: Symbol,
|
457
|
-
names: Symbol,
|
458
|
-
visibility: Visibility,
|
459
|
-
sigs: T::Array[Sig],
|
460
|
-
loc: T.nilable(Loc),
|
461
|
-
comments: T::Array[Comment],
|
462
|
-
block: T.nilable(T.proc.params(node: AttrWriter).void),
|
463
|
-
).void
|
464
|
-
end
|
372
|
+
#: (Symbol name, *Symbol names, ?visibility: Visibility, ?sigs: Array[Sig], ?loc: Loc?, ?comments: Array[Comment]) ?{ (AttrWriter node) -> void } -> void
|
465
373
|
def initialize(name, *names, visibility: Public.new, sigs: [], loc: nil, comments: [], &block)
|
466
374
|
super(name, names, loc: loc, visibility: visibility, sigs: sigs, comments: comments)
|
467
375
|
block&.call(self)
|
468
376
|
end
|
469
377
|
|
470
|
-
|
378
|
+
# @override
|
379
|
+
#: -> Array[String]
|
471
380
|
def fully_qualified_names
|
472
381
|
parent_name = parent_scope&.fully_qualified_name
|
473
382
|
names.map { |name| "#{parent_name}##{name}=" }
|
474
383
|
end
|
475
384
|
|
476
|
-
|
385
|
+
# @override
|
386
|
+
#: -> String
|
477
387
|
def to_s
|
478
388
|
symbols = names.map { |name| ":#{name}" }.join(", ")
|
479
389
|
"#{parent_scope&.fully_qualified_name}.attr_writer(#{symbols})"
|
@@ -483,35 +393,22 @@ module RBI
|
|
483
393
|
# Methods and args
|
484
394
|
|
485
395
|
class Method < NodeWithComments
|
486
|
-
|
487
|
-
|
488
|
-
sig { returns(String) }
|
396
|
+
#: String
|
489
397
|
attr_accessor :name
|
490
398
|
|
491
|
-
|
399
|
+
#: Array[Param]
|
492
400
|
attr_reader :params
|
493
401
|
|
494
|
-
|
402
|
+
#: bool
|
495
403
|
attr_accessor :is_singleton
|
496
404
|
|
497
|
-
|
405
|
+
#: Visibility
|
498
406
|
attr_accessor :visibility
|
499
407
|
|
500
|
-
|
408
|
+
#: Array[Sig]
|
501
409
|
attr_accessor :sigs
|
502
410
|
|
503
|
-
|
504
|
-
params(
|
505
|
-
name: String,
|
506
|
-
params: T::Array[Param],
|
507
|
-
is_singleton: T::Boolean,
|
508
|
-
visibility: Visibility,
|
509
|
-
sigs: T::Array[Sig],
|
510
|
-
loc: T.nilable(Loc),
|
511
|
-
comments: T::Array[Comment],
|
512
|
-
block: T.nilable(T.proc.params(node: Method).void),
|
513
|
-
).void
|
514
|
-
end
|
411
|
+
#: (String name, ?params: Array[Param], ?is_singleton: bool, ?visibility: Visibility, ?sigs: Array[Sig], ?loc: Loc?, ?comments: Array[Comment]) ?{ (Method node) -> void } -> void
|
515
412
|
def initialize(
|
516
413
|
name,
|
517
414
|
params: [],
|
@@ -531,59 +428,47 @@ module RBI
|
|
531
428
|
block&.call(self)
|
532
429
|
end
|
533
430
|
|
534
|
-
|
431
|
+
#: (Param param) -> void
|
535
432
|
def <<(param)
|
536
433
|
@params << param
|
537
434
|
end
|
538
435
|
|
539
|
-
|
436
|
+
#: (String name) -> void
|
540
437
|
def add_param(name)
|
541
438
|
@params << ReqParam.new(name)
|
542
439
|
end
|
543
440
|
|
544
|
-
|
441
|
+
#: (String name, String default_value) -> void
|
545
442
|
def add_opt_param(name, default_value)
|
546
443
|
@params << OptParam.new(name, default_value)
|
547
444
|
end
|
548
445
|
|
549
|
-
|
446
|
+
#: (String name) -> void
|
550
447
|
def add_rest_param(name)
|
551
448
|
@params << RestParam.new(name)
|
552
449
|
end
|
553
450
|
|
554
|
-
|
451
|
+
#: (String name) -> void
|
555
452
|
def add_kw_param(name)
|
556
453
|
@params << KwParam.new(name)
|
557
454
|
end
|
558
455
|
|
559
|
-
|
456
|
+
#: (String name, String default_value) -> void
|
560
457
|
def add_kw_opt_param(name, default_value)
|
561
458
|
@params << KwOptParam.new(name, default_value)
|
562
459
|
end
|
563
460
|
|
564
|
-
|
461
|
+
#: (String name) -> void
|
565
462
|
def add_kw_rest_param(name)
|
566
463
|
@params << KwRestParam.new(name)
|
567
464
|
end
|
568
465
|
|
569
|
-
|
466
|
+
#: (String name) -> void
|
570
467
|
def add_block_param(name)
|
571
468
|
@params << BlockParam.new(name)
|
572
469
|
end
|
573
470
|
|
574
|
-
|
575
|
-
params(
|
576
|
-
params: T::Array[SigParam],
|
577
|
-
return_type: T.any(String, Type),
|
578
|
-
is_abstract: T::Boolean,
|
579
|
-
is_override: T::Boolean,
|
580
|
-
is_overridable: T::Boolean,
|
581
|
-
is_final: T::Boolean,
|
582
|
-
type_params: T::Array[String],
|
583
|
-
checked: T.nilable(Symbol),
|
584
|
-
block: T.nilable(T.proc.params(node: Sig).void),
|
585
|
-
).void
|
586
|
-
end
|
471
|
+
#: (?params: Array[SigParam], ?return_type: (String | Type), ?is_abstract: bool, ?is_override: bool, ?is_overridable: bool, ?is_final: bool, ?type_params: Array[String], ?checked: Symbol?) ?{ (Sig node) -> void } -> void
|
587
472
|
def add_sig(
|
588
473
|
params: [],
|
589
474
|
return_type: "void",
|
@@ -609,7 +494,7 @@ module RBI
|
|
609
494
|
@sigs << sig
|
610
495
|
end
|
611
496
|
|
612
|
-
|
497
|
+
#: -> String
|
613
498
|
def fully_qualified_name
|
614
499
|
if is_singleton
|
615
500
|
"#{parent_scope&.fully_qualified_name}::#{name}"
|
@@ -618,7 +503,8 @@ module RBI
|
|
618
503
|
end
|
619
504
|
end
|
620
505
|
|
621
|
-
|
506
|
+
# @override
|
507
|
+
#: -> String
|
622
508
|
def to_s
|
623
509
|
"#{fully_qualified_name}(#{params.join(", ")})"
|
624
510
|
end
|
@@ -626,215 +512,149 @@ module RBI
|
|
626
512
|
|
627
513
|
class Param < NodeWithComments
|
628
514
|
extend T::Helpers
|
629
|
-
extend T::Sig
|
630
515
|
|
631
516
|
abstract!
|
632
517
|
|
633
|
-
|
518
|
+
#: String
|
634
519
|
attr_reader :name
|
635
520
|
|
636
|
-
|
637
|
-
params(
|
638
|
-
name: String,
|
639
|
-
loc: T.nilable(Loc),
|
640
|
-
comments: T::Array[Comment],
|
641
|
-
).void
|
642
|
-
end
|
521
|
+
#: (String name, ?loc: Loc?, ?comments: Array[Comment]) -> void
|
643
522
|
def initialize(name, loc: nil, comments: [])
|
644
523
|
super(loc: loc, comments: comments)
|
645
524
|
@name = name
|
646
525
|
end
|
647
526
|
|
648
|
-
|
527
|
+
# @override
|
528
|
+
#: -> String
|
649
529
|
def to_s
|
650
530
|
name
|
651
531
|
end
|
652
532
|
end
|
653
533
|
|
654
534
|
class ReqParam < Param
|
655
|
-
|
656
|
-
|
657
|
-
sig do
|
658
|
-
params(
|
659
|
-
name: String,
|
660
|
-
loc: T.nilable(Loc),
|
661
|
-
comments: T::Array[Comment],
|
662
|
-
block: T.nilable(T.proc.params(node: ReqParam).void),
|
663
|
-
).void
|
664
|
-
end
|
535
|
+
#: (String name, ?loc: Loc?, ?comments: Array[Comment]) ?{ (ReqParam node) -> void } -> void
|
665
536
|
def initialize(name, loc: nil, comments: [], &block)
|
666
537
|
super(name, loc: loc, comments: comments)
|
667
538
|
block&.call(self)
|
668
539
|
end
|
669
540
|
|
670
|
-
|
541
|
+
#: (Object? other) -> bool
|
671
542
|
def ==(other)
|
672
543
|
ReqParam === other && name == other.name
|
673
544
|
end
|
674
545
|
end
|
675
546
|
|
676
547
|
class OptParam < Param
|
677
|
-
|
678
|
-
|
679
|
-
sig { returns(String) }
|
548
|
+
#: String
|
680
549
|
attr_reader :value
|
681
550
|
|
682
|
-
|
683
|
-
params(
|
684
|
-
name: String,
|
685
|
-
value: String,
|
686
|
-
loc: T.nilable(Loc),
|
687
|
-
comments: T::Array[Comment],
|
688
|
-
block: T.nilable(T.proc.params(node: OptParam).void),
|
689
|
-
).void
|
690
|
-
end
|
551
|
+
#: (String name, String value, ?loc: Loc?, ?comments: Array[Comment]) ?{ (OptParam node) -> void } -> void
|
691
552
|
def initialize(name, value, loc: nil, comments: [], &block)
|
692
553
|
super(name, loc: loc, comments: comments)
|
693
554
|
@value = value
|
694
555
|
block&.call(self)
|
695
556
|
end
|
696
557
|
|
697
|
-
|
558
|
+
#: (Object? other) -> bool
|
698
559
|
def ==(other)
|
699
560
|
OptParam === other && name == other.name
|
700
561
|
end
|
701
562
|
end
|
702
563
|
|
703
564
|
class RestParam < Param
|
704
|
-
|
705
|
-
|
706
|
-
sig do
|
707
|
-
params(
|
708
|
-
name: String,
|
709
|
-
loc: T.nilable(Loc),
|
710
|
-
comments: T::Array[Comment],
|
711
|
-
block: T.nilable(T.proc.params(node: RestParam).void),
|
712
|
-
).void
|
713
|
-
end
|
565
|
+
#: (String name, ?loc: Loc?, ?comments: Array[Comment]) ?{ (RestParam node) -> void } -> void
|
714
566
|
def initialize(name, loc: nil, comments: [], &block)
|
715
567
|
super(name, loc: loc, comments: comments)
|
716
568
|
block&.call(self)
|
717
569
|
end
|
718
570
|
|
719
|
-
|
571
|
+
# @override
|
572
|
+
#: -> String
|
720
573
|
def to_s
|
721
574
|
"*#{name}"
|
722
575
|
end
|
723
576
|
|
724
|
-
|
577
|
+
#: (Object? other) -> bool
|
725
578
|
def ==(other)
|
726
579
|
RestParam === other && name == other.name
|
727
580
|
end
|
728
581
|
end
|
729
582
|
|
730
583
|
class KwParam < Param
|
731
|
-
|
732
|
-
|
733
|
-
sig do
|
734
|
-
params(
|
735
|
-
name: String,
|
736
|
-
loc: T.nilable(Loc),
|
737
|
-
comments: T::Array[Comment],
|
738
|
-
block: T.nilable(T.proc.params(node: KwParam).void),
|
739
|
-
).void
|
740
|
-
end
|
584
|
+
#: (String name, ?loc: Loc?, ?comments: Array[Comment]) ?{ (KwParam node) -> void } -> void
|
741
585
|
def initialize(name, loc: nil, comments: [], &block)
|
742
586
|
super(name, loc: loc, comments: comments)
|
743
587
|
block&.call(self)
|
744
588
|
end
|
745
589
|
|
746
|
-
|
590
|
+
# @override
|
591
|
+
#: -> String
|
747
592
|
def to_s
|
748
593
|
"#{name}:"
|
749
594
|
end
|
750
595
|
|
751
|
-
|
596
|
+
#: (Object? other) -> bool
|
752
597
|
def ==(other)
|
753
598
|
KwParam === other && name == other.name
|
754
599
|
end
|
755
600
|
end
|
756
601
|
|
757
602
|
class KwOptParam < Param
|
758
|
-
|
759
|
-
|
760
|
-
sig { returns(String) }
|
603
|
+
#: String
|
761
604
|
attr_reader :value
|
762
605
|
|
763
|
-
|
764
|
-
params(
|
765
|
-
name: String,
|
766
|
-
value: String,
|
767
|
-
loc: T.nilable(Loc),
|
768
|
-
comments: T::Array[Comment],
|
769
|
-
block: T.nilable(T.proc.params(node: KwOptParam).void),
|
770
|
-
).void
|
771
|
-
end
|
606
|
+
#: (String name, String value, ?loc: Loc?, ?comments: Array[Comment]) ?{ (KwOptParam node) -> void } -> void
|
772
607
|
def initialize(name, value, loc: nil, comments: [], &block)
|
773
608
|
super(name, loc: loc, comments: comments)
|
774
609
|
@value = value
|
775
610
|
block&.call(self)
|
776
611
|
end
|
777
612
|
|
778
|
-
|
613
|
+
# @override
|
614
|
+
#: -> String
|
779
615
|
def to_s
|
780
616
|
"#{name}:"
|
781
617
|
end
|
782
618
|
|
783
|
-
|
619
|
+
#: (Object? other) -> bool
|
784
620
|
def ==(other)
|
785
621
|
KwOptParam === other && name == other.name
|
786
622
|
end
|
787
623
|
end
|
788
624
|
|
789
625
|
class KwRestParam < Param
|
790
|
-
|
791
|
-
|
792
|
-
sig do
|
793
|
-
params(
|
794
|
-
name: String,
|
795
|
-
loc: T.nilable(Loc),
|
796
|
-
comments: T::Array[Comment],
|
797
|
-
block: T.nilable(T.proc.params(node: KwRestParam).void),
|
798
|
-
).void
|
799
|
-
end
|
626
|
+
#: (String name, ?loc: Loc?, ?comments: Array[Comment]) ?{ (KwRestParam node) -> void } -> void
|
800
627
|
def initialize(name, loc: nil, comments: [], &block)
|
801
628
|
super(name, loc: loc, comments: comments)
|
802
629
|
block&.call(self)
|
803
630
|
end
|
804
631
|
|
805
|
-
|
632
|
+
# @override
|
633
|
+
#: -> String
|
806
634
|
def to_s
|
807
635
|
"**#{name}:"
|
808
636
|
end
|
809
637
|
|
810
|
-
|
638
|
+
#: (Object? other) -> bool
|
811
639
|
def ==(other)
|
812
640
|
KwRestParam === other && name == other.name
|
813
641
|
end
|
814
642
|
end
|
815
643
|
|
816
644
|
class BlockParam < Param
|
817
|
-
|
818
|
-
|
819
|
-
sig do
|
820
|
-
params(
|
821
|
-
name: String,
|
822
|
-
loc: T.nilable(Loc),
|
823
|
-
comments: T::Array[Comment],
|
824
|
-
block: T.nilable(T.proc.params(node: BlockParam).void),
|
825
|
-
).void
|
826
|
-
end
|
645
|
+
#: (String name, ?loc: Loc?, ?comments: Array[Comment]) ?{ (BlockParam node) -> void } -> void
|
827
646
|
def initialize(name, loc: nil, comments: [], &block)
|
828
647
|
super(name, loc: loc, comments: comments)
|
829
648
|
block&.call(self)
|
830
649
|
end
|
831
650
|
|
832
|
-
|
651
|
+
# @override
|
652
|
+
#: -> String
|
833
653
|
def to_s
|
834
654
|
"&#{name}"
|
835
655
|
end
|
836
656
|
|
837
|
-
|
657
|
+
#: (Object? other) -> bool
|
838
658
|
def ==(other)
|
839
659
|
BlockParam === other && name == other.name
|
840
660
|
end
|
@@ -843,69 +663,43 @@ module RBI
|
|
843
663
|
# Mixins
|
844
664
|
|
845
665
|
class Mixin < NodeWithComments
|
846
|
-
extend T::Sig
|
847
666
|
extend T::Helpers
|
848
667
|
|
849
668
|
abstract!
|
850
669
|
|
851
|
-
|
670
|
+
#: Array[String]
|
852
671
|
attr_reader :names
|
853
672
|
|
854
|
-
|
855
|
-
params(
|
856
|
-
name: String,
|
857
|
-
names: T::Array[String],
|
858
|
-
loc: T.nilable(Loc),
|
859
|
-
comments: T::Array[Comment],
|
860
|
-
).void
|
861
|
-
end
|
673
|
+
#: (String name, Array[String] names, ?loc: Loc?, ?comments: Array[Comment]) -> void
|
862
674
|
def initialize(name, names, loc: nil, comments: [])
|
863
675
|
super(loc: loc, comments: comments)
|
864
|
-
@names =
|
676
|
+
@names = [name, *names] #: Array[String]
|
865
677
|
end
|
866
678
|
end
|
867
679
|
|
868
680
|
class Include < Mixin
|
869
|
-
|
870
|
-
|
871
|
-
sig do
|
872
|
-
params(
|
873
|
-
name: String,
|
874
|
-
names: String,
|
875
|
-
loc: T.nilable(Loc),
|
876
|
-
comments: T::Array[Comment],
|
877
|
-
block: T.nilable(T.proc.params(node: Include).void),
|
878
|
-
).void
|
879
|
-
end
|
681
|
+
#: (String name, *String names, ?loc: Loc?, ?comments: Array[Comment]) ?{ (Include node) -> void } -> void
|
880
682
|
def initialize(name, *names, loc: nil, comments: [], &block)
|
881
683
|
super(name, names, loc: loc, comments: comments)
|
882
684
|
block&.call(self)
|
883
685
|
end
|
884
686
|
|
885
|
-
|
687
|
+
# @override
|
688
|
+
#: -> String
|
886
689
|
def to_s
|
887
690
|
"#{parent_scope&.fully_qualified_name}.include(#{names.join(", ")})"
|
888
691
|
end
|
889
692
|
end
|
890
693
|
|
891
694
|
class Extend < Mixin
|
892
|
-
|
893
|
-
|
894
|
-
sig do
|
895
|
-
params(
|
896
|
-
name: String,
|
897
|
-
names: String,
|
898
|
-
loc: T.nilable(Loc),
|
899
|
-
comments: T::Array[Comment],
|
900
|
-
block: T.nilable(T.proc.params(node: Extend).void),
|
901
|
-
).void
|
902
|
-
end
|
695
|
+
#: (String name, *String names, ?loc: Loc?, ?comments: Array[Comment]) ?{ (Extend node) -> void } -> void
|
903
696
|
def initialize(name, *names, loc: nil, comments: [], &block)
|
904
697
|
super(name, names, loc: loc, comments: comments)
|
905
698
|
block&.call(self)
|
906
699
|
end
|
907
700
|
|
908
|
-
|
701
|
+
# @override
|
702
|
+
#: -> String
|
909
703
|
def to_s
|
910
704
|
"#{parent_scope&.fully_qualified_name}.extend(#{names.join(", ")})"
|
911
705
|
end
|
@@ -914,53 +708,44 @@ module RBI
|
|
914
708
|
# Visibility
|
915
709
|
|
916
710
|
class Visibility < NodeWithComments
|
917
|
-
extend T::Sig
|
918
711
|
extend T::Helpers
|
919
712
|
|
920
713
|
abstract!
|
921
714
|
|
922
|
-
|
715
|
+
#: Symbol
|
923
716
|
attr_reader :visibility
|
924
717
|
|
925
|
-
|
718
|
+
#: (Symbol visibility, ?loc: Loc?, ?comments: Array[Comment]) -> void
|
926
719
|
def initialize(visibility, loc: nil, comments: [])
|
927
720
|
super(loc: loc, comments: comments)
|
928
721
|
@visibility = visibility
|
929
722
|
end
|
930
723
|
|
931
|
-
|
724
|
+
#: (Object? other) -> bool
|
932
725
|
def ==(other)
|
933
726
|
return false unless other.is_a?(Visibility)
|
934
727
|
|
935
728
|
visibility == other.visibility
|
936
729
|
end
|
937
730
|
|
938
|
-
|
731
|
+
#: -> bool
|
939
732
|
def public?
|
940
733
|
visibility == :public
|
941
734
|
end
|
942
735
|
|
943
|
-
|
736
|
+
#: -> bool
|
944
737
|
def protected?
|
945
738
|
visibility == :protected
|
946
739
|
end
|
947
740
|
|
948
|
-
|
741
|
+
#: -> bool
|
949
742
|
def private?
|
950
743
|
visibility == :private
|
951
744
|
end
|
952
745
|
end
|
953
746
|
|
954
747
|
class Public < Visibility
|
955
|
-
|
956
|
-
|
957
|
-
sig do
|
958
|
-
params(
|
959
|
-
loc: T.nilable(Loc),
|
960
|
-
comments: T::Array[Comment],
|
961
|
-
block: T.nilable(T.proc.params(node: Public).void),
|
962
|
-
).void
|
963
|
-
end
|
748
|
+
#: (?loc: Loc?, ?comments: Array[Comment]) ?{ (Public node) -> void } -> void
|
964
749
|
def initialize(loc: nil, comments: [], &block)
|
965
750
|
super(:public, loc: loc, comments: comments)
|
966
751
|
block&.call(self)
|
@@ -968,15 +753,7 @@ module RBI
|
|
968
753
|
end
|
969
754
|
|
970
755
|
class Protected < Visibility
|
971
|
-
|
972
|
-
|
973
|
-
sig do
|
974
|
-
params(
|
975
|
-
loc: T.nilable(Loc),
|
976
|
-
comments: T::Array[Comment],
|
977
|
-
block: T.nilable(T.proc.params(node: Protected).void),
|
978
|
-
).void
|
979
|
-
end
|
756
|
+
#: (?loc: Loc?, ?comments: Array[Comment]) ?{ (Protected node) -> void } -> void
|
980
757
|
def initialize(loc: nil, comments: [], &block)
|
981
758
|
super(:protected, loc: loc, comments: comments)
|
982
759
|
block&.call(self)
|
@@ -984,15 +761,7 @@ module RBI
|
|
984
761
|
end
|
985
762
|
|
986
763
|
class Private < Visibility
|
987
|
-
|
988
|
-
|
989
|
-
sig do
|
990
|
-
params(
|
991
|
-
loc: T.nilable(Loc),
|
992
|
-
comments: T::Array[Comment],
|
993
|
-
block: T.nilable(T.proc.params(node: Private).void),
|
994
|
-
).void
|
995
|
-
end
|
764
|
+
#: (?loc: Loc?, ?comments: Array[Comment]) ?{ (Private node) -> void } -> void
|
996
765
|
def initialize(loc: nil, comments: [], &block)
|
997
766
|
super(:private, loc: loc, comments: comments)
|
998
767
|
block&.call(self)
|
@@ -1002,23 +771,13 @@ module RBI
|
|
1002
771
|
# Sends
|
1003
772
|
|
1004
773
|
class Send < NodeWithComments
|
1005
|
-
|
1006
|
-
|
1007
|
-
sig { returns(String) }
|
774
|
+
#: String
|
1008
775
|
attr_reader :method
|
1009
776
|
|
1010
|
-
|
777
|
+
#: Array[Arg]
|
1011
778
|
attr_reader :args
|
1012
779
|
|
1013
|
-
|
1014
|
-
params(
|
1015
|
-
method: String,
|
1016
|
-
args: T::Array[Arg],
|
1017
|
-
loc: T.nilable(Loc),
|
1018
|
-
comments: T::Array[Comment],
|
1019
|
-
block: T.nilable(T.proc.params(node: Send).void),
|
1020
|
-
).void
|
1021
|
-
end
|
780
|
+
#: (String method, ?Array[Arg] args, ?loc: Loc?, ?comments: Array[Comment]) ?{ (Send node) -> void } -> void
|
1022
781
|
def initialize(method, args = [], loc: nil, comments: [], &block)
|
1023
782
|
super(loc: loc, comments: comments)
|
1024
783
|
@method = method
|
@@ -1026,74 +785,59 @@ module RBI
|
|
1026
785
|
block&.call(self)
|
1027
786
|
end
|
1028
787
|
|
1029
|
-
|
788
|
+
#: (Arg arg) -> void
|
1030
789
|
def <<(arg)
|
1031
790
|
@args << arg
|
1032
791
|
end
|
1033
792
|
|
1034
|
-
|
793
|
+
#: (Object? other) -> bool
|
1035
794
|
def ==(other)
|
1036
795
|
Send === other && method == other.method && args == other.args
|
1037
796
|
end
|
1038
797
|
|
1039
|
-
|
798
|
+
#: -> String
|
1040
799
|
def to_s
|
1041
800
|
"#{parent_scope&.fully_qualified_name}.#{method}(#{args.join(", ")})"
|
1042
801
|
end
|
1043
802
|
end
|
1044
803
|
|
1045
804
|
class Arg < Node
|
1046
|
-
|
1047
|
-
|
1048
|
-
sig { returns(String) }
|
805
|
+
#: String
|
1049
806
|
attr_reader :value
|
1050
807
|
|
1051
|
-
|
1052
|
-
params(
|
1053
|
-
value: String,
|
1054
|
-
loc: T.nilable(Loc),
|
1055
|
-
).void
|
1056
|
-
end
|
808
|
+
#: (String value, ?loc: Loc?) -> void
|
1057
809
|
def initialize(value, loc: nil)
|
1058
810
|
super(loc: loc)
|
1059
811
|
@value = value
|
1060
812
|
end
|
1061
813
|
|
1062
|
-
|
814
|
+
#: (Object? other) -> bool
|
1063
815
|
def ==(other)
|
1064
816
|
Arg === other && value == other.value
|
1065
817
|
end
|
1066
818
|
|
1067
|
-
|
819
|
+
#: -> String
|
1068
820
|
def to_s
|
1069
821
|
value
|
1070
822
|
end
|
1071
823
|
end
|
1072
824
|
|
1073
825
|
class KwArg < Arg
|
1074
|
-
|
1075
|
-
|
1076
|
-
sig { returns(String) }
|
826
|
+
#: String
|
1077
827
|
attr_reader :keyword
|
1078
828
|
|
1079
|
-
|
1080
|
-
params(
|
1081
|
-
keyword: String,
|
1082
|
-
value: String,
|
1083
|
-
loc: T.nilable(Loc),
|
1084
|
-
).void
|
1085
|
-
end
|
829
|
+
#: (String keyword, String value, ?loc: Loc?) -> void
|
1086
830
|
def initialize(keyword, value, loc: nil)
|
1087
831
|
super(value, loc: loc)
|
1088
832
|
@keyword = keyword
|
1089
833
|
end
|
1090
834
|
|
1091
|
-
|
835
|
+
#: (Object? other) -> bool
|
1092
836
|
def ==(other)
|
1093
837
|
KwArg === other && value == other.value && keyword == other.keyword
|
1094
838
|
end
|
1095
839
|
|
1096
|
-
|
840
|
+
#: -> String
|
1097
841
|
def to_s
|
1098
842
|
"#{keyword}: #{value}"
|
1099
843
|
end
|
@@ -1102,38 +846,22 @@ module RBI
|
|
1102
846
|
# Sorbet's sigs
|
1103
847
|
|
1104
848
|
class Sig < NodeWithComments
|
1105
|
-
|
1106
|
-
|
1107
|
-
sig { returns(T::Array[SigParam]) }
|
849
|
+
#: Array[SigParam]
|
1108
850
|
attr_reader :params
|
1109
851
|
|
1110
|
-
|
852
|
+
#: (Type | String)
|
1111
853
|
attr_accessor :return_type
|
1112
854
|
|
1113
|
-
|
1114
|
-
attr_accessor :is_abstract, :is_override, :is_overridable, :is_final
|
855
|
+
#: bool
|
856
|
+
attr_accessor :is_abstract, :is_override, :is_overridable, :is_final, :allow_incompatible_override, :without_runtime
|
1115
857
|
|
1116
|
-
|
858
|
+
#: Array[String]
|
1117
859
|
attr_reader :type_params
|
1118
860
|
|
1119
|
-
|
861
|
+
#: Symbol?
|
1120
862
|
attr_accessor :checked
|
1121
863
|
|
1122
|
-
|
1123
|
-
params(
|
1124
|
-
params: T::Array[SigParam],
|
1125
|
-
return_type: T.any(Type, String),
|
1126
|
-
is_abstract: T::Boolean,
|
1127
|
-
is_override: T::Boolean,
|
1128
|
-
is_overridable: T::Boolean,
|
1129
|
-
is_final: T::Boolean,
|
1130
|
-
type_params: T::Array[String],
|
1131
|
-
checked: T.nilable(Symbol),
|
1132
|
-
loc: T.nilable(Loc),
|
1133
|
-
comments: T::Array[Comment],
|
1134
|
-
block: T.nilable(T.proc.params(node: Sig).void),
|
1135
|
-
).void
|
1136
|
-
end
|
864
|
+
#: (?params: Array[SigParam], ?return_type: (Type | String), ?is_abstract: bool, ?is_override: bool, ?is_overridable: bool, ?is_final: bool, ?allow_incompatible_override: bool, ?without_runtime: bool, ?type_params: Array[String], ?checked: Symbol?, ?loc: Loc?, ?comments: Array[Comment]) ?{ (Sig node) -> void } -> void
|
1137
865
|
def initialize(
|
1138
866
|
params: [],
|
1139
867
|
return_type: "void",
|
@@ -1141,6 +869,8 @@ module RBI
|
|
1141
869
|
is_override: false,
|
1142
870
|
is_overridable: false,
|
1143
871
|
is_final: false,
|
872
|
+
allow_incompatible_override: false,
|
873
|
+
without_runtime: false,
|
1144
874
|
type_params: [],
|
1145
875
|
checked: nil,
|
1146
876
|
loc: nil,
|
@@ -1154,49 +884,41 @@ module RBI
|
|
1154
884
|
@is_override = is_override
|
1155
885
|
@is_overridable = is_overridable
|
1156
886
|
@is_final = is_final
|
887
|
+
@allow_incompatible_override = allow_incompatible_override
|
888
|
+
@without_runtime = without_runtime
|
1157
889
|
@type_params = type_params
|
1158
890
|
@checked = checked
|
1159
891
|
block&.call(self)
|
1160
892
|
end
|
1161
893
|
|
1162
|
-
|
894
|
+
#: (SigParam param) -> void
|
1163
895
|
def <<(param)
|
1164
896
|
@params << param
|
1165
897
|
end
|
1166
898
|
|
1167
|
-
|
899
|
+
#: (String name, (Type | String) type) -> void
|
1168
900
|
def add_param(name, type)
|
1169
901
|
@params << SigParam.new(name, type)
|
1170
902
|
end
|
1171
903
|
|
1172
|
-
|
904
|
+
#: (Object other) -> bool
|
1173
905
|
def ==(other)
|
1174
906
|
return false unless other.is_a?(Sig)
|
1175
907
|
|
1176
908
|
params == other.params && return_type.to_s == other.return_type.to_s && is_abstract == other.is_abstract &&
|
1177
909
|
is_override == other.is_override && is_overridable == other.is_overridable && is_final == other.is_final &&
|
1178
|
-
type_params == other.type_params && checked == other.checked
|
910
|
+
without_runtime == other.without_runtime && type_params == other.type_params && checked == other.checked
|
1179
911
|
end
|
1180
912
|
end
|
1181
913
|
|
1182
914
|
class SigParam < NodeWithComments
|
1183
|
-
|
1184
|
-
|
1185
|
-
sig { returns(String) }
|
915
|
+
#: String
|
1186
916
|
attr_reader :name
|
1187
917
|
|
1188
|
-
|
918
|
+
#: (Type | String)
|
1189
919
|
attr_reader :type
|
1190
920
|
|
1191
|
-
|
1192
|
-
params(
|
1193
|
-
name: String,
|
1194
|
-
type: T.any(Type, String),
|
1195
|
-
loc: T.nilable(Loc),
|
1196
|
-
comments: T::Array[Comment],
|
1197
|
-
block: T.nilable(T.proc.params(node: SigParam).void),
|
1198
|
-
).void
|
1199
|
-
end
|
921
|
+
#: (String name, (Type | String) type, ?loc: Loc?, ?comments: Array[Comment]) ?{ (SigParam node) -> void } -> void
|
1200
922
|
def initialize(name, type, loc: nil, comments: [], &block)
|
1201
923
|
super(loc: loc, comments: comments)
|
1202
924
|
@name = name
|
@@ -1204,7 +926,7 @@ module RBI
|
|
1204
926
|
block&.call(self)
|
1205
927
|
end
|
1206
928
|
|
1207
|
-
|
929
|
+
#: (Object other) -> bool
|
1208
930
|
def ==(other)
|
1209
931
|
other.is_a?(SigParam) && name == other.name && type.to_s == other.type.to_s
|
1210
932
|
end
|
@@ -1213,16 +935,7 @@ module RBI
|
|
1213
935
|
# Sorbet's T::Struct
|
1214
936
|
|
1215
937
|
class TStruct < Class
|
1216
|
-
|
1217
|
-
|
1218
|
-
sig do
|
1219
|
-
params(
|
1220
|
-
name: String,
|
1221
|
-
loc: T.nilable(Loc),
|
1222
|
-
comments: T::Array[Comment],
|
1223
|
-
block: T.nilable(T.proc.params(klass: TStruct).void),
|
1224
|
-
).void
|
1225
|
-
end
|
938
|
+
#: (String name, ?loc: Loc?, ?comments: Array[Comment]) ?{ (TStruct klass) -> void } -> void
|
1226
939
|
def initialize(name, loc: nil, comments: [], &block)
|
1227
940
|
super(name, superclass_name: "::T::Struct", loc: loc, comments: comments) {}
|
1228
941
|
block&.call(self)
|
@@ -1235,24 +948,16 @@ module RBI
|
|
1235
948
|
|
1236
949
|
abstract!
|
1237
950
|
|
1238
|
-
|
951
|
+
#: String
|
1239
952
|
attr_accessor :name
|
1240
953
|
|
1241
|
-
|
954
|
+
#: (Type | String)
|
1242
955
|
attr_accessor :type
|
1243
956
|
|
1244
|
-
|
957
|
+
#: String?
|
1245
958
|
attr_accessor :default
|
1246
959
|
|
1247
|
-
|
1248
|
-
params(
|
1249
|
-
name: String,
|
1250
|
-
type: T.any(Type, String),
|
1251
|
-
default: T.nilable(String),
|
1252
|
-
loc: T.nilable(Loc),
|
1253
|
-
comments: T::Array[Comment],
|
1254
|
-
).void
|
1255
|
-
end
|
960
|
+
#: (String name, (Type | String) type, ?default: String?, ?loc: Loc?, ?comments: Array[Comment]) -> void
|
1256
961
|
def initialize(name, type, default: nil, loc: nil, comments: [])
|
1257
962
|
super(loc: loc, comments: comments)
|
1258
963
|
@name = name
|
@@ -1265,60 +970,42 @@ module RBI
|
|
1265
970
|
end
|
1266
971
|
|
1267
972
|
class TStructConst < TStructField
|
1268
|
-
|
1269
|
-
|
1270
|
-
sig do
|
1271
|
-
params(
|
1272
|
-
name: String,
|
1273
|
-
type: T.any(Type, String),
|
1274
|
-
default: T.nilable(String),
|
1275
|
-
loc: T.nilable(Loc),
|
1276
|
-
comments: T::Array[Comment],
|
1277
|
-
block: T.nilable(T.proc.params(node: TStructConst).void),
|
1278
|
-
).void
|
1279
|
-
end
|
973
|
+
#: (String name, (Type | String) type, ?default: String?, ?loc: Loc?, ?comments: Array[Comment]) ?{ (TStructConst node) -> void } -> void
|
1280
974
|
def initialize(name, type, default: nil, loc: nil, comments: [], &block)
|
1281
975
|
super(name, type, default: default, loc: loc, comments: comments)
|
1282
976
|
block&.call(self)
|
1283
977
|
end
|
1284
978
|
|
1285
|
-
|
979
|
+
# @override
|
980
|
+
#: -> Array[String]
|
1286
981
|
def fully_qualified_names
|
1287
982
|
parent_name = parent_scope&.fully_qualified_name
|
1288
983
|
["#{parent_name}##{name}"]
|
1289
984
|
end
|
1290
985
|
|
1291
|
-
|
986
|
+
# @override
|
987
|
+
#: -> String
|
1292
988
|
def to_s
|
1293
989
|
"#{parent_scope&.fully_qualified_name}.const(:#{name})"
|
1294
990
|
end
|
1295
991
|
end
|
1296
992
|
|
1297
993
|
class TStructProp < TStructField
|
1298
|
-
|
1299
|
-
|
1300
|
-
sig do
|
1301
|
-
params(
|
1302
|
-
name: String,
|
1303
|
-
type: T.any(Type, String),
|
1304
|
-
default: T.nilable(String),
|
1305
|
-
loc: T.nilable(Loc),
|
1306
|
-
comments: T::Array[Comment],
|
1307
|
-
block: T.nilable(T.proc.params(node: TStructProp).void),
|
1308
|
-
).void
|
1309
|
-
end
|
994
|
+
#: (String name, (Type | String) type, ?default: String?, ?loc: Loc?, ?comments: Array[Comment]) ?{ (TStructProp node) -> void } -> void
|
1310
995
|
def initialize(name, type, default: nil, loc: nil, comments: [], &block)
|
1311
996
|
super(name, type, default: default, loc: loc, comments: comments)
|
1312
997
|
block&.call(self)
|
1313
998
|
end
|
1314
999
|
|
1315
|
-
|
1000
|
+
# @override
|
1001
|
+
#: -> Array[String]
|
1316
1002
|
def fully_qualified_names
|
1317
1003
|
parent_name = parent_scope&.fully_qualified_name
|
1318
1004
|
["#{parent_name}##{name}", "#{parent_name}##{name}="]
|
1319
1005
|
end
|
1320
1006
|
|
1321
|
-
|
1007
|
+
# @override
|
1008
|
+
#: -> String
|
1322
1009
|
def to_s
|
1323
1010
|
"#{parent_scope&.fully_qualified_name}.prop(:#{name})"
|
1324
1011
|
end
|
@@ -1327,16 +1014,7 @@ module RBI
|
|
1327
1014
|
# Sorbet's T::Enum
|
1328
1015
|
|
1329
1016
|
class TEnum < Class
|
1330
|
-
|
1331
|
-
|
1332
|
-
sig do
|
1333
|
-
params(
|
1334
|
-
name: String,
|
1335
|
-
loc: T.nilable(Loc),
|
1336
|
-
comments: T::Array[Comment],
|
1337
|
-
block: T.nilable(T.proc.params(klass: TEnum).void),
|
1338
|
-
).void
|
1339
|
-
end
|
1017
|
+
#: (String name, ?loc: Loc?, ?comments: Array[Comment]) ?{ (TEnum klass) -> void } -> void
|
1340
1018
|
def initialize(name, loc: nil, comments: [], &block)
|
1341
1019
|
super(name, superclass_name: "::T::Enum", loc: loc, comments: comments) {}
|
1342
1020
|
block&.call(self)
|
@@ -1344,26 +1022,43 @@ module RBI
|
|
1344
1022
|
end
|
1345
1023
|
|
1346
1024
|
class TEnumBlock < Scope
|
1347
|
-
|
1348
|
-
|
1349
|
-
sig do
|
1350
|
-
params(
|
1351
|
-
loc: T.nilable(Loc),
|
1352
|
-
comments: T::Array[Comment],
|
1353
|
-
block: T.nilable(T.proc.params(node: TEnumBlock).void),
|
1354
|
-
).void
|
1355
|
-
end
|
1025
|
+
#: (?loc: Loc?, ?comments: Array[Comment]) ?{ (TEnumBlock node) -> void } -> void
|
1356
1026
|
def initialize(loc: nil, comments: [], &block)
|
1357
|
-
super
|
1027
|
+
super {}
|
1358
1028
|
block&.call(self)
|
1359
1029
|
end
|
1360
1030
|
|
1361
|
-
|
1031
|
+
# @override
|
1032
|
+
#: -> String
|
1362
1033
|
def fully_qualified_name
|
1363
1034
|
"#{parent_scope&.fully_qualified_name}.enums"
|
1364
1035
|
end
|
1365
1036
|
|
1366
|
-
|
1037
|
+
# @override
|
1038
|
+
#: -> String
|
1039
|
+
def to_s
|
1040
|
+
fully_qualified_name
|
1041
|
+
end
|
1042
|
+
end
|
1043
|
+
|
1044
|
+
class TEnumValue < NodeWithComments
|
1045
|
+
#: String
|
1046
|
+
attr_reader :name
|
1047
|
+
|
1048
|
+
#: (String name, ?loc: Loc?, ?comments: Array[Comment]) ?{ (TEnumValue node) -> void } -> void
|
1049
|
+
def initialize(name, loc: nil, comments: [], &block)
|
1050
|
+
super(loc: loc, comments: comments)
|
1051
|
+
@name = name
|
1052
|
+
block&.call(self)
|
1053
|
+
end
|
1054
|
+
|
1055
|
+
#: -> String
|
1056
|
+
def fully_qualified_name
|
1057
|
+
"#{parent_scope&.fully_qualified_name}::#{name}"
|
1058
|
+
end
|
1059
|
+
|
1060
|
+
# @override
|
1061
|
+
#: -> String
|
1367
1062
|
def to_s
|
1368
1063
|
fully_qualified_name
|
1369
1064
|
end
|
@@ -1372,46 +1067,28 @@ module RBI
|
|
1372
1067
|
# Sorbet's misc.
|
1373
1068
|
|
1374
1069
|
class Helper < NodeWithComments
|
1375
|
-
|
1376
|
-
|
1377
|
-
sig { returns(String) }
|
1070
|
+
#: String
|
1378
1071
|
attr_reader :name
|
1379
1072
|
|
1380
|
-
|
1381
|
-
params(
|
1382
|
-
name: String,
|
1383
|
-
loc: T.nilable(Loc),
|
1384
|
-
comments: T::Array[Comment],
|
1385
|
-
block: T.nilable(T.proc.params(node: Helper).void),
|
1386
|
-
).void
|
1387
|
-
end
|
1073
|
+
#: (String name, ?loc: Loc?, ?comments: Array[Comment]) ?{ (Helper node) -> void } -> void
|
1388
1074
|
def initialize(name, loc: nil, comments: [], &block)
|
1389
1075
|
super(loc: loc, comments: comments)
|
1390
1076
|
@name = name
|
1391
1077
|
block&.call(self)
|
1392
1078
|
end
|
1393
1079
|
|
1394
|
-
|
1080
|
+
# @override
|
1081
|
+
#: -> String
|
1395
1082
|
def to_s
|
1396
1083
|
"#{parent_scope&.fully_qualified_name}.#{name}!"
|
1397
1084
|
end
|
1398
1085
|
end
|
1399
1086
|
|
1400
1087
|
class TypeMember < NodeWithComments
|
1401
|
-
|
1402
|
-
|
1403
|
-
sig { returns(String) }
|
1088
|
+
#: String
|
1404
1089
|
attr_reader :name, :value
|
1405
1090
|
|
1406
|
-
|
1407
|
-
params(
|
1408
|
-
name: String,
|
1409
|
-
value: String,
|
1410
|
-
loc: T.nilable(Loc),
|
1411
|
-
comments: T::Array[Comment],
|
1412
|
-
block: T.nilable(T.proc.params(node: TypeMember).void),
|
1413
|
-
).void
|
1414
|
-
end
|
1091
|
+
#: (String name, String value, ?loc: Loc?, ?comments: Array[Comment]) ?{ (TypeMember node) -> void } -> void
|
1415
1092
|
def initialize(name, value, loc: nil, comments: [], &block)
|
1416
1093
|
super(loc: loc, comments: comments)
|
1417
1094
|
@name = name
|
@@ -1419,61 +1096,46 @@ module RBI
|
|
1419
1096
|
block&.call(self)
|
1420
1097
|
end
|
1421
1098
|
|
1422
|
-
|
1099
|
+
#: -> String
|
1423
1100
|
def fully_qualified_name
|
1424
1101
|
return name if name.start_with?("::")
|
1425
1102
|
|
1426
1103
|
"#{parent_scope&.fully_qualified_name}::#{name}"
|
1427
1104
|
end
|
1428
1105
|
|
1429
|
-
|
1106
|
+
# @override
|
1107
|
+
#: -> String
|
1430
1108
|
def to_s
|
1431
1109
|
fully_qualified_name
|
1432
1110
|
end
|
1433
1111
|
end
|
1434
1112
|
|
1435
1113
|
class MixesInClassMethods < Mixin
|
1436
|
-
|
1437
|
-
|
1438
|
-
sig do
|
1439
|
-
params(
|
1440
|
-
name: String,
|
1441
|
-
names: String,
|
1442
|
-
loc: T.nilable(Loc),
|
1443
|
-
comments: T::Array[Comment],
|
1444
|
-
block: T.nilable(T.proc.params(node: MixesInClassMethods).void),
|
1445
|
-
).void
|
1446
|
-
end
|
1114
|
+
#: (String name, *String names, ?loc: Loc?, ?comments: Array[Comment]) ?{ (MixesInClassMethods node) -> void } -> void
|
1447
1115
|
def initialize(name, *names, loc: nil, comments: [], &block)
|
1448
1116
|
super(name, names, loc: loc, comments: comments)
|
1449
1117
|
block&.call(self)
|
1450
1118
|
end
|
1451
1119
|
|
1452
|
-
|
1120
|
+
# @override
|
1121
|
+
#: -> String
|
1453
1122
|
def to_s
|
1454
1123
|
"#{parent_scope&.fully_qualified_name}.mixes_in_class_methods(#{names.join(", ")})"
|
1455
1124
|
end
|
1456
1125
|
end
|
1457
1126
|
|
1458
1127
|
class RequiresAncestor < NodeWithComments
|
1459
|
-
|
1460
|
-
|
1461
|
-
sig { returns(String) }
|
1128
|
+
#: String
|
1462
1129
|
attr_reader :name
|
1463
1130
|
|
1464
|
-
|
1465
|
-
params(
|
1466
|
-
name: String,
|
1467
|
-
loc: T.nilable(Loc),
|
1468
|
-
comments: T::Array[Comment],
|
1469
|
-
).void
|
1470
|
-
end
|
1131
|
+
#: (String name, ?loc: Loc?, ?comments: Array[Comment]) -> void
|
1471
1132
|
def initialize(name, loc: nil, comments: [])
|
1472
1133
|
super(loc: loc, comments: comments)
|
1473
1134
|
@name = name
|
1474
1135
|
end
|
1475
1136
|
|
1476
|
-
|
1137
|
+
# @override
|
1138
|
+
#: -> String
|
1477
1139
|
def to_s
|
1478
1140
|
"#{parent_scope&.fully_qualified_name}.requires_ancestor(#{name})"
|
1479
1141
|
end
|