rbi 0.3.1 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: df7c963f26d929bf1c52a460d2f6f47669aa5eb23ce9ebe061ec556ea91247b1
4
- data.tar.gz: 4d86c174bb9270e060978f512d4193cdf1f427b9059c49bc2c913f3a0b25e4c5
3
+ metadata.gz: a5d95986e2041432d98662ec8d46d89eb8a1b8cafafd8bba4d78ac7218e4379e
4
+ data.tar.gz: bbc117ade8b85f2834e172f6d7c4fac54c71846634b176b52adf607a0c82d37a
5
5
  SHA512:
6
- metadata.gz: d42622aa6fed586afe5f8c247144d3d36b6409107df4bd8a6e53b9f96812523f9d6e098ab95e8e715e9b0f4a2bb6d24dffa7831f251367038fb69a164a827496
7
- data.tar.gz: 8e97964c77c0b5d96b763ab6e0b502bf5cd6fb56bbab556efe073d30a74cb1912e13777635c26993702ef5974dbe971520ac153fe8f8cc5ce481055659c3c91c
6
+ metadata.gz: bc76dff9e19e46d13dd54d458b018cf0f41210f2ca00d7b6a053012740017fc4d47ac9b5f09ea66921b9e3634c415116f5ad4d3bc3c34d53bd4d208dc5cb9362
7
+ data.tar.gz: 37eafcb497a99293ebac8a2614863bcebdb294effa0a02e479f24b853a2b9886a16f927bfdb1f31d4c31d66527310ef716d21ee6e62f885db7c27a9133ed6c7d
data/Gemfile CHANGED
@@ -10,7 +10,7 @@ group(:development, :test) do
10
10
  gem("minitest")
11
11
  gem("minitest-reporters")
12
12
  gem("rake", "~> 13.2")
13
- gem("rubocop", "~> 1.73", require: false)
13
+ gem("rubocop", "~> 1.75", require: false)
14
14
  gem("rubocop-shopify", require: false)
15
15
  gem("rubocop-sorbet", require: false)
16
16
  gem("sorbet", ">= 0.5.9204", require: false)
data/lib/rbi/formatter.rb CHANGED
@@ -6,14 +6,15 @@ module RBI
6
6
  #: Integer?
7
7
  attr_accessor :max_line_length
8
8
 
9
- #: (?add_sig_templates: bool, ?group_nodes: bool, ?max_line_length: Integer?, ?nest_singleton_methods: bool, ?nest_non_public_members: bool, ?sort_nodes: bool) -> void
9
+ #: (?add_sig_templates: bool, ?group_nodes: bool, ?max_line_length: Integer?, ?nest_singleton_methods: bool, ?nest_non_public_members: bool, ?sort_nodes: bool, ?replace_attributes_with_methods: bool) -> void
10
10
  def initialize(
11
11
  add_sig_templates: false,
12
12
  group_nodes: false,
13
13
  max_line_length: nil,
14
14
  nest_singleton_methods: false,
15
15
  nest_non_public_members: false,
16
- sort_nodes: false
16
+ sort_nodes: false,
17
+ replace_attributes_with_methods: false
17
18
  )
18
19
  @add_sig_templates = add_sig_templates
19
20
  @group_nodes = group_nodes
@@ -21,6 +22,7 @@ module RBI
21
22
  @nest_singleton_methods = nest_singleton_methods
22
23
  @nest_non_public_members = nest_non_public_members
23
24
  @sort_nodes = sort_nodes
25
+ @replace_attributes_with_methods = replace_attributes_with_methods
24
26
  end
25
27
 
26
28
  #: (RBI::File file) -> String
@@ -36,6 +38,7 @@ module RBI
36
38
 
37
39
  #: (RBI::Tree tree) -> void
38
40
  def format_tree(tree)
41
+ tree.replace_attributes_with_methods! if @replace_attributes_with_methods
39
42
  tree.add_sig_templates! if @add_sig_templates
40
43
  tree.nest_singleton_methods! if @nest_singleton_methods
41
44
  tree.nest_non_public_members! if @nest_non_public_members
data/lib/rbi/index.rb CHANGED
@@ -17,7 +17,7 @@ module RBI
17
17
  #: -> void
18
18
  def initialize
19
19
  super
20
- @index = T.let({}, T::Hash[String, T::Array[Node]])
20
+ @index = {} #: Hash[String, Array[Node]]
21
21
  end
22
22
 
23
23
  #: -> Array[String]
@@ -217,7 +217,17 @@ module RBI
217
217
  # @override
218
218
  #: -> Array[String]
219
219
  def index_ids
220
- [to_s]
220
+ [fully_qualified_name]
221
+ end
222
+ end
223
+
224
+ class TEnumValue
225
+ include Indexable
226
+
227
+ # @override
228
+ #: -> Array[String]
229
+ def index_ids
230
+ [fully_qualified_name]
221
231
  end
222
232
  end
223
233
  end
data/lib/rbi/loc.rb CHANGED
@@ -50,7 +50,7 @@ module RBI
50
50
 
51
51
  string = String.new
52
52
  ::File.foreach(file).with_index do |line, line_number|
53
- string << line if line_number + 1 >= begin_line && line_number + 1 <= end_line
53
+ string << line if (line_number + 1).between?(begin_line, end_line)
54
54
  end
55
55
  string
56
56
  end
data/lib/rbi/model.rb CHANGED
@@ -45,7 +45,7 @@ module RBI
45
45
 
46
46
  #: -> Scope?
47
47
  def parent_scope
48
- parent = T.let(parent_tree, T.nilable(Tree))
48
+ parent = parent_tree #: Tree?
49
49
  parent = parent.parent_tree until parent.is_a?(Scope) || parent.nil?
50
50
  parent
51
51
  end
@@ -105,7 +105,9 @@ module RBI
105
105
  def annotations
106
106
  comments
107
107
  .select { |comment| comment.text.start_with?("@") }
108
- .map { |comment| T.must(comment.text[1..]) }
108
+ .map do |comment|
109
+ comment.text[1..] #: as !nil
110
+ end
109
111
  end
110
112
  end
111
113
 
@@ -116,7 +118,7 @@ module RBI
116
118
  #: (?loc: Loc?, ?comments: Array[Comment]) ?{ (Tree node) -> void } -> void
117
119
  def initialize(loc: nil, comments: [], &block)
118
120
  super(loc: loc, comments: comments)
119
- @nodes = T.let([], T::Array[Node])
121
+ @nodes = [] #: Array[Node]
120
122
  block&.call(self)
