rbi 0.0.2 → 0.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f74d8bfd9f52c65d39357d68e286e247a48d53779397c11f310b50ca37b3b925
4
- data.tar.gz: 0a924a9c84c508cbb70b307a1b8770f00b1c855d68c41c57e0dd74dfd1f75d86
3
+ metadata.gz: 80af4a72c6b71d1ed72dd5eefc9c2821443cbb7ca00d458bbfd2a381e1297545
4
+ data.tar.gz: 8d774a3c7094a748a6fab5623eb6da0f5097e00591696e4e22423f3de6a869ee
5
5
  SHA512:
6
- metadata.gz: 303c4606968022e24e65f0d9a54732431ee7c6cc315dffe592e0196e5c449a5842319d32897231f046ca8266ccaf3dc9743fd7229582988b5a590c381cf4473b
7
- data.tar.gz: 955d836aea51639220440f984fa0a8c595c763521b84ddca73dfdd08b8b546bc5b61e3fc48a19ddd04e50a7824377cc25960816a9ac2d65454ab8821259acda8
6
+ metadata.gz: 259201aa73a41ef445010bb89bd14f69df1ef107dcfdf1becda6ead491ce067d6a0cbb9520f751272a879d76d65c74bb524a67c037447f74e243fd429749fbe7
7
+ data.tar.gz: b989d25962cca475a307fcf1e76c8c74d74b3079290532e7be0bd3901446dbc800242641557ddc51e3cf2977970059869228f58bef0ff372537ef934b3a46eb2
data/README.md CHANGED
@@ -60,7 +60,7 @@ This repo uses itself (`rbi`) to retrieve and generate gem RBIs. You can run `de
60
60
 
61
61
  ## Contributing
62
62
 
63
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rbi. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/rbi/blob/master/CODE_OF_CONDUCT.md).
63
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Shopify/rbi. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/Shopify/rbi/blob/master/CODE_OF_CONDUCT.md).
64
64
 
65
65
  ## License
66
66
 
data/lib/rbi/model.rb CHANGED
@@ -48,7 +48,7 @@ module RBI
48
48
  end
49
49
 
50
50
  class Comment < Node
51
- extend T::Helpers
51
+ extend T::Sig
52
52
 
53
53
  sig { returns(String) }
54
54
  attr_accessor :text
@@ -66,6 +66,15 @@ module RBI
66
66
  end
67
67
  end
68
68
 
69
+ class EmptyComment < Comment
70
+ extend T::Sig
71
+
72
+ sig { params(loc: T.nilable(Loc)).void }
73
+ def initialize(loc: nil)
74
+ super("", loc: loc)
75
+ end
76
+ end
77
+
69
78
  class NodeWithComments < Node
70
79
  extend T::Sig
71
80
  extend T::Helpers
@@ -92,7 +101,7 @@ module RBI
92
101
  params(
93
102
  loc: T.nilable(Loc),
94
103
  comments: T::Array[Comment],
95
- block: T.nilable(T.proc.params(tree: Tree).void)
104
+ block: T.nilable(T.proc.params(node: Tree).void)
96
105
  ).void
97
106
  end
98
107
  def initialize(loc: nil, comments: [], &block)
@@ -129,7 +138,7 @@ module RBI
129
138
  params(
130
139
  strictness: T.nilable(String),
131
140
  comments: T::Array[Comment],
132
- block: T.nilable(T.proc.params(mod: File).void)
141
+ block: T.nilable(T.proc.params(file: File).void)
133
142
  ).void
134
143
  end
135
144
  def initialize(strictness: nil, comments: [], &block)
@@ -172,7 +181,7 @@ module RBI
172
181
  name: String,
173
182
  loc: T.nilable(Loc),
174
183
  comments: T::Array[Comment],
175
- block: T.nilable(T.proc.params(mod: Module).void)
184
+ block: T.nilable(T.proc.params(node: Module).void)
176
185
  ).void
177
186
  end
178
187
  def initialize(name, loc: nil, comments: [], &block)
@@ -203,7 +212,7 @@ module RBI
203
212
  superclass_name: T.nilable(String),
204
213
  loc: T.nilable(Loc),
205
214
  comments: T::Array[Comment],
206
- block: T.nilable(T.proc.params(klass: Class).void)
215
+ block: T.nilable(T.proc.params(node: Class).void)
207
216
  ).void
208
217
  end
209
218
  def initialize(name, superclass_name: nil, loc: nil, comments: [], &block)
@@ -227,7 +236,7 @@ module RBI
227
236
  params(
228
237
  loc: T.nilable(Loc),
229
238
  comments: T::Array[Comment],
230
- block: T.nilable(T.proc.params(klass: SingletonClass).void)
239
+ block: T.nilable(T.proc.params(node: SingletonClass).void)
231
240
  ).void
232
241
  end
233
242
  def initialize(loc: nil, comments: [], &block)
@@ -241,6 +250,43 @@ module RBI
241
250
  end
242
251
  end
243
252
 
253
+ class Struct < Scope
254
+ extend T::Sig
255
+
256
+ sig { returns(String) }
257
+ attr_accessor :name
258
+
259
+ sig { returns(T::Array[Symbol]) }
260
+ attr_accessor :members
261
+
262
+ sig { returns(T::Boolean) }
263
+ attr_accessor :keyword_init
264
+
265
+ sig do
266
+ params(
267
+ name: String,
268
+ members: T::Array[Symbol],
269
+ keyword_init: T::Boolean,
270
+ loc: T.nilable(Loc),
271
+ comments: T::Array[Comment],
272
+ block: T.nilable(T.proc.params(struct: Struct).void)
273
+ ).void
274
+ end
275
+ def initialize(name, members: [], keyword_init: false, loc: nil, comments: [], &block)
276
+ super(loc: loc, comments: comments) {}
277
+ @name = name
278
+ @members = members
279
+ @keyword_init = keyword_init
280
+ block&.call(self)
281
+ end
282
+
283
+ sig { override.returns(String) }
284
+ def fully_qualified_name
285
+ return name if name.start_with?("::")
286
+ "#{parent_scope&.fully_qualified_name}::#{name}"
287
+ end
288
+ end
289
+
244
290
  # Consts
245
291
 
246
292
  class Const < NodeWithComments
@@ -249,11 +295,20 @@ module RBI
249
295
  sig { returns(String) }
250
296
  attr_reader :name, :value
251
297
 
252
- sig { params(name: String, value: String, loc: T.nilable(Loc), comments: T::Array[Comment]).void }
253
- def initialize(name, value, loc: nil, comments: [])
298
+ sig do
299
+ params(
300
+ name: String,
301
+ value: String,
302
+ loc: T.nilable(Loc),
303
+ comments: T::Array[Comment],
304
+ block: T.nilable(T.proc.params(node: Const).void)
305
+ ).void
306
+ end
307
+ def initialize(name, value, loc: nil, comments: [], &block)
254
308
  super(loc: loc, comments: comments)
255
309
  @name = name
256
310
  @value = value
311
+ block&.call(self)
257
312
  end
258
313
 
259
314
  sig { returns(String) }
@@ -288,14 +343,14 @@ module RBI
288
343
  sig do
289
344
  params(
290
345
  name: Symbol,
291
- names: Symbol,
346
+ names: T::Array[Symbol],
292
347
  visibility: Visibility,
293
348
  sigs: T::Array[Sig],
294
349
  loc: T.nilable(Loc),
295
350
  comments: T::Array[Comment]
296
351
  ).void
297
352
  end
298
- def initialize(name, *names, visibility: Visibility::Public, sigs: [], loc: nil, comments: [])
353
+ def initialize(name, names, visibility: Public.new, sigs: [], loc: nil, comments: [])
299
354
  super(loc: loc, comments: comments)
300
355
  @names = T.let([name, *names], T::Array[Symbol])
301
356
  @visibility = visibility
@@ -309,6 +364,22 @@ module RBI
309
364
  class AttrAccessor < Attr
310
365
  extend T::Sig
311
366
 
367
+ sig do
368
+ params(
369
+ name: Symbol,
370
+ names: Symbol,
371
+ visibility: Visibility,
372
+ sigs: T::Array[Sig],
373
+ loc: T.nilable(Loc),
374
+ comments: T::Array[Comment],
375
+ block: T.nilable(T.proc.params(node: AttrAccessor).void)
376
+ ).void
377
+ end
378
+ def initialize(name, *names, visibility: Public.new, sigs: [], loc: nil, comments: [], &block)
379
+ super(name, names, loc: loc, visibility: visibility, sigs: sigs, comments: comments)
380
+ block&.call(self)
381
+ end
382
+
312
383
  sig { override.returns(T::Array[String]) }
313
384
  def fully_qualified_names
314
385
  parent_name = parent_scope&.fully_qualified_name
@@ -325,6 +396,22 @@ module RBI
325
396
  class AttrReader < Attr
326
397
  extend T::Sig
327
398
 
399
+ sig do
400
+ params(
401
+ name: Symbol,
402
+ names: Symbol,
403
+ visibility: Visibility,
404
+ sigs: T::Array[Sig],
405
+ loc: T.nilable(Loc),
406
+ comments: T::Array[Comment],
407
+ block: T.nilable(T.proc.params(node: AttrReader).void)
408
+ ).void
409
+ end
410
+ def initialize(name, *names, visibility: Public.new, sigs: [], loc: nil, comments: [], &block)
411
+ super(name, names, loc: loc, visibility: visibility, sigs: sigs, comments: comments)
412
+ block&.call(self)
413
+ end
414
+
328
415
  sig { override.returns(T::Array[String]) }
329
416
  def fully_qualified_names
330
417
  parent_name = parent_scope&.fully_qualified_name
@@ -341,6 +428,22 @@ module RBI
341
428
  class AttrWriter < Attr
342
429
  extend T::Sig
343
430
 
431
+ sig do
432
+ params(
433
+ name: Symbol,
434
+ names: Symbol,
435
+ visibility: Visibility,
436
+ sigs: T::Array[Sig],
437
+ loc: T.nilable(Loc),
438
+ comments: T::Array[Comment],
439
+ block: T.nilable(T.proc.params(node: AttrWriter).void)
440
+ ).void
441
+ end
442
+ def initialize(name, *names, visibility: Public.new, sigs: [], loc: nil, comments: [], &block)
443
+ super(name, names, loc: loc, visibility: visibility, sigs: sigs, comments: comments)
444
+ block&.call(self)
445
+ end
446
+
344
447
  sig { override.returns(T::Array[String]) }
345
448
  def fully_qualified_names
346
449
  parent_name = parent_scope&.fully_qualified_name
@@ -383,14 +486,14 @@ module RBI
383
486
  sigs: T::Array[Sig],
384
487
  loc: T.nilable(Loc),
385
488
  comments: T::Array[Comment],
386
- block: T.nilable(T.proc.params(mod: Method).void)
489
+ block: T.nilable(T.proc.params(node: Method).void)
387
490
  ).void
388
491
  end
389
492
  def initialize(
390
493
  name,
391
494
  params: [],
392
495
  is_singleton: false,
393
- visibility: Visibility::Public,
496
+ visibility: Public.new,
394
497
  sigs: [],
395
498
  loc: nil,
396
499
  comments: [],
@@ -426,12 +529,21 @@ module RBI
426
529
  end
427
530
 
428
531
  class Param < NodeWithComments
532
+ extend T::Helpers
429
533
  extend T::Sig
430
534
 
535
+ abstract!
536
+
431
537
  sig { returns(String) }
432
538
  attr_reader :name
433
539
 
434
- sig { params(name: String, loc: T.nilable(Loc), comments: T::Array[Comment]).void }
540
+ sig do
541
+ params(
542
+ name: String,
543
+ loc: T.nilable(Loc),
544
+ comments: T::Array[Comment],
545
+ ).void
546
+ end
435
547
  def initialize(name, loc: nil, comments: [])
436
548
  super(loc: loc, comments: comments)
437
549
  @name = name
@@ -441,11 +553,27 @@ module RBI
441
553
  def to_s
442
554
  name
443
555
  end
556
+ end
557
+
558
+ class ReqParam < Param
559
+ extend T::Sig
560
+
561
+ sig do
562
+ params(
563
+ name: String,
564
+ loc: T.nilable(Loc),
565
+ comments: T::Array[Comment],
566
+ block: T.nilable(T.proc.params(node: ReqParam).void)
567
+ ).void
568
+ end
569
+ def initialize(name, loc: nil, comments: [], &block)
570
+ super(name, loc: loc, comments: comments)
571
+ block&.call(self)
572
+ end
444
573
 
445
574
  sig { params(other: T.nilable(Object)).returns(T::Boolean) }
446
575
  def ==(other)
447
- return false unless other.instance_of?(Param)
448
- name == T.cast(other, Param).name
576
+ ReqParam === other && name == other.name
449
577
  end
450
578
  end
451
579
 
@@ -455,39 +583,70 @@ module RBI
455
583
  sig { returns(String) }
456
584
  attr_reader :value
457
585
 
458
- sig { params(name: String, value: String, loc: T.nilable(Loc), comments: T::Array[Comment]).void }
459
- def initialize(name, value, loc: nil, comments: [])
586
+ sig do
587
+ params(
588
+ name: String,
589
+ value: String,
590
+ loc: T.nilable(Loc),
591
+ comments: T::Array[Comment],
592
+ block: T.nilable(T.proc.params(node: OptParam).void)
593
+ ).void
594
+ end
595
+ def initialize(name, value, loc: nil, comments: [], &block)
460
596
  super(name, loc: loc, comments: comments)
461
597
  @value = value
598
+ block&.call(self)
462
599
  end
463
600
 
464
601
  sig { params(other: T.nilable(Object)).returns(T::Boolean) }
465
602
  def ==(other)
466
- return false unless other.instance_of?(OptParam)
467
- other = T.cast(other, OptParam)
468
- return false unless name == other.name
469
- value == other.value
603
+ OptParam === other && name == other.name && value == other.value
470
604
  end
471
605
  end
472
606
 
473
607
  class RestParam < Param
474
608
  extend T::Sig
475
609
 
476
- sig { params(other: T.nilable(Object)).returns(T::Boolean) }
477
- def ==(other)
478
- return false unless other.instance_of?(RestParam)
479
- name == T.cast(other, RestParam).name
610
+ sig do
611
+ params(
612
+ name: String,
613
+ loc: T.nilable(Loc),
614
+ comments: T::Array[Comment],
615
+ block: T.nilable(T.proc.params(node: RestParam).void)
616
+ ).void
617
+ end
618
+ def initialize(name, loc: nil, comments: [], &block)
619
+ super(name, loc: loc, comments: comments)
620
+ block&.call(self)
480
621
  end
481
622
 
482
623
  sig { override.returns(String) }
483
624
  def to_s
484
625
  "*#{name}"
485
626
  end
627
+
628
+ sig { params(other: T.nilable(Object)).returns(T::Boolean) }
629
+ def ==(other)
630
+ RestParam === other && name == other.name
631
+ end
486
632
  end
487
633
 
488
634
  class KwParam < Param
489
635
  extend T::Sig
490
636
 
637
+ sig do
638
+ params(
639
+ name: String,
640
+ loc: T.nilable(Loc),
641
+ comments: T::Array[Comment],
642
+ block: T.nilable(T.proc.params(node: KwParam).void)
643
+ ).void
644
+ end
645
+ def initialize(name, loc: nil, comments: [], &block)
646
+ super(name, loc: loc, comments: comments)
647
+ block&.call(self)
648
+ end
649
+
491
650
  sig { override.returns(String) }
492
651
  def to_s
493
652
  "#{name}:"
@@ -495,14 +654,31 @@ module RBI
495
654
 
496
655
  sig { params(other: T.nilable(Object)).returns(T::Boolean) }
497
656
  def ==(other)
498
- return false unless other.instance_of?(KwParam)
499
- name == T.cast(other, KwParam).name
657
+ KwParam === other && name == other.name
500
658
  end
501
659
  end
502
660
 
503
- class KwOptParam < OptParam
661
+ class KwOptParam < Param
504
662
  extend T::Sig
505
663
 
664
+ sig { returns(String) }
665
+ attr_reader :value
666
+
667
+ sig do
668
+ params(
669
+ name: String,
670
+ value: String,
671
+ loc: T.nilable(Loc),
672
+ comments: T::Array[Comment],
673
+ block: T.nilable(T.proc.params(node: KwOptParam).void)
674
+ ).void
675
+ end
676
+ def initialize(name, value, loc: nil, comments: [], &block)
677
+ super(name, loc: loc, comments: comments)
678
+ @value = value
679
+ block&.call(self)
680
+ end
681
+
506
682
  sig { override.returns(String) }
507
683
  def to_s
508
684
  "#{name}:"
@@ -510,16 +686,26 @@ module RBI
510
686
 
511
687
  sig { params(other: T.nilable(Object)).returns(T::Boolean) }
512
688
  def ==(other)
513
- return false unless other.instance_of?(KwOptParam)
514
- other = T.cast(other, KwOptParam)
515
- return false unless name == other.name
516
- value == other.value
689
+ KwOptParam === other && name == other.name && value == other.value
517
690
  end
518
691
  end
519
692
 
520
693
  class KwRestParam < Param
521
694
  extend T::Sig
522
695
 
696
+ sig do
697
+ params(
698
+ name: String,
699
+ loc: T.nilable(Loc),
700
+ comments: T::Array[Comment],
701
+ block: T.nilable(T.proc.params(node: KwRestParam).void)
702
+ ).void
703
+ end
704
+ def initialize(name, loc: nil, comments: [], &block)
705
+ super(name, loc: loc, comments: comments)
706
+ block&.call(self)
707
+ end
708
+
523
709
  sig { override.returns(String) }
524
710
  def to_s
525
711
  "**#{name}:"
@@ -527,14 +713,26 @@ module RBI
527
713
 
528
714
  sig { params(other: T.nilable(Object)).returns(T::Boolean) }
529
715
  def ==(other)
530
- return false unless other.instance_of?(KwRestParam)
531
- name == T.cast(other, KwRestParam).name
716
+ KwRestParam === other && name == other.name
532
717
  end
533
718
  end
534
719
 
535
720
  class BlockParam < Param
536
721
  extend T::Sig
537
722
 
723
+ sig do
724
+ params(
725
+ name: String,
726
+ loc: T.nilable(Loc),
727
+ comments: T::Array[Comment],
728
+ block: T.nilable(T.proc.params(node: BlockParam).void)
729
+ ).void
730
+ end
731
+ def initialize(name, loc: nil, comments: [], &block)
732
+ super(name, loc: loc, comments: comments)
733
+ block&.call(self)
734
+ end
735
+
538
736
  sig { override.returns(String) }
539
737
  def to_s
540
738
  "&#{name}"
@@ -542,8 +740,7 @@ module RBI
542
740
 
543
741
  sig { params(other: T.nilable(Object)).returns(T::Boolean) }
544
742
  def ==(other)
545
- return false unless other.instance_of?(BlockParam)
546
- name == T.cast(other, BlockParam).name
743
+ BlockParam === other && name == other.name
547
744
  end
548
745
  end
549
746
 
@@ -558,8 +755,15 @@ module RBI
558
755
  sig { returns(T::Array[String]) }
559
756
  attr_accessor :names
560
757
 
561
- sig { params(name: String, names: String, loc: T.nilable(Loc), comments: T::Array[Comment]).void }
562
- def initialize(name, *names, loc: nil, comments: [])
758
+ sig do
759
+ params(
760
+ name: String,
761
+ names: T::Array[String],
762
+ loc: T.nilable(Loc),
763
+ comments: T::Array[Comment]
764
+ ).void
765
+ end
766
+ def initialize(name, names, loc: nil, comments: [])
563
767
  super(loc: loc, comments: comments)
564
768
  @names = T.let([name, *names], T::Array[String])
565
769
  end
@@ -568,6 +772,20 @@ module RBI
568
772
  class Include < Mixin
569
773
  extend T::Sig
570
774
 
775
+ sig do
776
+ params(
777
+ name: String,
778
+ names: String,
779
+ loc: T.nilable(Loc),
780
+ comments: T::Array[Comment],
781
+ block: T.nilable(T.proc.params(node: Include).void)
782
+ ).void
783
+ end
784
+ def initialize(name, *names, loc: nil, comments: [], &block)
785
+ super(name, names, loc: loc, comments: comments)
786
+ block&.call(self)
787
+ end
788
+
571
789
  sig { override.returns(String) }
572
790
  def to_s
573
791
  "#{parent_scope&.fully_qualified_name}.include(#{names.join(", ")})"
@@ -577,6 +795,20 @@ module RBI
577
795
  class Extend < Mixin
578
796
  extend T::Sig
579
797
 
798
+ sig do
799
+ params(
800
+ name: String,
801
+ names: String,
802
+ loc: T.nilable(Loc),
803
+ comments: T::Array[Comment],
804
+ block: T.nilable(T.proc.params(node: Extend).void)
805
+ ).void
806
+ end
807
+ def initialize(name, *names, loc: nil, comments: [], &block)
808
+ super(name, names, loc: loc, comments: comments)
809
+ block&.call(self)
810
+ end
811
+
580
812
  sig { override.returns(String) }
581
813
  def to_s
582
814
  "#{parent_scope&.fully_qualified_name}.extend(#{names.join(", ")})"
@@ -585,7 +817,7 @@ module RBI
585
817
 
586
818
  # Visibility
587
819
 
588
- class Visibility < Node
820
+ class Visibility < NodeWithComments
589
821
  extend T::Sig
590
822
  extend T::Helpers
591
823
 
@@ -594,9 +826,9 @@ module RBI
594
826
  sig { returns(Symbol) }
595
827
  attr_reader :visibility
596
828
 
597
- sig { params(visibility: Symbol, loc: T.nilable(Loc)).void }
598
- def initialize(visibility, loc: nil)
599
- super(loc: loc)
829
+ sig { params(visibility: Symbol, loc: T.nilable(Loc), comments: T::Array[Comment]).void }
830
+ def initialize(visibility, loc: nil, comments: [])
831
+ super(loc: loc, comments: comments)
600
832
  @visibility = visibility
601
833
  end
602
834
 
@@ -605,9 +837,68 @@ module RBI
605
837
  visibility == other.visibility
606
838
  end
607
839
 
608
- Public = T.let(Visibility.new(:public), Visibility)
609
- Protected = T.let(Visibility.new(:protected), Visibility)
610
- Private = T.let(Visibility.new(:private), Visibility)
840
+ sig { returns(T::Boolean) }
841
+ def public?
842
+ visibility == :public
843
+ end
844
+
845
+ sig { returns(T::Boolean) }
846
+ def protected?
847
+ visibility == :protected
848
+ end
849
+
850
+ sig { returns(T::Boolean) }
851
+ def private?
852
+ visibility == :private
853
+ end
854
+ end
855
+
856
+ class Public < Visibility
857
+ extend T::Sig
858
+
859
+ sig do
860
+ params(
861
+ loc: T.nilable(Loc),
862
+ comments: T::Array[Comment],
863
+ block: T.nilable(T.proc.params(node: Public).void)
864
+ ).void
865
+ end
866
+ def initialize(loc: nil, comments: [], &block)
867
+ super(:public, loc: loc, comments: comments)
868
+ block&.call(self)
869
+ end
870
+ end
871
+
872
+ class Protected < Visibility
873
+ extend T::Sig
874
+
875
+ sig do
876
+ params(
877
+ loc: T.nilable(Loc),
878
+ comments: T::Array[Comment],
879
+ block: T.nilable(T.proc.params(node: Protected).void)
880
+ ).void
881
+ end
882
+ def initialize(loc: nil, comments: [], &block)
883
+ super(:protected, loc: loc, comments: comments)
884
+ block&.call(self)
885
+ end
886
+ end
887
+
888
+ class Private < Visibility
889
+ extend T::Sig
890
+
891
+ sig do
892
+ params(
893
+ loc: T.nilable(Loc),
894
+ comments: T::Array[Comment],
895
+ block: T.nilable(T.proc.params(node: Private).void)
896
+ ).void
897
+ end
898
+ def initialize(loc: nil, comments: [], &block)
899
+ super(:private, loc: loc, comments: comments)
900
+ block&.call(self)
901
+ end
611
902
  end
612
903
 
613
904
  # Sorbet's sigs
@@ -639,7 +930,8 @@ module RBI
639
930
  is_overridable: T::Boolean,
640
931
  type_params: T::Array[String],
641
932
  checked: T.nilable(Symbol),
642
- loc: T.nilable(Loc)
933
+ loc: T.nilable(Loc),
934
+ block: T.nilable(T.proc.params(node: Sig).void)
643
935
  ).void
644
936
  end
645
937
  def initialize(
@@ -650,7 +942,8 @@ module RBI
650
942
  is_overridable: false,
651
943
  type_params: [],
652
944
  checked: nil,
653
- loc: nil
945
+ loc: nil,
946
+ &block
654
947
  )
655
948
  super(loc: loc)
656
949
  @params = params
@@ -660,6 +953,7 @@ module RBI
660
953
  @is_overridable = is_overridable
661
954
  @type_params = type_params
662
955
  @checked = checked
956
+ block&.call(self)
663
957
  end
664
958
 
665
959
  sig { params(param: SigParam).void }
@@ -676,17 +970,26 @@ module RBI
676
970
  end
677
971
  end
678
972
 
679
- class SigParam < Node
973
+ class SigParam < NodeWithComments
680
974
  extend T::Sig
681
975
 
682
976
  sig { returns(String) }
683
977
  attr_reader :name, :type
684
978
 
685
- sig { params(name: String, type: String, loc: T.nilable(Loc)).void }
686
- def initialize(name, type, loc: nil)
687
- super(loc: loc)
979
+ sig do
980
+ params(
981
+ name: String,
982
+ type: String,
983
+ loc: T.nilable(Loc),
984
+ comments: T::Array[Comment],
985
+ block: T.nilable(T.proc.params(node: SigParam).void)
986
+ ).void
987
+ end
988
+ def initialize(name, type, loc: nil, comments: [], &block)
989
+ super(loc: loc, comments: comments)
688
990
  @name = name
689
991
  @type = type
992
+ block&.call(self)
690
993
  end
691
994
 
692
995
  sig { params(other: Object).returns(T::Boolean) }
@@ -749,6 +1052,21 @@ module RBI
749
1052
  class TStructConst < TStructField
750
1053
  extend T::Sig
751
1054
 
1055
+ sig do
1056
+ params(
1057
+ name: String,
1058
+ type: String,
1059
+ default: T.nilable(String),
1060
+ loc: T.nilable(Loc),
1061
+ comments: T::Array[Comment],
1062
+ block: T.nilable(T.proc.params(node: TStructConst).void)
1063
+ ).void
1064
+ end
1065
+ def initialize(name, type, default: nil, loc: nil, comments: [], &block)
1066
+ super(name, type, default: default, loc: loc, comments: comments)
1067
+ block&.call(self)
1068
+ end
1069
+
752
1070
  sig { override.returns(T::Array[String]) }
753
1071
  def fully_qualified_names
754
1072
  parent_name = parent_scope&.fully_qualified_name
@@ -764,6 +1082,21 @@ module RBI
764
1082
  class TStructProp < TStructField
765
1083
  extend T::Sig
766
1084
 
1085
+ sig do
1086
+ params(
1087
+ name: String,
1088
+ type: String,
1089
+ default: T.nilable(String),
1090
+ loc: T.nilable(Loc),
1091
+ comments: T::Array[Comment],
1092
+ block: T.nilable(T.proc.params(node: TStructProp).void)
1093
+ ).void
1094
+ end
1095
+ def initialize(name, type, default: nil, loc: nil, comments: [], &block)
1096
+ super(name, type, default: default, loc: loc, comments: comments)
1097
+ block&.call(self)
1098
+ end
1099
+
767
1100
  sig { override.returns(T::Array[String]) }
768
1101
  def fully_qualified_names
769
1102
  parent_name = parent_scope&.fully_qualified_name
@@ -801,10 +1134,18 @@ module RBI
801
1134
  sig { returns(T::Array[String]) }
802
1135
  attr_reader :names
803
1136
 
804
- sig { params(names: T::Array[String], loc: T.nilable(Loc), comments: T::Array[Comment]).void }
805
- def initialize(names = [], loc: nil, comments: [])
1137
+ sig do
1138
+ params(
1139
+ names: T::Array[String],
1140
+ loc: T.nilable(Loc),
1141
+ comments: T::Array[Comment],
1142
+ block: T.nilable(T.proc.params(node: TEnumBlock).void)
1143
+ ).void
1144
+ end
1145
+ def initialize(names = [], loc: nil, comments: [], &block)
806
1146
  super(loc: loc, comments: comments)
807
1147
  @names = names
1148
+ block&.call(self)
808
1149
  end
809
1150
 
810
1151
  sig { returns(T::Boolean) }
@@ -831,10 +1172,18 @@ module RBI
831
1172
  sig { returns(String) }
832
1173
  attr_reader :name
833
1174
 
834
- sig { params(name: String, loc: T.nilable(Loc), comments: T::Array[Comment]).void }
835
- def initialize(name, loc: nil, comments: [])
1175
+ sig do
1176
+ params(
1177
+ name: String,
1178
+ loc: T.nilable(Loc),
1179
+ comments: T::Array[Comment],
1180
+ block: T.nilable(T.proc.params(node: Helper).void)
1181
+ ).void
1182
+ end
1183
+ def initialize(name, loc: nil, comments: [], &block)
836
1184
  super(loc: loc, comments: comments)
837
1185
  @name = name
1186
+ block&.call(self)
838
1187
  end
839
1188
 
840
1189
  sig { override.returns(String) }
@@ -849,11 +1198,20 @@ module RBI
849
1198
  sig { returns(String) }
850
1199
  attr_reader :name, :value
851
1200
 
852
- sig { params(name: String, value: String, loc: T.nilable(Loc), comments: T::Array[Comment]).void }
853
- def initialize(name, value, loc: nil, comments: [])
1201
+ sig do
1202
+ params(
1203
+ name: String,
1204
+ value: String,
1205
+ loc: T.nilable(Loc),
1206
+ comments: T::Array[Comment],
1207
+ block: T.nilable(T.proc.params(node: TypeMember).void)
1208
+ ).void
1209
+ end
1210
+ def initialize(name, value, loc: nil, comments: [], &block)
854
1211
  super(loc: loc, comments: comments)
855
1212
  @name = name
856
1213
  @value = value
1214
+ block&.call(self)
857
1215
  end
858
1216
 
859
1217
  sig { returns(String) }
@@ -871,6 +1229,20 @@ module RBI
871
1229
  class MixesInClassMethods < Mixin
872
1230
  extend T::Sig
873
1231
 
1232
+ sig do
1233
+ params(
1234
+ name: String,
1235
+ names: String,
1236
+ loc: T.nilable(Loc),
1237
+ comments: T::Array[Comment],
1238
+ block: T.nilable(T.proc.params(node: MixesInClassMethods).void)
1239
+ ).void
1240
+ end
1241
+ def initialize(name, *names, loc: nil, comments: [], &block)
1242
+ super(name, names, loc: loc, comments: comments)
1243
+ block&.call(self)
1244
+ end
1245
+
874
1246
  sig { override.returns(String) }
875
1247
  def to_s
876
1248
  "#{parent_scope&.fully_qualified_name}.mixes_in_class_methods(#{names.join(", ")})"