parlour 3.0.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -83,7 +83,7 @@ module Parlour
83
83
 
84
84
  extend T::Sig
85
85
 
86
- sig { params(ast: Parser::AST::Node, unknown_node_errors: T::Boolean).void }
86
+ sig { params(ast: Parser::AST::Node, unknown_node_errors: T::Boolean, generator: T.nilable(RbiGenerator)).void }
87
87
  # Creates a new {TypeParser} from whitequark/parser AST.
88
88
  #
89
89
  # @param [Parser::AST::Node] The AST.
@@ -92,25 +92,26 @@ module Parlour
92
92
  # if true, a parse error is raised. Setting this to true is likely to
93
93
  # raise errors for lots of non-RBI Ruby code, but setting it to false
94
94
  # could miss genuine typed objects if Parlour or your code contains a bug.
95
- def initialize(ast, unknown_node_errors: false)
95
+ def initialize(ast, unknown_node_errors: false, generator: nil)
96
96
  @ast = ast
97
97
  @unknown_node_errors = unknown_node_errors
98
+ @generator = generator || DetachedRbiGenerator.new
98
99
  end
99
100
 
100
- sig { params(filename: String, source: String).returns(TypeParser) }
101
+ sig { params(filename: String, source: String, generator: T.nilable(RbiGenerator)).returns(TypeParser) }
101
102
  # Creates a new {TypeParser} from a source file and its filename.
102
103
  #
103
104
  # @param [String] filename A filename. This does not need to be an actual
104
105
  # file; it merely identifies this source.
105
106
  # @param [String] source The Ruby source code.
106
107
  # @return [TypeParser]
107
- def self.from_source(filename, source)
108
+ def self.from_source(filename, source, generator: nil)
108
109
  buffer = Parser::Source::Buffer.new(filename)
109
110
  buffer.source = source
110
111
 
111
112
  # || special case handles parser returning nil on an empty file
112
113
  parsed = Parser::CurrentRuby.new.parse(buffer) || Parser::AST::Node.new(:body)
113
- TypeParser.new(parsed)
114
+ TypeParser.new(parsed, generator: generator)
114
115
  end
115
116
 
116
117
  sig { returns(Parser::AST::Node) }
@@ -122,12 +123,16 @@ module Parlour
122
123
  # is encountered.
123
124
  attr_reader :unknown_node_errors
124
125
 
126
+ sig { returns(RbiGenerator) }
127
+ # @return [RbiGenerator] The {RbiGenerator} to load the source into.
128
+ attr_accessor :generator
129
+
125
130
  # Parses the entire source file and returns the resulting root namespace.
126
131
  #
127
132
  # @return [RbiGenerator::Namespace] The root namespace of the parsed source.
128
133
  sig { returns(RbiGenerator::Namespace) }
129
134
  def parse_all
130
- root = RbiGenerator::Namespace.new(DetachedRbiGenerator.new)
135
+ root = generator.root
131
136
  root.children.concat(parse_path_to_object(NodePath.new([])))
132
137
  root
133
138
  end
@@ -162,7 +167,7 @@ module Parlour
162
167
  top_level = T.let(nil, T.nilable(RbiGenerator::Namespace))
163
168
  parent_names.each do |n|
164
169
  new_obj = RbiGenerator::Namespace.new(
165
- DetachedRbiGenerator.new,
170
+ generator,
166
171
  n.to_s,
167
172
  false,
168
173
  )
@@ -225,7 +230,7 @@ module Parlour
225
230
  end
226
231
 