121
123
  end
122
124
 
@@ -144,7 +146,7 @@ module RBI
144
146
 
145
147
  #: (?strictness: String?, ?comments: Array[Comment]) ?{ (File file) -> void } -> void
146
148
  def initialize(strictness: nil, comments: [], &block)
147
- @root = T.let(Tree.new, Tree)
149
+ @root = Tree.new #: Tree
148
150
  @strictness = strictness
149
151
  @comments = comments
150
152
  block&.call(self)
@@ -313,7 +315,7 @@ module RBI
313
315
  #: (Symbol name, Array[Symbol] names, ?visibility: Visibility, ?sigs: Array[Sig], ?loc: Loc?, ?comments: Array[Comment]) -> void
314
316
  def initialize(name, names, visibility: Public.new, sigs: [], loc: nil, comments: [])
315
317
  super(loc: loc, comments: comments)
316
- @names = T.let([name, *names], T::Array[Symbol])
318
+ @names = [name, *names] #: Array[Symbol]
317
319
  @visibility = visibility
318
320
  @sigs = sigs
319
321
  end
@@ -671,7 +673,7 @@ module RBI
671
673
  #: (String name, Array[String] names, ?loc: Loc?, ?comments: Array[Comment]) -> void
672
674
  def initialize(name, names, loc: nil, comments: [])
673
675
  super(loc: loc, comments: comments)
674
- @names = T.let([name, *names], T::Array[String])
676
+ @names = [name, *names] #: Array[String]
675
677
  end
676
678
  end
677
679
 
@@ -851,7 +853,7 @@ module RBI
851
853
  attr_accessor :return_type
852
854
 
853
855
  #: bool
854
- attr_accessor :is_abstract, :is_override, :is_overridable, :is_final, :allow_incompatible_override
856
+ attr_accessor :is_abstract, :is_override, :is_overridable, :is_final, :allow_incompatible_override, :without_runtime
855
857
 
856
858
  #: Array[String]
857
859
  attr_reader :type_params
@@ -859,7 +861,7 @@ module RBI
859
861
  #: Symbol?
860
862
  attr_accessor :checked
861
863
 
862
- #: (?params: Array[SigParam], ?return_type: (Type | String), ?is_abstract: bool, ?is_override: bool, ?is_overridable: bool, ?is_final: bool, ?allow_incompatible_override: bool, ?type_params: Array[String], ?checked: Symbol?, ?loc: Loc?, ?comments: Array[Comment]) ?{ (Sig node) -> void } -> void
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
863
865
  def initialize(
864
866
  params: [],
865
867
  return_type: "void",
@@ -868,6 +870,7 @@ module RBI
868
870
  is_overridable: false,
869
871
  is_final: false,
870
872
  allow_incompatible_override: false,
873
+ without_runtime: false,
871
874
  type_params: [],
872
875
  checked: nil,
873
876
  loc: nil,
@@ -882,6 +885,7 @@ module RBI
882
885
  @is_overridable = is_overridable
883
886
  @is_final = is_final
884
887
  @allow_incompatible_override = allow_incompatible_override
888
+ @without_runtime = without_runtime
885
889
  @type_params = type_params
886
890
  @checked = checked
887
891
  block&.call(self)
@@ -903,7 +907,7 @@ module RBI
903
907
 
904
908
  params == other.params && return_type.to_s == other.return_type.to_s && is_abstract == other.is_abstract &&
905
909
  is_override == other.is_override && is_overridable == other.is_overridable && is_final == other.is_final &&
906
- type_params == other.type_params && checked == other.checked
910
+ without_runtime == other.without_runtime && type_params == other.type_params && checked == other.checked
907
911
  end
908
912
  end
909
913
 
@@ -1037,6 +1041,29 @@ module RBI
1037
1041
  end
1038
1042
  end
1039
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
1062
+ def to_s
1063
+ fully_qualified_name
1064
+ end
1065
+ end
1066
+
1040
1067
  # Sorbet's misc.
1041
1068
 
1042
1069
  class Helper < NodeWithComments
data/lib/rbi/parser.rb CHANGED
@@ -136,7 +136,28 @@ module RBI
136
136
 
137
137
  #: (Prism::Node node) -> String
138
138
  def node_string!(node)
139
- T.must(node_string(node))
139
+ node_string(node) #: as !nil
140
+ end
141
+
142
+ #: (Prism::Node node) -> Prism::Location
143
+ def adjust_prism_location_for_heredoc(node)
144
+ visitor = HeredocLocationVisitor.new(
145
+ node.location.send(:source),
146
+ node.location.start_offset,
147
+ node.location.end_offset,
148
+ )
149
+ visitor.visit(node)
150
+ visitor.location
151
+ end
152
+
153
+ #: (Prism::Node? node) -> bool
154
+ def self?(node)
155
+ node.is_a?(Prism::SelfNode)
156
+ end
157
+
158
+ #: (Prism::Node? node) -> bool
159
+ def t_sig_without_runtime?(node)
160
+ !!(node.is_a?(Prism::ConstantPathNode) && node_string(node) =~ /(::)?T::Sig::WithoutRuntime/)
140
161
  end
141
162
  end
142
163
 
@@ -151,12 +172,12 @@ module RBI
151
172
  def initialize(source, comments:, file:)
152
173
  super(source, file: file)
153
174
 
154
- @comments_by_line = T.let(comments.to_h { |c| [c.location.start_line, c] }, T::Hash[Integer, Prism::Comment])
155
- @tree = T.let(Tree.new, Tree)
175
+ @comments_by_line = comments.to_h { |c| [c.location.start_line, c] } #: Hash[Integer, Prism::Comment]
176
+ @tree = Tree.new #: Tree
156
177
 
157
- @scopes_stack = T.let([@tree], T::Array[Tree])
158
- @last_node = T.let(nil, T.nilable(Prism::Node))
159
- @last_sigs = T.let([], T::Array[RBI::Sig])
178
+ @scopes_stack = [@tree] #: Array[Tree]
179
+ @last_node = nil #: Prism::Node?
180
+ @last_sigs = [] #: Array[RBI::Sig]
160
181
  end
161
182
 
162
183
  # @override
@@ -217,30 +238,51 @@ module RBI
217
238
 
218
239
  current_scope << if struct
219
240
  struct
220
- elsif type_variable_definition?(node.value)
221
- TypeMember.new(
241
+ elsif t_enum_value?(node)
242
+ TEnumValue.new(
222
243
  case node
223
244
  when Prism::ConstantWriteNode
224
245
  node.name.to_s
225
246
  when Prism::ConstantPathWriteNode
226
247
  node_string!(node.target)
227
248
  end,
228
- node_string!(node.value),
229
249
  loc: node_loc(node),
230
250
  comments: node_comments(node),
231
251
  )
232
252
  else
233
- Const.new(
234
- case node
235
- when Prism::ConstantWriteNode
236
- node.name.to_s
237
- when Prism::ConstantPathWriteNode
238
- node_string!(node.target)
239
- end,
240
- node_string!(node.value),
241
- loc: node_loc(node),
242
- comments: node_comments(node),
253
+ adjusted_node_location = adjust_prism_location_for_heredoc(node)
254
+
255
+ adjusted_value_location = Prism::Location.new(
256
+ node.value.location.send(:source),
257
+ node.value.location.start_offset,
258
+ adjusted_node_location.end_offset - node.value.location.start_offset,
243
259
  )
260
+
261
+ if type_variable_definition?(node.value)
262
+ TypeMember.new(
263
+ case node
264
+ when Prism::ConstantWriteNode
265
+ node.name.to_s
266
+ when Prism::ConstantPathWriteNode
267
+ node_string!(node.target)
268
+ end,
269
+ adjusted_value_location.slice,
270
+ loc: Loc.from_prism(@file, adjusted_node_location),
271
+ comments: node_comments(node),
272
+ )
273
+ else
274
+ Const.new(
275
+ case node
276
+ when Prism::ConstantWriteNode
277
+ node.name.to_s
278
+ when Prism::ConstantPathWriteNode
279
+ node_string!(node.target)
280
+ end,
281
+ adjusted_value_location.slice,
282
+ loc: Loc.from_prism(@file, adjusted_node_location),
283
+ comments: node_comments(node),
284
+ )
285
+ end
244
286
  end
245
287
  end
246
288
 
@@ -473,6 +515,10 @@ module RBI
473
515
  comments: node_comments(node),
474
516
  )
475
517
  when "sig"
518
+ unless node.receiver.nil? || self?(node.receiver) || t_sig_without_runtime?(node.receiver)
519
+ @last_node = nil
520
+ return
521
+ end
476
522
  @last_sigs << parse_sig(node)
477
523
  else
478
524
  current_scope << Send.new(
@@ -509,7 +555,7 @@ module RBI
509
555
  # Collect all the remaining comments after visiting the tree
510
556
  #: -> void
511
557
  def collect_orphan_comments
512
- last_line = T.let(nil, T.nilable(Integer))
558
+ last_line = nil #: Integer?
513
559
  last_node_end = @tree.nodes.last&.loc&.end_line
514
560
 
515
561
  @comments_by_line.each do |line, comment|
@@ -532,7 +578,7 @@ module RBI
532
578
 
533
579
  #: -> Tree
534
580
  def current_scope
535
- T.must(@scopes_stack.last) # Should never be nil since we create a Tree as the root
581
+ @scopes_stack.last #: as !nil # Should never be nil since we create a Tree as the root
536
582
  end
537
583
 
538
584
  #: -> Array[Sig]
@@ -544,7 +590,7 @@ module RBI
544
590
 
545
591
  #: (Array[Sig] sigs) -> Array[Comment]
546
592
  def detach_comments_from_sigs(sigs)
547
- comments = T.let([], T::Array[Comment])
593
+ comments = [] #: Array[Comment]
548
594
 
549
595
  sigs.each do |sig|
550
596
  comments += sig.comments.dup
@@ -587,7 +633,7 @@ module RBI
587
633
 
588
634
  #: (Prism::Node? node) -> Array[Arg]
589
635
  def parse_send_args(node)
590
- args = T.let([], T::Array[Arg])
636
+ args = [] #: Array[Arg]
591
637
  return args unless node.is_a?(Prism::ArgumentsNode)
592
638
 
593
639
  node.arguments.each do |arg|
@@ -598,11 +644,13 @@ module RBI
598
644
 
599
645
  args << KwArg.new(
600
646
  node_string!(assoc.key).delete_suffix(":"),
601
- T.must(node_string(assoc.value)),
647
+ node_string(assoc.value), #: as !nil
602
648
  )
603
649
  end
604
650
  else
605
- args << Arg.new(T.must(node_string(arg)))
651
+ args << Arg.new(
652
+ node_string(arg), #: as !nil
653
+ )
606
654
  end
607
655
  end
608
656
 
@@ -703,7 +751,7 @@ module RBI
703
751
  return unless node_string(recv) =~ /(::)?Struct/
704
752
 
705
753
  members = []
706
- keyword_init = T.let(false, T::Boolean)
754
+ keyword_init = false #: bool
707
755
 
708
756
  args = send.arguments
709
757
  if args.is_a?(Prism::ArgumentsNode)
@@ -753,7 +801,7 @@ module RBI
753
801
  type = node_string!(type_arg)
754
802
  loc = node_loc(send)
755
803
  comments = node_comments(send)
756
- default_value = T.let(nil, T.nilable(String))
804
+ default_value = nil #: String?
757
805
 
758
806
  rest.each do |arg|
759
807
  next unless arg.is_a?(Prism::KeywordHashNode)
@@ -819,6 +867,19 @@ module RBI
819
867
  def type_variable_definition?(node)
820
868
  node.is_a?(Prism::CallNode) && (node.message == "type_member" || node.message == "type_template")
821
869
  end
870
+
871
+ #: (Prism::Node? node) -> bool
872
+ def t_enum_value?(node)
873
+ return false unless current_scope.is_a?(TEnumBlock)
874
+
875
+ return false unless node.is_a?(Prism::ConstantWriteNode)
876
+
877
+ value = node.value
878
+ return false unless value.is_a?(Prism::CallNode)
879
+ return false unless value.message == "new"
880
+
881
+ true
882
+ end
822
883
  end
823
884
 
824
885
  class SigBuilder < Visitor
@@ -829,7 +890,7 @@ module RBI
829
890
  def initialize(content, file:)
830
891
  super
831
892
 
832
- @current = T.let(Sig.new, Sig)
893
+ @current = Sig.new #: Sig
833
894
  end
834
895
 
835
896
  # @override
@@ -837,6 +898,8 @@ module RBI
837
898
  def visit_call_node(node)
838
899
  case node.message
839
900
  when "sig"
901
+ @current.without_runtime = t_sig_without_runtime?(node.receiver)
902
+
840
903
  args = node.arguments
841
904
  if args.is_a?(Prism::ArgumentsNode)
842
905
  args.arguments.each do |arg|
@@ -903,5 +966,59 @@ module RBI
903
966
  )
904
967
  end
905
968
  end
969
+
970
+ class HeredocLocationVisitor < Prism::Visitor
971
+ #: (Prism::Source source, Integer begin_offset, Integer end_offset) -> void
972
+ def initialize(source, begin_offset, end_offset)
973
+ super()
974
+ @source = source
975
+ @begin_offset = begin_offset
976
+ @end_offset = end_offset
977
+ @offset_last_newline = false #: bool
978
+ end
979
+
980
+ # @override
981
+ #: (Prism::StringNode node) -> void
982
+ def visit_string_node(node)
983
+ return unless node.heredoc?
984
+
985
+ closing_loc = node.closing_loc
986
+ return unless closing_loc
987
+
988
+ handle_string_node(node)
989
+ end
990
+
991
+ # @override
992
+ #: (Prism::InterpolatedStringNode node) -> void
993
+ def visit_interpolated_string_node(node)
994
+ return super unless node.heredoc?
995
+
996
+ closing_loc = node.closing_loc
997
+ return super unless closing_loc
998
+
999
+ handle_string_node(node)
1000
+ end
1001
+
1002
+ #: -> Prism::Location
1003
+ def location
1004
+ Prism::Location.new(
1005
+ @source,
1006
+ @begin_offset,
1007
+ @end_offset - @begin_offset - (@offset_last_newline ? 1 : 0),
1008
+ )
1009
+ end
1010
+
1011
+ private
1012
+
1013
+ #: (Prism::StringNode | Prism::InterpolatedStringNode node) -> void
1014
+ def handle_string_node(node)
1015
+ closing_loc = node.closing_loc #: as !nil
1016
+
1017
+ if closing_loc.end_offset > @end_offset
1018
+ @end_offset = closing_loc.end_offset
1019
+ @offset_last_newline = true if node.closing_loc&.slice&.end_with?("\n")
1020
+ end
1021
+ end
1022
+ end
906
1023
  end
907
1024
  end
data/lib/rbi/printer.rb CHANGED
@@ -23,8 +23,8 @@ module RBI
23
23
  @out = out
24
24
  @current_indent = indent
25
25
  @print_locs = print_locs
26
- @in_visibility_group = T.let(false, T::Boolean)
27
- @previous_node = T.let(nil, T.nilable(Node))
26
+ @in_visibility_group = false #: bool
27
+ @previous_node = nil #: Node?
28
28
  @max_line_length = max_line_length
29
29
  end
30
30
 
@@ -542,6 +542,16 @@ module RBI
542
542
  printl("end")
543
543
  end
544
544
 
545
+ # @override
546
+ #: (TEnumValue node) -> void
547
+ def visit_tenum_value(node)
548
+ print_blank_line_before(node)
549
+ print_loc(node)
550
+ visit_all(node.comments)
551
+
552
+ printl("#{node.name} = new")
553
+ end
554
+
545
555
  # @override
546
556
  #: (TypeMember node) -> void
547
557
  def visit_type_member(node)
@@ -675,6 +685,13 @@ module RBI
675
685
  node.comments.empty? && node.empty?
676
686
  when Attr
677
687
  node.comments.empty? && node.sigs.empty?
688
+ when Const
689
+ return false unless node.comments.empty?
690
+
691
+ loc = node.loc
692
+ return true unless loc
693
+
694
+ loc.begin_line == loc.end_line
678
695
  when Method
679
696
  node.comments.empty? && node.sigs.empty? && node.params.all? { |p| p.comments.empty? }
680
697
  when Sig
@@ -690,7 +707,9 @@ module RBI
690
707
 
691
708
  #: (Sig node) -> void
692
709
  def print_sig_as_line(node)
693
- printt("sig")
710
+ printt
711
+ print("T::Sig::WithoutRuntime.") if node.without_runtime
712
+ print("sig")
694
713
  print("(:final)") if node.is_final
695
714
  print(" { ")
696
715
  sig_modifiers(node).each do |modifier|
@@ -717,12 +736,16 @@ module RBI
717
736
  def print_sig_as_block(node)
718
737
  modifiers = sig_modifiers(node)
719
738
 
720
- printt("sig")
739
+ printt
740
+ print("T::Sig::WithoutRuntime.") if node.without_runtime
741
+ print("sig")
721
742
  print("(:final)") if node.is_final
722
743
  printn(" do")
723
744
  indent
724
745
  if modifiers.any?
725
- printl(T.must(modifiers.first))
746
+ printl(
747
+ modifiers.first, #: as !nil
748
+ )
726
749
  indent
727
750
  modifiers[1..]&.each do |modifier|
728
751
  printl(".#{modifier}")
@@ -771,7 +794,7 @@ module RBI
771
794
 
772
795
  #: (Sig node) -> Array[String]
773
796
  def sig_modifiers(node)
774
- modifiers = T.let([], T::Array[String])
797
+ modifiers = [] #: Array[String]
775
798
  modifiers << "abstract" if node.is_abstract
776
799
 
777
800
  if node.is_override
@@ -21,7 +21,7 @@ module RBI
21
21
  #: (Method) -> void
22
22
  def initialize(method)
23
23
  @method = method
24
- @result = T.let(Sig.new, Sig)
24
+ @result = Sig.new #: Sig
25
25
  end
26
26
 
27
27
  #: (::RBS::MethodType) -> void
@@ -44,7 +44,7 @@ module RBI
44
44
  raise Error, "No block param found" unless block_param
45
45
 
46
46
  block_name = block_param.name
47
- block_type = T.cast(translate_type(type.type), RBI::Type::Proc)
47
+ block_type = translate_type(type.type) #: as RBI::Type::Proc
48
48
 
49
49
  bind = type.self_type
50
50
  block_type.bind(translate_type(bind)) if bind
@@ -75,7 +75,7 @@ module RBI
75
75
  when ::RBS::Types::Optional
76
76
  Type.nilable(translate(type.type))
77
77
  when ::RBS::Types::Proc
78
- proc = T.cast(translate(type.type), Type::Proc)
78
+ proc = translate(type.type) #: as Type::Proc
79
79
  proc.bind(translate(type.self_type)) if type.self_type
80
80
  proc
81
81
  when ::RBS::Types::Record
@@ -23,9 +23,9 @@ module RBI
23
23
  @out = out
24
24
  @current_indent = indent
25
25
  @print_locs = print_locs
26
- @in_visibility_group = T.let(false, T::Boolean)
27
- @previous_node = T.let(nil, T.nilable(Node))
28
- @positional_names = T.let(positional_names, T::Boolean)
26
+ @in_visibility_group = false #: bool
27
+ @previous_node = nil #: Node?
28
+ @positional_names = positional_names #: bool
29
29
  end
30
30
 
31
31
  # Printing
@@ -316,6 +316,10 @@ module RBI
316
316
  print_blank_line_before(node)
317
317
  visit_all(node.comments)
318
318
 
319
+ if node.sigs.any?(&:without_runtime)
320
+ printl("# @without_runtime")
321
+ end
322
+
319
323
  if node.sigs.any?(&:is_abstract)
320
324
  printl("# @abstract")
321
325
  end
@@ -349,7 +353,10 @@ module RBI
349
353
  print(": ")
350
354
  if sigs.any?
351
355
  first, *rest = sigs
352
- print_method_sig(node, T.must(first))
356
+ print_method_sig(
357
+ node,
358
+ first, #: as !nil
359
+ )
353
360
  if rest.any?
354
361
  spaces = node.name.size + 4
355
362
  rest.each do |sig|
@@ -645,19 +652,22 @@ module RBI
645
652
  # @override
646
653
  #: (TEnumBlock node) -> void
647
654
  def visit_tenum_block(node)
648
- node.nodes.each do |child|
649
- child = if child.is_a?(Const) && child.value == "new"
650
- parent = node.parent_scope
651
- Const.new(
652
- child.name,
653
- "T.let(nil, #{parent.is_a?(TEnum) ? parent.name : "T.untyped"})",
654
- comments: child.comments,
655
- )
656
- else
657
- child
658
- end
659
- visit(child)
660
- @previous_node = child
655
+ visit_all(node.nodes)
656
+ end
657
+
658
+ # @override
659
+ #: (TEnumValue node) -> void
660
+ def visit_tenum_value(node)
661
+ print_blank_line_before(node)
662
+ print_loc(node)
663
+ visit_all(node.comments)
664
+
665
+ t_enum = node.parent_scope&.parent_scope
666
+
667
+ if t_enum.is_a?(TEnum)
668
+ printl("#{node.name}: #{t_enum.name}")
669
+ else
670
+ printl("#{node.name}: untyped")
661
671
  end
662
672
  end
663
673
 
@@ -882,7 +892,7 @@ module RBI
882
892
 
883
893
  #: -> void
884
894
  def initialize
885
- @string = T.let(String.new, String)
895
+ @string = String.new #: String
886
896
  end
887
897
 
888
898
  #: (Type node) -> void
@@ -41,7 +41,8 @@ module RBI
41
41
 
42
42
  child.detach
43
43
  child.is_singleton = true
44
- T.must(node.parent_tree) << child
44
+ parent_tree = node.parent_tree #: as !nil
45
+ parent_tree << child
45
46
  end
46
47
 
47
48
  node.detach if node.nodes.empty?
@@ -29,7 +29,7 @@ module RBI
29
29
  def initialize
30
30
  super
31
31
 
32
- @current_visibility = T.let([Public.new], T::Array[Visibility])
32
+ @current_visibility = [Public.new] #: Array[Visibility]
33
33
  end
34
34
 
35
35
  # @override
@@ -46,7 +46,7 @@ module RBI
46
46
  visit_all(node.nodes.dup)
47
47
  @current_visibility.pop
48
48
  when Attr, Method
49
- node.visibility = T.must(@current_visibility.last)
49
+ node.visibility = @current_visibility.last #: as !nil
50
50
  end
51
51
  end
52
52
  end
@@ -67,8 +67,8 @@ module RBI
67
67
  @left_name = left_name
68
68
  @right_name = right_name
69
69
  @keep = keep
70
- @tree = T.let(MergeTree.new, MergeTree)
71
- @scope_stack = T.let([@tree], T::Array[Tree])
70
+ @tree = MergeTree.new #: MergeTree
71
+ @scope_stack = [@tree] #: Array[Tree]
72
72
  end
73
73
 
74
74
  #: (Tree tree) -> void
@@ -99,12 +99,12 @@ module RBI
99
99
  def initialize(output, left_name: "left", right_name: "right", keep: Keep::NONE)
100
100
  super()
101
101
  @tree = output
102
- @index = T.let(output.index, Index)
103
- @scope_stack = T.let([@tree], T::Array[Tree])
102
+ @index = output.index #: Index
103
+ @scope_stack = [@tree] #: Array[Tree]
104
104
  @left_name = left_name
105
105
  @right_name = right_name
106
106
  @keep = keep
107
- @conflicts = T.let([], T::Array[Conflict])
107
+ @conflicts = [] #: Array[Conflict]
108
108
  end
109
109
 
110
110
  # @override
@@ -159,7 +159,7 @@ module RBI
159
159
 
160
160
  #: -> Tree
161
161
  def current_scope
162
- T.must(@scope_stack.last)
162
+ @scope_stack.last #: as !nil
163
163
  end
164
164
 
165
165
  #: (Node node) -> Node?
@@ -245,7 +245,7 @@ module RBI
245
245
  # @override
246
246
  #: (Array[Node] nodes) -> void
247
247
  def visit_all(nodes)
248
- last_conflict_tree = T.let(nil, T.nilable(ConflictTree))
248
+ last_conflict_tree = nil #: ConflictTree?
249
249
  nodes.dup.each do |node|
250
250
  if node.is_a?(ConflictTree)
251
251
  if last_conflict_tree
@@ -287,7 +287,7 @@ module RBI
287
287
 
288
288
  #: -> ConflictTree?
289
289
  def parent_conflict_tree
290
- parent = T.let(parent_tree, T.nilable(Node))
290
+ parent = parent_tree #: Node?
291
291
  while parent
292
292
  return parent if parent.is_a?(ConflictTree)
293
293
 
@@ -555,9 +555,9 @@ module RBI
555
555
  super()
556
556
  @left_name = left_name
557
557
  @right_name = right_name
558
- @left = T.let(Tree.new, Tree)
558
+ @left = Tree.new #: Tree
559
559
  @left.parent_tree = self
560
- @right = T.let(Tree.new, Tree)
560
+ @right = Tree.new #: Tree
561
561
  @right.parent_tree = self
562
562
  end
563
563
  end
@@ -24,7 +24,7 @@ module RBI
24
24
  def initialize
25
25
  super
26
26
 
27
- @top_level_object_class = T.let(nil, T.nilable(Class))
27
+ @top_level_object_class = nil #: Class?
28
28
  end
29
29
 
30
30
  # @override
@@ -53,7 +53,7 @@ module RBI
53
53
  def initialize(index)
54
54
  super()
55
55
  @index = index
56
- @operations = T.let([], T::Array[Operation])
56
+ @operations = [] #: Array[Operation]
57
57
  end
58
58
 
59
59
  class << self
@@ -107,10 +107,10 @@ module RBI
107
107
  when Scope
108
108
  node.empty?
109
109
  when Attr
110
- previous = T.cast(previous, Attr)
110
+ previous = previous #: as Attr
111
111
  node.names == previous.names && node.sigs == previous.sigs
112
112
  when Method
113
- previous = T.cast(previous, Method)
113
+ previous = previous #: as Method
114
114
  node.params == previous.params && node.sigs == previous.sigs
115
115
  else
116
116
  true
@@ -31,7 +31,9 @@ module RBI
31
31
  next res if res && res != 0 # we can sort the nodes by their name, let's stop here
32
32
 
33
33
  # Finally, if the two nodes have the same rank and the same name or at least one node is anonymous then,
34
- T.must(original_order[a]) <=> T.must(original_order[b]) # we keep the original order
34
+ original_order_a = original_order[a] #: as !nil
35
+ original_order_b = original_order[b] #: as !nil
36
+ original_order_a <=> original_order_b # we keep the original order
35
37
  end
36
38
  end
37
39
 
@@ -35,7 +35,7 @@ module RBI
35
35
  comments = node.comments.dup
36
36
  node.comments.clear
37
37
 
38
- rbs_sigs = T.let([], T::Array[RBSComment])
38
+ rbs_sigs = [] #: Array[RBSComment]
39
39
 
40
40
  comments.each do |comment|
41
41
  case comment
@@ -67,7 +67,7 @@ module RBI
67
67
  raise Error, "AttrWriter must have exactly one name"
68
68
  end
69
69
 
70
- name = T.must(node.names.first)
70
+ name = node.names.first #: as !nil
71
71
  sig.params << SigParam.new(name.to_s, RBS::TypeTranslator.translate(attr_type))
72
72
  end
73
73
 
data/lib/rbi/type.rb CHANGED
@@ -285,7 +285,7 @@ module RBI
285
285
  def initialize(name, *params)
286
286
  super()
287
287
  @name = name
288
- @params = T.let(params, T::Array[Type])
288
+ @params = params #: Array[Type]
289
289
  end
290
290
 
291
291
  # @override
@@ -395,9 +395,9 @@ module RBI
395
395
  #: -> void
396
396
  def initialize
397
397
  super
398
- @proc_params = T.let({}, T::Hash[Symbol, Type])
399
- @proc_returns = T.let(Type.void, Type)
400
- @proc_bind = T.let(nil, T.nilable(Type))
398
+ @proc_params = {} #: Hash[Symbol, Type]
399
+ @proc_returns = Type.void #: Type
400
+ @proc_bind = nil #: Type?
401
401
  end
402
402
 
403
403
  # @override
@@ -570,7 +570,7 @@ module RBI
570
570
  end.uniq
571
571
 
572
572
  if flattened.size == 1
573
- T.must(flattened.first)
573
+ flattened.first #: as !nil
574
574
  else
575
575
  raise ArgumentError, "RBI::Type.all should have at least 2 types supplied" if flattened.size < 2
576
576
 
@@ -596,7 +596,7 @@ module RBI
596
596
  end
597
597
  end
598
598
 
599
- is_nilable = T.let(false, T::Boolean)
599
+ is_nilable = false #: bool
600
600
 
601
601
  types = flattened.filter_map do |type|
602
602
  case type
@@ -632,7 +632,7 @@ module RBI
632
632
  raise ArgumentError, "RBI::Type.any should have at least 2 types supplied"
633
633
  end
634
634
  when 1
635
- T.must(types.first)
635
+ types.first #: as !nil
636
636
  else
637
637
  Any.new(types)
638
638
  end
@@ -693,7 +693,7 @@ module RBI
693
693
 
694
694
  #: -> void
695
695
  def initialize
696
- @nilable = T.let(false, T::Boolean)
696
+ @nilable = false #: bool
697
697
  end
698
698
 
699
699
  # Returns a new type that is `nilable` if it is not already.
@@ -18,7 +18,7 @@ module RBI
18
18
  raise Error, "Expected a type expression, got nothing" if node.statements.body.empty?
19
19
  raise Error, "Expected a single type expression, got `#{node.slice}`" if node.statements.body.size > 1
20
20
 
21
- node = T.must(node.statements.body.first)
21
+ node = node.statements.body.first #: as !nil
22
22
  parse_node(node)
23
23
  end
24
24
 
@@ -40,7 +40,9 @@ module RBI
40
40
  children = body.body
41
41
  raise Error, "Expected exactly 1 child, got #{children.size}" unless children.size == 1
42
42
 
43
- parse_node(T.must(children.first))
43
+ parse_node(
44
+ children.first, #: as !nil
45
+ )
44
46
  else
45
47
  raise Error, "Unexpected node `#{node}`"
46
48
  end
@@ -84,7 +86,11 @@ module RBI
84
86
  if t_class?(recv)
85
87
  # `T::Class[Foo]` or `::T::Class[Foo]`
86
88
  args = check_arguments_exactly!(node, 1)
87
- return Type::Class.new(parse_node(T.must(args.first)))
89
+ return Type::Class.new(
90
+ parse_node(
91
+ args.first, #: as !nil
92
+ ),
93
+ )
88
94
  else
89
95
  # `::Foo[Bar]` or `::Foo[Bar, Baz]`
90
96
  args = check_arguments_at_least!(node, 1)
@@ -94,11 +100,15 @@ module RBI
94
100
  # `T.class_of(Foo)[Bar]`
95
101
  if t_class_of?(recv)
96
102
  type_args = check_arguments_exactly!(recv, 1)
97
- type = parse_node(T.must(type_args.first))
103
+ type = parse_node(
104
+ type_args.first, #: as !nil
105
+ )
98
106
  raise Error, "Expected a simple type, got `#{type}`" unless type.is_a?(Type::Simple)
99
107
 
100
108
  type_param_args = check_arguments_exactly!(node, 1)
101
- type_param = parse_node(T.must(type_param_args.first))
109
+ type_param = parse_node(
110
+ type_param_args.first, #: as !nil
111
+ )
102
112
  return Type::ClassOf.new(type, type_param)
103
113
  end
104
114
  end
@@ -117,7 +127,9 @@ module RBI
117
127
  when :nilable
118
128
  # `T.nilable(Foo)`
119
129
  args = check_arguments_exactly!(node, 1)
120
- type = parse_node(T.must(args.first))
130
+ type = parse_node(
131
+ args.first, #: as !nil
132
+ )
121
133
  Type::Nilable.new(type)
122
134
  when :anything
123
135
  # `T.anything`
@@ -142,7 +154,9 @@ module RBI
142
154
  when :class_of
143
155
  # `T.class_of(Foo)`
144
156
  args = check_arguments_exactly!(node, 1)
145
- type = parse_node(T.must(args.first))
157
+ type = parse_node(
158
+ args.first, #: as !nil
159
+ )
146
160
  raise Error, "Expected a simple type, got `#{type}`" unless type.is_a?(Type::Simple)
147
161
 
148
162
  Type::ClassOf.new(type)
@@ -180,7 +194,9 @@ module RBI
180
194
  elem_key = elem.key
181
195
  key = case elem_key
182
196
  when Prism::SymbolNode
183
- T.must(elem_key.value).to_sym
197
+ elem_key
198
+ .value #: as !nil
199
+ .to_sym
184
200
  when Prism::StringNode
185
201
  elem_key.content
186
202
  else
@@ -216,14 +232,22 @@ module RBI
216
232
  T.unsafe(type).params(**params)
217
233
  when :returns
218
234
  args = check_arguments_exactly!(call, 1)
219
- type.returns(parse_node(T.must(args.first)))
235
+ type.returns(
236
+ parse_node(
237
+ args.first, #: as !nil
238
+ ),
239
+ )
220
240
  when :void
221
241
  type.void
222
242
  when :proc
223
243
  return type
224
244
  when :bind
225
245
  args = check_arguments_exactly!(call, 1)
226
- type.bind(parse_node(T.must(args.first)))
246
+ type.bind(
247
+ parse_node(
248
+ args.first, #: as !nil
249
+ ),
250
+ )
227
251
  else
228
252
  raise Error, "Unexpected expression `#{node.slice}`"
229
253
  end
@@ -261,8 +285,8 @@ module RBI
261
285
 
262
286
  #: (Prism::CallNode node) -> Array[Prism::Node]
263
287
  def call_chain(node)
264
- call_chain = T.let([node], T::Array[Prism::Node])
265
- receiver = T.let(node.receiver, T.nilable(Prism::Node))
288
+ call_chain = [node] #: Array[Prism::Node]
289
+ receiver = node.receiver #: Prism::Node?
266
290
  while receiver
267
291
  call_chain.prepend(receiver)
268
292
  break unless receiver.is_a?(Prism::CallNode)
data/lib/rbi/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module RBI
5
- VERSION = "0.3.1"
5
+ VERSION = "0.3.3"
6
6
  end
data/lib/rbi/visitor.rb CHANGED
@@ -88,6 +88,8 @@ module RBI
88
88
  visit_sig(node)
89
89
  when SigParam
90
90
  visit_sig_param(node)
91
+ when TEnumValue
92
+ visit_tenum_value(node)
91
93
  when TStructConst
92
94
  visit_tstruct_const(node)
93
95
  when TStructProp
@@ -222,6 +224,9 @@ module RBI
222
224
  #: (TEnumBlock node) -> void
223
225
  def visit_tenum_block(node); end
224
226
 
227
+ #: (TEnumValue node) -> void
228
+ def visit_tenum_value(node); end
229
+
225
230
  #: (Helper node) -> void
226
231
  def visit_helper(node); end
227
232
 
data/rbi/rbi.rbi CHANGED
@@ -403,10 +403,11 @@ class RBI::Formatter
403
403
  max_line_length: T.nilable(::Integer),
404
404
  nest_singleton_methods: T::Boolean,
405
405
  nest_non_public_members: T::Boolean,
406
- sort_nodes: T::Boolean
406
+ sort_nodes: T::Boolean,
407
+ replace_attributes_with_methods: T::Boolean
407
408
  ).void
408
409
  end
409
- def initialize(add_sig_templates: T.unsafe(nil), group_nodes: T.unsafe(nil), max_line_length: T.unsafe(nil), nest_singleton_methods: T.unsafe(nil), nest_non_public_members: T.unsafe(nil), sort_nodes: T.unsafe(nil)); end
410
+ def initialize(add_sig_templates: T.unsafe(nil), group_nodes: T.unsafe(nil), max_line_length: T.unsafe(nil), nest_singleton_methods: T.unsafe(nil), nest_non_public_members: T.unsafe(nil), sort_nodes: T.unsafe(nil), replace_attributes_with_methods: T.unsafe(nil)); end
410
411
 
411
412
  sig { params(file: ::RBI::File).void }
412
413
  def format_file(file); end
@@ -1005,6 +1006,25 @@ class RBI::Parser
1005
1006
  end
1006
1007
  end
1007
1008
 
1009
+ class RBI::Parser::HeredocLocationVisitor < ::Prism::Visitor
1010
+ sig { params(source: ::Prism::Source, begin_offset: ::Integer, end_offset: ::Integer).void }
1011
+ def initialize(source, begin_offset, end_offset); end
1012
+
1013
+ sig { returns(::Prism::Location) }
1014
+ def location; end
1015
+
1016
+ sig { override.params(node: ::Prism::InterpolatedStringNode).void }
1017
+ def visit_interpolated_string_node(node); end
1018
+
1019
+ sig { override.params(node: ::Prism::StringNode).void }
1020
+ def visit_string_node(node); end
1021
+
1022
+ private
1023
+
1024
+ sig { params(node: T.any(::Prism::InterpolatedStringNode, ::Prism::StringNode)).void }
1025
+ def handle_string_node(node); end
1026
+ end
1027
+
1008
1028
  class RBI::Parser::SigBuilder < ::RBI::Parser::Visitor
1009
1029
  sig { params(content: ::String, file: ::String).void }
1010
1030
  def initialize(content, file:); end
@@ -1109,6 +1129,9 @@ class RBI::Parser::TreeBuilder < ::RBI::Parser::Visitor
1109
1129
  sig { void }
1110
1130
  def set_root_tree_loc; end
1111
1131
 
1132
+ sig { params(node: T.nilable(::Prism::Node)).returns(T::Boolean) }
1133
+ def t_enum_value?(node); end
1134
+
1112
1135
  sig { params(node: T.nilable(::Prism::Node)).returns(T::Boolean) }
1113
1136
  def type_variable_definition?(node); end
1114
1137
  end
@@ -1119,6 +1142,9 @@ class RBI::Parser::Visitor < ::Prism::Visitor
1119
1142
 
1120
1143
  private
1121
1144
 
1145
+ sig { params(node: ::Prism::Node).returns(::Prism::Location) }
1146
+ def adjust_prism_location_for_heredoc(node); end
1147
+
1122
1148
  sig { params(node: ::Prism::Node).returns(::RBI::Loc) }
1123
1149
  def node_loc(node); end
1124
1150
 
@@ -1127,6 +1153,12 @@ class RBI::Parser::Visitor < ::Prism::Visitor
1127
1153
 
1128
1154
  sig { params(node: ::Prism::Node).returns(::String) }
1129
1155
  def node_string!(node); end
1156
+
1157
+ sig { params(node: T.nilable(::Prism::Node)).returns(T::Boolean) }
1158
+ def self?(node); end
1159
+
1160
+ sig { params(node: T.nilable(::Prism::Node)).returns(T::Boolean) }
1161
+ def t_sig_without_runtime?(node); end
1130
1162
  end
1131
1163
 
1132
1164
  class RBI::Printer < ::RBI::Visitor
@@ -1345,6 +1377,9 @@ class RBI::Printer < ::RBI::Visitor
1345
1377
  sig { override.params(node: ::RBI::TEnumBlock).void }
1346
1378
  def visit_tenum_block(node); end
1347
1379
 
1380
+ sig { override.params(node: ::RBI::TEnumValue).void }
1381
+ def visit_tenum_value(node); end
1382
+
1348
1383
  sig { override.params(node: ::RBI::Tree).void }
1349
1384
  def visit_tree(node); end
1350
1385
 
@@ -1658,6 +1693,9 @@ class RBI::RBSPrinter < ::RBI::Visitor
1658
1693
  sig { override.params(node: ::RBI::TEnumBlock).void }
1659
1694
  def visit_tenum_block(node); end
1660
1695
 
1696
+ sig { override.params(node: ::RBI::TEnumValue).void }
1697
+ def visit_tenum_value(node); end
1698
+
1661
1699
  sig { override.params(node: ::RBI::Tree).void }
1662
1700
  def visit_tree(node); end
1663
1701
 
@@ -2375,6 +2413,7 @@ class RBI::Sig < ::RBI::NodeWithComments
2375
2413
  is_overridable: T::Boolean,
2376
2414
  is_final: T::Boolean,
2377
2415
  allow_incompatible_override: T::Boolean,
2416
+ without_runtime: T::Boolean,
2378
2417
  type_params: T::Array[::String],
2379
2418
  checked: T.nilable(::Symbol),
2380
2419
  loc: T.nilable(::RBI::Loc),
@@ -2382,7 +2421,7 @@ class RBI::Sig < ::RBI::NodeWithComments
2382
2421
  block: T.nilable(T.proc.params(node: ::RBI::Sig).void)
2383
2422
  ).void