227
232
  final_obj = RbiGenerator::StructClassNamespace.new(
228
- DetachedRbiGenerator.new,
233
+ generator,
229
234
  this_name.to_s,
230
235
  final,
231
236
  props,
@@ -248,7 +253,7 @@ module Parlour
248
253
  end
249
254
 
250
255
  final_obj = RbiGenerator::EnumClassNamespace.new(
251
- DetachedRbiGenerator.new,
256
+ generator,
252
257
  this_name.to_s,
253
258
  final,
254
259
  enums,
@@ -256,7 +261,7 @@ module Parlour
256
261
  )
257
262
  else
258
263
  final_obj = RbiGenerator::ClassNamespace.new(
259
- DetachedRbiGenerator.new,
264
+ generator,
260
265
  this_name.to_s,
261
266
  final,
262
267
  node_to_s(superclass),
@@ -288,7 +293,7 @@ module Parlour
288
293
  top_level = T.let(nil, T.nilable(RbiGenerator::Namespace))
289
294
  parent_names.each do |n|
290
295
  new_obj = RbiGenerator::Namespace.new(
291
- DetachedRbiGenerator.new,
296
+ generator,
292
297
  n.to_s,
293
298
  false,
294
299
  )
@@ -298,7 +303,7 @@ module Parlour
298
303
  end if parent_names
299
304
 
300
305
  final_obj = RbiGenerator::ModuleNamespace.new(
301
- DetachedRbiGenerator.new,
306
+ generator,
302
307
  this_name.to_s,
303
308
  final,
304
309
  interface,
@@ -341,7 +346,7 @@ module Parlour
341
346
  when :casgn
342
347
  _, name, body = *node
343
348
  [Parlour::RbiGenerator::Constant.new(
344
- DetachedRbiGenerator.new,
349
+ generator,
345
350
  name: T.must(name).to_s,
346
351
  value: T.must(node_to_s(body)),
347
352
  )]
@@ -535,7 +540,7 @@ module Parlour
535
540
  # There should only be one ever here, but future-proofing anyway
536
541
  def_names.map do |def_name|
537
542
  RbiGenerator::Method.new(
538
- DetachedRbiGenerator.new,
543
+ generator,
539
544
  def_name,
540
545
  parameters,
541
546
  return_type,
@@ -575,7 +580,7 @@ module Parlour
575
580
 
576
581
  def_names.map do |def_name|
577
582
  RbiGenerator::Attribute.new(
578
- DetachedRbiGenerator.new,
583
+ generator,
579
584
  def_name,
580
585
  attr_direction,
581
586
  attr_type,
@@ -662,7 +667,7 @@ module Parlour
662
667
  # There should only be one ever here, but future-proofing anyway
663
668
  def_names.map do |def_name|
664
669
  RbiGenerator::Method.new(
665
- DetachedRbiGenerator.new,
670
+ generator,
666
671
  def_name,
667
672
  parameters,
668
673
  return_type,
@@ -679,7 +684,7 @@ module Parlour
679
684
 
680
685
  def_names.map do |def_name|
681
686
  RbiGenerator::Attribute.new(
682
- DetachedRbiGenerator.new,
687
+ generator,
683
688
  def_name,
684
689
  attr_direction,
685
690
  attr_type,
@@ -1,5 +1,5 @@
1
1
  # typed: strong
2
2
  module Parlour
3
3
  # The library version.
4
- VERSION = '3.0.0'
4
+ VERSION = '4.0.0'
5
5
  end
@@ -0,0 +1,893 @@
1
+ # typed: strong
2
+ module Kernel
3
+ end
4
+
5
+ module Parlour
6
+ VERSION = '4.0.0'
7
+
8
+ class ConflictResolver
9
+ extend T::Sig
10
+
11
+ sig { params(namespace: RbiGenerator::Namespace, resolver: T.proc.params(
12
+ desc: String,
13
+ choices: T::Array[RbiGenerator::RbiObject]
14
+ ).returns(RbiGenerator::RbiObject)).void }
15
+ def resolve_conflicts(namespace, &resolver); end
16
+
17
+ sig { params(arr: T::Array[T.untyped]).returns(T.nilable(Symbol)) }
18
+ def merge_strategy(arr); end
19
+
20
+ sig { params(arr: T::Array[T.untyped]).returns(T::Boolean) }
21
+ def all_eql?(arr); end
22
+ end
23
+
24
+ module Debugging
25
+ extend T::Sig
26
+
27
+ sig { params(value: T::Boolean).returns(T::Boolean) }
28
+ def self.debug_mode=(value); end
29
+
30
+ sig { returns(T::Boolean) }
31
+ def self.debug_mode?; end
32
+
33
+ sig { params(object: T.untyped, message: String).void }
34
+ def self.debug_puts(object, message); end
35
+
36
+ sig { params(object: T.untyped).returns(String) }
37
+ def self.name_for_debug_caller(object); end
38
+
39
+ module Tree
40
+ extend T::Sig
41
+ INDENT_SPACES = 2
42
+
43
+ sig { params(message: String).returns(String) }
44
+ def self.begin(message); end
45
+
46
+ sig { params(message: String).returns(String) }
47
+ def self.here(message); end
48
+
49
+ sig { params(message: String).returns(String) }
50
+ def self.end(message); end
51
+
52
+ sig { returns(T.untyped) }
53
+ def self.line_prefix; end
54
+
55
+ sig { returns(T.untyped) }
56
+ def self.text_prefix; end
57
+ end
58
+ end
59
+
60
+ class ParseError < StandardError
61
+ extend T::Sig
62
+
63
+ sig { returns(Parser::Source::Buffer) }
64
+ attr_reader :buffer
65
+
66
+ sig { returns(Parser::Source::Range) }
67
+ attr_reader :range
68
+
69
+ sig { params(buffer: T.untyped, range: T.untyped).returns(T.untyped) }
70
+ def initialize(buffer, range); end
71
+ end
72
+
73
+ class Plugin
74
+ abstract!
75
+
76
+ extend T::Sig
77
+ extend T::Helpers
78
+
79
+ sig { returns(T::Hash[String, T.class_of(Plugin)]) }
80
+ def self.registered_plugins; end
81
+
82
+ sig { params(new_plugin: T.class_of(Plugin)).void }
83
+ def self.inherited(new_plugin); end
84
+
85
+ sig { params(plugins: T::Array[Plugin], generator: RbiGenerator, allow_failure: T::Boolean).void }
86
+ def self.run_plugins(plugins, generator, allow_failure: true); end
87
+
88
+ sig { params(options: T::Hash[T.untyped, T.untyped]).void }
89
+ def initialize(options); end
90
+
91
+ sig { abstract.params(root: RbiGenerator::Namespace).void }
92
+ def generate(root); end
93
+
94
+ sig { returns(T.nilable(String)) }
95
+ attr_accessor :strictness
96
+ end
97
+
98
+ module TypeLoader
99
+ extend T::Sig
100
+
101
+ sig { params(source: String, filename: T.nilable(String), generator: T.nilable(RbiGenerator)).returns(RbiGenerator::Namespace) }
102
+ def self.load_source(source, filename = nil, generator: nil); end
103
+
104
+ sig { params(filename: String, generator: T.nilable(RbiGenerator)).returns(RbiGenerator::Namespace) }
105
+ def self.load_file(filename, generator: nil); end
106
+
107
+ sig do
108
+ params(
109
+ root: String,
110
+ inclusions: T::Array[String],
111
+ exclusions: T::Array[String],
112
+ generator: T.nilable(RbiGenerator)
113
+ ).returns(RbiGenerator::Namespace)
114
+ end
115
+ def self.load_project(root, inclusions: ['.'], exclusions: [], generator: nil); end
116
+ end
117
+
118
+ class TypeParser
119
+ extend T::Sig
120
+
121
+ class NodePath
122
+ extend T::Sig
123
+
124
+ sig { returns(T::Array[Integer]) }
125
+ attr_reader :indices
126
+
127
+ sig { params(indices: T::Array[Integer]).void }
128
+ def initialize(indices); end
129
+
130
+ sig { returns(NodePath) }
131
+ def parent; end
132
+
133
+ sig { params(index: Integer).returns(NodePath) }
134
+ def child(index); end
135
+
136
+ sig { params(offset: Integer).returns(NodePath) }
137
+ def sibling(offset); end
138
+
139
+ sig { params(start: Parser::AST::Node).returns(Parser::AST::Node) }
140
+ def traverse(start); end
141
+ end
142
+
143
+ sig { params(ast: Parser::AST::Node, unknown_node_errors: T::Boolean, generator: T.nilable(RbiGenerator)).void }
144
+ def initialize(ast, unknown_node_errors: false, generator: nil); end
145
+
146
+ sig { params(filename: String, source: String, generator: T.nilable(RbiGenerator)).returns(TypeParser) }
147
+ def self.from_source(filename, source, generator: nil); end
148
+
149
+ sig { returns(Parser::AST::Node) }
150
+ attr_accessor :ast
151
+
152
+ sig { returns(T::Boolean) }
153
+ attr_reader :unknown_node_errors
154
+
155
+ sig { returns(RbiGenerator) }
156
+ attr_accessor :generator
157
+
158
+ sig { returns(RbiGenerator::Namespace) }
159
+ def parse_all; end
160
+
161
+ sig { params(path: NodePath, is_within_eigenclass: T::Boolean).returns(T::Array[RbiGenerator::RbiObject]) }
162
+ def parse_path_to_object(path, is_within_eigenclass: false); end
163
+
164
+ class IntermediateSig < T::Struct
165
+ prop :type_parameters, T.nilable(T::Array[Symbol])
166
+ prop :overridable, T::Boolean
167
+ prop :override, T::Boolean
168
+ prop :abstract, T::Boolean
169
+ prop :final, T::Boolean
170
+ prop :return_type, T.nilable(String)
171
+ prop :params, T.nilable(T::Array[Parser::AST::Node])
172
+
173
+ end
174
+
175
+ sig { params(path: NodePath).returns(IntermediateSig) }
176
+ def parse_sig_into_sig(path); end
177
+
178
+ sig { params(path: NodePath, is_within_eigenclass: T::Boolean).returns(T::Array[RbiGenerator::Method]) }
179
+ def parse_sig_into_methods(path, is_within_eigenclass: false); end
180
+
181
+ sig { params(path: NodePath, is_within_eigenclass: T::Boolean).returns(T::Array[RbiGenerator::Method]) }
182
+ def parse_method_into_methods(path, is_within_eigenclass: false); end
183
+
184
+ sig { params(node: T.nilable(Parser::AST::Node)).returns(T::Array[Symbol]) }
185
+ def constant_names(node); end
186
+
187
+ sig { params(node: Parser::AST::Node).returns(T::Boolean) }
188
+ def sig_node?(node); end
189
+
190
+ sig { params(path: NodePath).returns(T::Boolean) }
191
+ def previous_sibling_sig_node?(path); end
192
+
193
+ sig { params(node: T.nilable(Parser::AST::Node)).returns(T.nilable(String)) }
194
+ def node_to_s(node); end
195
+
196
+ sig { params(node: T.nilable(Parser::AST::Node), modifier: Symbol).returns(T::Boolean) }
197
+ def body_has_modifier?(node, modifier); end
198
+
199
+ sig { params(node: Parser::AST::Node).returns([T::Array[String], T::Array[String]]) }
200
+ def body_includes_and_extends(node); end
201
+
202
+ sig { params(desc: String, node: T.any(Parser::AST::Node, NodePath)).returns(T.noreturn) }
203
+ def parse_err(desc, node); end
204
+
205
+ sig do
206
+ type_parameters(:A, :B).params(
207
+ a: T::Array[T.type_parameter(:A)],
208
+ fa: T.proc.params(item: T.type_parameter(:A)).returns(T.untyped),
209
+ b: T::Array[T.type_parameter(:B)],
210
+ fb: T.proc.params(item: T.type_parameter(:B)).returns(T.untyped)
211
+ ).returns(T::Array[[T.type_parameter(:A), T.type_parameter(:B)]])
212
+ end
213
+ def zip_by(a, fa, b, fb); end
214
+ end
215
+
216
+ class RbiGenerator
217
+ extend T::Sig
218
+
219
+ sig { params(break_params: Integer, tab_size: Integer, sort_namespaces: T::Boolean).void }
220
+ def initialize(break_params: 4, tab_size: 2, sort_namespaces: false); end
221
+
222
+ sig { returns(Options) }
223
+ attr_reader :options
224
+
225
+ sig { returns(Namespace) }
226
+ attr_reader :root
227
+
228
+ sig { returns(T.nilable(Plugin)) }
229
+ attr_accessor :current_plugin
230
+
231
+ sig { overridable.params(strictness: String).returns(String) }
232
+ def rbi(strictness = 'strong'); end
233
+
234
+ class Arbitrary < RbiObject
235
+ sig { params(generator: RbiGenerator, code: String, block: T.nilable(T.proc.params(x: Arbitrary).void)).void }
236
+ def initialize(generator, code: '', &block); end
237
+
238
+ sig { returns(String) }
239
+ attr_accessor :code
240
+
241
+ sig { params(other: Object).returns(T::Boolean) }
242
+ def ==(other); end
243
+
244
+ sig { override.params(indent_level: Integer, options: Options).returns(T::Array[String]) }
245
+ def generate_rbi(indent_level, options); end
246
+
247
+ sig { override.params(others: T::Array[RbiGenerator::RbiObject]).returns(T::Boolean) }
248
+ def mergeable?(others); end
249
+
250
+ sig { override.params(others: T::Array[RbiGenerator::RbiObject]).void }
251
+ def merge_into_self(others); end
252
+
253
+ sig { override.returns(String) }
254
+ def describe; end
255
+ end
256
+
257
+ class Attribute < Method
258
+ sig do
259
+ params(
260
+ generator: RbiGenerator,
261
+ name: String,
262
+ kind: Symbol,
263
+ type: String,
264
+ class_attribute: T::Boolean,
265
+ block: T.nilable(T.proc.params(x: Attribute).void)
266
+ ).void
267
+ end
268
+ def initialize(generator, name, kind, type, class_attribute: false, &block); end
269
+
270
+ sig { returns(Symbol) }
271
+ attr_reader :kind
272
+
273
+ sig { returns(T::Boolean) }
274
+ attr_reader :class_attribute
275
+
276
+ sig { override.params(other: Object).returns(T::Boolean) }
277
+ def ==(other); end
278
+
279
+ sig { override.params(indent_level: Integer, options: Options).returns(T::Array[String]) }
280
+ def generate_definition(indent_level, options); end
281
+ end
282
+
283
+ class ClassNamespace < Namespace
284
+ extend T::Sig
285
+
286
+ sig do
287
+ params(
288
+ generator: RbiGenerator,
289
+ name: String,
290
+ final: T::Boolean,
291
+ superclass: T.nilable(String),
292
+ abstract: T::Boolean,
293
+ block: T.nilable(T.proc.params(x: ClassNamespace).void)
294
+ ).void
295
+ end
296
+ def initialize(generator, name, final, superclass, abstract, &block); end
297
+
298
+ sig { override.params(indent_level: Integer, options: Options).returns(T::Array[String]) }
299
+ def generate_rbi(indent_level, options); end
300
+
301
+ sig { returns(T.nilable(String)) }
302
+ attr_reader :superclass
303
+
304
+ sig { returns(T::Boolean) }
305
+ attr_reader :abstract
306
+
307
+ sig { override.params(others: T::Array[RbiGenerator::RbiObject]).returns(T::Boolean) }
308
+ def mergeable?(others); end
309
+
310
+ sig { override.params(others: T::Array[RbiGenerator::RbiObject]).void }
311
+ def merge_into_self(others); end
312
+
313
+ sig { override.returns(String) }
314
+ def describe; end
315
+ end
316
+
317
+ class Constant < RbiObject
318
+ sig do
319
+ params(
320
+ generator: RbiGenerator,
321
+ name: String,
322
+ value: String,
323
+ eigen_constant: T::Boolean,
324
+ block: T.nilable(T.proc.params(x: Constant).void)
325
+ ).void
326
+ end
327
+ def initialize(generator, name: '', value: '', eigen_constant: false, &block); end
328
+
329
+ sig { returns(String) }
330
+ attr_reader :value
331
+
332
+ sig { returns(T.untyped) }
333
+ attr_reader :eigen_constant
334
+
335
+ sig { params(other: Object).returns(T::Boolean) }
336
+ def ==(other); end
337
+
338
+ sig { override.params(indent_level: Integer, options: Options).returns(T::Array[String]) }
339
+ def generate_rbi(indent_level, options); end
340
+
341
+ sig { override.params(others: T::Array[RbiGenerator::RbiObject]).returns(T::Boolean) }
342
+ def mergeable?(others); end
343
+
344
+ sig { override.params(others: T::Array[RbiGenerator::RbiObject]).void }
345
+ def merge_into_self(others); end
346
+
347
+ sig { override.returns(String) }
348
+ def describe; end
349
+ end
350
+
351
+ class EnumClassNamespace < ClassNamespace
352
+ extend T::Sig
353
+
354
+ sig do
355
+ params(
356
+ generator: RbiGenerator,
357
+ name: String,
358
+ final: T::Boolean,
359
+ enums: T::Array[T.any([String, String], String)],
360
+ abstract: T::Boolean,
361
+ block: T.nilable(T.proc.params(x: EnumClassNamespace).void)
362
+ ).void
363
+ end
364
+ def initialize(generator, name, final, enums, abstract, &block); end
365
+
366
+ sig { returns(T::Array[T.any([String, String], String)]) }
367
+ attr_reader :enums
368
+
369
+ sig { override.params(indent_level: Integer, options: Options).returns(T::Array[String]) }
370
+ def generate_body(indent_level, options); end
371
+
372
+ sig { override.params(others: T::Array[RbiGenerator::RbiObject]).returns(T::Boolean) }
373
+ def mergeable?(others); end
374
+
375
+ sig { override.params(others: T::Array[RbiGenerator::RbiObject]).void }
376
+ def merge_into_self(others); end
377
+ end
378
+
379
+ class Extend < RbiObject
380
+ sig { params(generator: RbiGenerator, name: String, block: T.nilable(T.proc.params(x: Extend).void)).void }
381
+ def initialize(generator, name: '', &block); end
382
+
383
+ sig { params(other: Object).returns(T::Boolean) }
384
+ def ==(other); end
385
+
386
+ sig { override.params(indent_level: Integer, options: Options).returns(T::Array[String]) }
387
+ def generate_rbi(indent_level, options); end
388
+
389
+ sig { override.params(others: T::Array[RbiGenerator::RbiObject]).returns(T::Boolean) }
390
+ def mergeable?(others); end
391
+
392
+ sig { override.params(others: T::Array[RbiGenerator::RbiObject]).void }
393
+ def merge_into_self(others); end
394
+
395
+ sig { override.returns(String) }
396
+ def describe; end
397
+ end
398
+
399
+ class Include < RbiObject
400
+ sig { params(generator: RbiGenerator, name: String, block: T.nilable(T.proc.params(x: Include).void)).void }
401
+ def initialize(generator, name: '', &block); end
402
+
403
+ sig { params(other: Object).returns(T::Boolean) }
404
+ def ==(other); end
405
+
406
+ sig { override.params(indent_level: Integer, options: Options).returns(T::Array[String]) }
407
+ def generate_rbi(indent_level, options); end
408
+
409
+ sig { override.params(others: T::Array[RbiGenerator::RbiObject]).returns(T::Boolean) }
410
+ def mergeable?(others); end
411
+
412
+ sig { override.params(others: T::Array[RbiGenerator::RbiObject]).void }
413
+ def merge_into_self(others); end
414
+
415
+ sig { override.returns(String) }
416
+ def describe; end
417
+ end
418
+
419
+ class Method < RbiObject
420
+ extend T::Sig
421
+
422
+ sig do
423
+ params(
424
+ generator: RbiGenerator,
425
+ name: String,
426
+ parameters: T::Array[Parameter],
427
+ return_type: T.nilable(String),
428
+ abstract: T::Boolean,
429
+ implementation: T::Boolean,
430
+ override: T::Boolean,
431
+ overridable: T::Boolean,
432
+ class_method: T::Boolean,
433
+ final: T::Boolean,
434
+ type_parameters: T.nilable(T::Array[Symbol]),
435
+ block: T.nilable(T.proc.params(x: Method).void)
436
+ ).void
437
+ end
438
+ def initialize(generator, name, parameters, return_type = nil, abstract: false, implementation: false, override: false, overridable: false, class_method: false, final: false, type_parameters: nil, &block); end
439
+
440
+ sig { overridable.params(other: Object).returns(T::Boolean) }
441
+ def ==(other); end
442
+
443
+ sig { returns(T::Array[Parameter]) }
444
+ attr_reader :parameters
445
+
446
+ sig { returns(T.nilable(String)) }
447
+ attr_reader :return_type
448
+
449
+ sig { returns(T::Boolean) }
450
+ attr_reader :abstract
451
+
452
+ sig { returns(T::Boolean) }
453
+ attr_reader :implementation
454
+
455
+ sig { returns(T::Boolean) }
456
+ attr_reader :override
457
+
458
+ sig { returns(T::Boolean) }
459
+ attr_reader :overridable
460
+
461
+ sig { returns(T::Boolean) }
462
+ attr_reader :class_method
463
+
464
+ sig { returns(T::Boolean) }
465
+ attr_reader :final
466
+
467
+ sig { returns(T::Array[Symbol]) }
468
+ attr_reader :type_parameters
469
+
470
+ sig { override.params(indent_level: Integer, options: Options).returns(T::Array[String]) }
471
+ def generate_rbi(indent_level, options); end
472
+
473
+ sig { override.params(others: T::Array[RbiGenerator::RbiObject]).returns(T::Boolean) }
474
+ def mergeable?(others); end
475
+
476
+ sig { override.params(others: T::Array[RbiGenerator::RbiObject]).void }
477
+ def merge_into_self(others); end
478
+
479
+ sig { override.returns(String) }
480
+ def describe; end
481
+
482
+ sig { overridable.params(indent_level: Integer, options: Options).returns(T::Array[String]) }
483
+ def generate_definition(indent_level, options); end
484
+
485
+ sig { returns(String) }
486
+ def qualifiers; end
487
+ end
488
+
489
+ class ModuleNamespace < Namespace
490
+ extend T::Sig
491
+
492
+ sig do
493
+ params(
494
+ generator: RbiGenerator,
495
+ name: String,
496
+ final: T::Boolean,
497
+ interface: T::Boolean,
498
+ block: T.nilable(T.proc.params(x: ClassNamespace).void)
499
+ ).void
500
+ end
501
+ def initialize(generator, name, final, interface, &block); end
502
+
503
+ sig { override.params(indent_level: Integer, options: Options).returns(T::Array[String]) }
504
+ def generate_rbi(indent_level, options); end
505
+
506
+ sig { returns(T::Boolean) }
507
+ attr_reader :interface
508
+
509
+ sig { override.params(others: T::Array[RbiGenerator::RbiObject]).returns(T::Boolean) }
510
+ def mergeable?(others); end
511
+
512
+ sig { override.params(others: T::Array[RbiGenerator::RbiObject]).void }
513
+ def merge_into_self(others); end
514
+
515
+ sig { override.returns(String) }
516
+ def describe; end
517
+ end
518
+
519
+ class Namespace < RbiObject
520
+ extend T::Sig
521
+
522
+ sig { override.overridable.params(indent_level: Integer, options: Options).returns(T::Array[String]) }
523
+ def generate_rbi(indent_level, options); end
524
+
525
+ sig do
526
+ params(
527
+ generator: RbiGenerator,
528
+ name: T.nilable(String),
529
+ final: T::Boolean,
530
+ block: T.nilable(T.proc.params(x: Namespace).void)
531
+ ).void
532
+ end
533
+ def initialize(generator, name = nil, final = false, &block); end
534
+
535
+ sig { returns(T::Boolean) }
536
+ attr_reader :final
537
+
538
+ sig { returns(T::Array[RbiObject]) }
539
+ attr_reader :children
540
+
541
+ sig { returns(T::Array[RbiGenerator::Extend]) }
542
+ def extends; end
543
+
544
+ sig { returns(T::Array[RbiGenerator::Include]) }
545
+ def includes; end
546
+
547
+ sig { returns(T::Array[RbiGenerator::Constant]) }
548
+ def constants; end
549
+
550
+ sig { params(object: T.untyped, block: T.proc.params(x: Namespace).void).void }
551
+ def path(object, &block); end
552
+
553
+ sig { params(comment: T.any(String, T::Array[String])).void }
554
+ def add_comment_to_next_child(comment); end
555
+
556
+ sig do
557
+ params(
558
+ name: String,
559
+ final: T::Boolean,
560
+ superclass: T.nilable(String),
561
+ abstract: T::Boolean,
562
+ block: T.nilable(T.proc.params(x: ClassNamespace).void)
563
+ ).returns(ClassNamespace)
564
+ end
565
+ def create_class(name, final: false, superclass: nil, abstract: false, &block); end
566
+
567
+ sig do
568
+ params(
569
+ name: String,
570
+ final: T::Boolean,
571
+ enums: T.nilable(T::Array[T.any([String, String], String)]),
572
+ abstract: T::Boolean,
573
+ block: T.nilable(T.proc.params(x: EnumClassNamespace).void)
574
+ ).returns(EnumClassNamespace)
575
+ end
576
+ def create_enum_class(name, final: false, enums: nil, abstract: false, &block); end
577
+
578
+ sig do
579
+ params(
580
+ name: String,
581
+ final: T::Boolean,
582
+ props: T.nilable(T::Array[StructProp]),
583
+ abstract: T::Boolean,
584
+ block: T.nilable(T.proc.params(x: StructClassNamespace).void)
585
+ ).returns(StructClassNamespace)
586
+ end
587
+ def create_struct_class(name, final: false, props: nil, abstract: false, &block); end
588
+
589
+ sig do
590
+ params(
591
+ name: String,
592
+ final: T::Boolean,
593
+ interface: T::Boolean,
594
+ block: T.nilable(T.proc.params(x: ClassNamespace).void)
595
+ ).returns(ModuleNamespace)
596
+ end
597
+ def create_module(name, final: false, interface: false, &block); end
598
+
599
+ sig do
600
+ params(
601
+ name: String,
602
+ parameters: T.nilable(T::Array[Parameter]),
603
+ return_type: T.nilable(String),
604
+ returns: T.nilable(String),
605
+ abstract: T::Boolean,
606
+ implementation: T::Boolean,
607
+ override: T::Boolean,
608
+ overridable: T::Boolean,
609
+ class_method: T::Boolean,
610
+ final: T::Boolean,
611
+ type_parameters: T.nilable(T::Array[Symbol]),
612
+ block: T.nilable(T.proc.params(x: Method).void)
613
+ ).returns(Method)
614
+ end
615
+ def create_method(name, parameters: nil, return_type: nil, returns: nil, abstract: false, implementation: false, override: false, overridable: false, class_method: false, final: false, type_parameters: nil, &block); end
616
+
617
+ sig do
618
+ params(
619
+ name: String,
620
+ kind: Symbol,
621
+ type: String,
622
+ class_attribute: T::Boolean,
623
+ block: T.nilable(T.proc.params(x: Attribute).void)
624
+ ).returns(Attribute)
625
+ end
626
+ def create_attribute(name, kind:, type:, class_attribute: false, &block); end
627
+
628
+ sig do
629
+ params(
630
+ name: String,
631
+ type: String,
632
+ class_attribute: T::Boolean,
633
+ block: T.nilable(T.proc.params(x: Attribute).void)
634
+ ).returns(Attribute)
635
+ end
636
+ def create_attr_reader(name, type:, class_attribute: false, &block); end
637
+
638
+ sig do
639
+ params(
640
+ name: String,
641
+ type: String,
642
+ class_attribute: T::Boolean,
643
+ block: T.nilable(T.proc.params(x: Attribute).void)
644
+ ).returns(Attribute)
645
+ end
646
+ def create_attr_writer(name, type:, class_attribute: false, &block); end
647
+
648
+ sig do
649
+ params(
650
+ name: String,
651
+ type: String,
652
+ class_attribute: T::Boolean,
653
+ block: T.nilable(T.proc.params(x: Attribute).void)
654
+ ).returns(Attribute)
655
+ end
656
+ def create_attr_accessor(name, type:, class_attribute: false, &block); end
657
+
658
+ sig { params(code: T.untyped, block: T.untyped).returns(T.untyped) }
659
+ def create_arbitrary(code:, &block); end
660
+
661
+ sig { params(name: String, block: T.nilable(T.proc.params(x: Extend).void)).returns(RbiGenerator::Extend) }
662
+ def create_extend(name, &block); end
663
+
664
+ sig { params(extendables: T::Array[String]).returns(T::Array[Extend]) }
665
+ def create_extends(extendables); end
666
+
667
+ sig { params(name: String, block: T.nilable(T.proc.params(x: Include).void)).returns(Include) }
668
+ def create_include(name, &block); end
669
+
670
+ sig { params(includables: T::Array[String]).returns(T::Array[Include]) }
671
+ def create_includes(includables); end
672
+
673
+ sig do
674
+ params(
675
+ name: String,
676
+ value: String,
677
+ eigen_constant: T::Boolean,
678
+ block: T.nilable(T.proc.params(x: Constant).void)
679
+ ).returns(Constant)
680
+ end
681
+ def create_constant(name, value:, eigen_constant: false, &block); end
682
+
683
+ sig { params(name: String, type: String, block: T.nilable(T.proc.params(x: Constant).void)).returns(Constant) }
684
+ def create_type_alias(name, type:, &block); end
685
+
686
+ sig { override.overridable.params(others: T::Array[RbiGenerator::RbiObject]).returns(T::Boolean) }
687
+ def mergeable?(others); end
688
+
689
+ sig { override.overridable.params(others: T::Array[RbiGenerator::RbiObject]).void }
690
+ def merge_into_self(others); end
691
+
692
+ sig { override.overridable.returns(String) }
693
+ def describe; end
694
+
695
+ sig { overridable.params(indent_level: Integer, options: Options).returns(T::Array[String]) }
696
+ def generate_body(indent_level, options); end
697
+
698
+ sig { params(object: RbiObject).void }
699
+ def move_next_comments(object); end
700
+ end
701
+
702
+ class Options
703
+ extend T::Sig
704
+
705
+ sig { params(break_params: Integer, tab_size: Integer, sort_namespaces: T::Boolean).void }
706
+ def initialize(break_params:, tab_size:, sort_namespaces:); end
707
+
708
+ sig { returns(Integer) }
709
+ attr_reader :break_params
710
+
711
+ sig { returns(Integer) }
712
+ attr_reader :tab_size
713
+
714
+ sig { returns(T::Boolean) }
715
+ attr_reader :sort_namespaces
716
+
717
+ sig { params(level: Integer, str: String).returns(String) }
718
+ def indented(level, str); end
719
+ end
720
+
721
+ class Parameter
722
+ extend T::Sig
723
+ PREFIXES = {
724
+ normal: '',
725
+ splat: '*',
726
+ double_splat: '**',
727
+ block: '&'
728
+ }.freeze
729
+
730
+ sig { params(name: String, type: T.nilable(String), default: T.nilable(String)).void }
731
+ def initialize(name, type: nil, default: nil); end
732
+
733
+ sig { params(other: Object).returns(T::Boolean) }
734
+ def ==(other); end
735
+
736
+ sig { returns(String) }
737
+ attr_reader :name
738
+
739
+ sig { returns(String) }
740
+ def name_without_kind; end
741
+
742
+ sig { returns(String) }
743
+ attr_reader :type
744
+
745
+ sig { returns(T.nilable(String)) }
746
+ attr_reader :default
747
+
748
+ sig { returns(Symbol) }
749
+ attr_reader :kind
750
+
751
+ sig { returns(String) }
752
+ def to_def_param; end
753
+
754
+ sig { returns(String) }
755
+ def to_sig_param; end
756
+ end
757
+
758
+ class RbiObject
759
+ abstract!
760
+
761
+ extend T::Helpers
762
+ extend T::Sig
763
+
764
+ sig { params(generator: RbiGenerator, name: String).void }
765
+ def initialize(generator, name); end
766
+
767
+ sig { returns(RbiGenerator) }
768
+ attr_reader :generator
769
+
770
+ sig { returns(T.nilable(Plugin)) }
771
+ attr_reader :generated_by
772
+
773
+ sig { returns(String) }
774
+ attr_reader :name
775
+
776
+ sig { returns(T::Array[String]) }
777
+ attr_reader :comments
778
+
779
+ sig { params(comment: T.any(String, T::Array[String])).void }
780
+ def add_comment(comment); end
781
+
782
+ sig { abstract.params(indent_level: Integer, options: Options).returns(T::Array[String]) }
783
+ def generate_rbi(indent_level, options); end
784
+
785
+ sig { abstract.params(others: T::Array[RbiGenerator::RbiObject]).returns(T::Boolean) }
786
+ def mergeable?(others); end
787
+
788
+ sig { abstract.params(others: T::Array[RbiGenerator::RbiObject]).void }
789
+ def merge_into_self(others); end
790
+
791
+ sig { abstract.returns(String) }
792
+ def describe; end
793
+
794
+ sig { params(indent_level: Integer, options: Options).returns(T::Array[String]) }
795
+ def generate_comments(indent_level, options); end
796
+ end
797
+
798
+ class StructClassNamespace < ClassNamespace
799
+ extend T::Sig
800
+
801
+ sig do
802
+ params(
803
+ generator: RbiGenerator,
804
+ name: String,
805
+ final: T::Boolean,
806
+ props: T::Array[StructProp],
807
+ abstract: T::Boolean,
808
+ block: T.nilable(T.proc.params(x: StructClassNamespace).void)
809
+ ).void
810
+ end
811
+ def initialize(generator, name, final, props, abstract, &block); end
812
+
813
+ sig { returns(T::Array[StructProp]) }
814
+ attr_reader :props
815
+
816
+ sig { override.params(indent_level: Integer, options: Options).returns(T::Array[String]) }
817
+ def generate_body(indent_level, options); end
818
+
819
+ sig { override.params(others: T::Array[RbiGenerator::RbiObject]).returns(T::Boolean) }
820
+ def mergeable?(others); end
821
+
822
+ sig { override.params(others: T::Array[RbiGenerator::RbiObject]).void }
823
+ def merge_into_self(others); end
824
+ end
825
+
826
+ class StructProp
827
+ extend T::Sig
828
+ EXTRA_PROPERTIES = %i{
829
+ optional enum dont_store foreign default factory immutable array override redaction
830
+ }
831
+
832
+ sig do
833
+ params(
834
+ name: String,
835
+ type: String,
836
+ optional: T.nilable(T.any(T::Boolean, Symbol)),
837
+ enum: T.nilable(String),
838
+ dont_store: T.nilable(T::Boolean),
839
+ foreign: T.nilable(String),
840
+ default: T.nilable(String),
841
+ factory: T.nilable(String),
842
+ immutable: T.nilable(T::Boolean),
843
+ array: T.nilable(String),
844
+ override: T.nilable(T::Boolean),
845
+ redaction: T.nilable(String)
846
+ ).void
847
+ end
848
+ def initialize(name, type, optional: nil, enum: nil, dont_store: nil, foreign: nil, default: nil, factory: nil, immutable: nil, array: nil, override: nil, redaction: nil); end
849
+
850
+ sig { params(other: Object).returns(T::Boolean) }
851
+ def ==(other); end
852
+
853
+ sig { returns(String) }
854
+ attr_reader :name
855
+
856
+ sig { returns(T.nilable(String)) }
857
+ attr_reader :type
858
+
859
+ sig { returns(T.nilable(T.any(T::Boolean, Symbol))) }
860
+ attr_reader :optional
861
+
862
+ sig { returns(T.nilable(String)) }
863
+ attr_reader :enum
864
+
865
+ sig { returns(T.nilable(T::Boolean)) }
866
+ attr_reader :dont_store
867
+
868
+ sig { returns(T.nilable(String)) }
869
+ attr_reader :foreign
870
+
871
+ sig { returns(T.nilable(String)) }
872
+ attr_reader :default
873
+
874
+ sig { returns(T.nilable(String)) }
875
+ attr_reader :factory
876
+
877
+ sig { returns(T.nilable(T::Boolean)) }
878
+ attr_reader :immutable
879
+
880
+ sig { returns(T.nilable(String)) }
881
+ attr_reader :array
882
+
883
+ sig { returns(T.nilable(T::Boolean)) }
884
+ attr_reader :override
885
+
886
+ sig { returns(T.nilable(String)) }
887
+ attr_reader :redaction
888
+
889
+ sig { returns(String) }
890
+ def to_prop_call; end
891
+ end
892
+ end
893
+ end