2384
2423
  end
2385
- def initialize(params: T.unsafe(nil), return_type: T.unsafe(nil), is_abstract: T.unsafe(nil), is_override: T.unsafe(nil), is_overridable: T.unsafe(nil), is_final: T.unsafe(nil), allow_incompatible_override: T.unsafe(nil), type_params: T.unsafe(nil), checked: T.unsafe(nil), loc: T.unsafe(nil), comments: T.unsafe(nil), &block); end
2424
+ def initialize(params: T.unsafe(nil), return_type: T.unsafe(nil), is_abstract: T.unsafe(nil), is_override: T.unsafe(nil), is_overridable: T.unsafe(nil), is_final: T.unsafe(nil), allow_incompatible_override: T.unsafe(nil), without_runtime: T.unsafe(nil), type_params: T.unsafe(nil), checked: T.unsafe(nil), loc: T.unsafe(nil), comments: T.unsafe(nil), &block); end
2386
2425
 
2387
2426
  sig { params(param: ::RBI::SigParam).void }
2388
2427
  def <<(param); end
@@ -2440,6 +2479,12 @@ class RBI::Sig < ::RBI::NodeWithComments
2440
2479
 
2441
2480
  sig { returns(T::Array[::String]) }
2442
2481
  def type_params; end
2482
+
2483
+ # @return [Boolean]
2484
+ def without_runtime; end
2485
+
2486
+ # @return [Boolean]
2487
+ def without_runtime=(_arg0); end
2443
2488
  end
2444
2489
 
2445
2490
  class RBI::SigParam < ::RBI::NodeWithComments
@@ -2549,6 +2594,32 @@ class RBI::TEnumBlock < ::RBI::Scope
2549
2594
  def to_s; end
2550
2595
  end
2551
2596
 
2597
+ class RBI::TEnumValue < ::RBI::NodeWithComments
2598
+ include ::RBI::Indexable
2599
+
2600
+ sig do
2601
+ params(
2602
+ name: ::String,
2603
+ loc: T.nilable(::RBI::Loc),
2604
+ comments: T::Array[::RBI::Comment],
2605
+ block: T.nilable(T.proc.params(node: ::RBI::TEnumValue).void)
2606
+ ).void
2607
+ end
2608
+ def initialize(name, loc: T.unsafe(nil), comments: T.unsafe(nil), &block); end
2609
+
2610
+ sig { returns(::String) }
2611
+ def fully_qualified_name; end
2612
+
2613
+ sig { override.returns(T::Array[::String]) }
2614
+ def index_ids; end
2615
+
2616
+ sig { returns(::String) }
2617
+ def name; end
2618
+
2619
+ sig { override.returns(::String) }
2620
+ def to_s; end
2621
+ end
2622
+
2552
2623
  # Sorbet's T::Struct
2553
2624
  class RBI::TStruct < ::RBI::Class
2554
2625
  sig do
@@ -3590,6 +3661,9 @@ class RBI::Visitor
3590
3661
  sig { params(node: ::RBI::TEnumBlock).void }
3591
3662
  def visit_tenum_block(node); end
3592
3663
 
3664
+ sig { params(node: ::RBI::TEnumValue).void }
3665
+ def visit_tenum_value(node); end
3666
+
3593
3667
  sig { params(node: ::RBI::Tree).void }
3594
3668
  def visit_tree(node); end
3595
3669
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexandre Terrasa
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-03-13 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: prism
@@ -110,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
110
  - !ruby/object:Gem::Version
111
111
  version: '0'
112
112
  requirements: []
113
- rubygems_version: 3.6.5
113
+ rubygems_version: 3.6.8
114
114
  specification_version: 4
115
115
  summary: RBI generation framework
116
116
  test_files: []