rbs-inline 0.9.0 → 0.11.0

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: f73d1f3ac7e111f773fe9b2d034dc5ccc3a8732f50aacf1a07655ad3450e24f4
4
- data.tar.gz: '082c1f8a6ef85a239f29563f1e95d6af0ac0af89c5860a6c552d56505a0a27ba'
3
+ metadata.gz: 83b5fc9f8e331ee20d2e8dc61604dc9a21693dcf6869f79e29eebbc885c45554
4
+ data.tar.gz: 5c7a7abdc5acbf156bbd914ccaaa2eb86a54086ddf6562b6fc6f485921b120a0
5
5
  SHA512:
6
- metadata.gz: 6002e610f1440abbfe351ee3c746e6c4c1f6dcae1a885fc9a5f60d701ebd0548620d8c6ffc6211bffd5830fd9c65901f7d7155d6de049a8670f0b72749f55b0c
7
- data.tar.gz: 61041de88fbc0048f48fc46c012e1d1a7ff66760aef73e288f60351705425f466d84a4d50488feac54bb58e50fb504916596a8ceaf8ee5f99c76919227ee431e
6
+ metadata.gz: e4acaf6c3c40bcee7639b9d7f482b8e3acc47466c5069c15437c9f2205775938f6acba61ba4afe4612ab98a65dbeb4e2fd7894c6bc0071512edce0e89db76632
7
+ data.tar.gz: ab895615e1dab1d9ce750e55ee06499cfd224de8df9b754c592fd2224d8d89c33d2f64f14c312a9f61515e60627fd247f6d5646eb51d1b1731ed10b60b9c1524
data/README.md CHANGED
@@ -2,9 +2,6 @@
2
2
 
3
3
  RBS::Inline allows embedding RBS type declarations into Ruby code as comments. You can declare types, write the implementation, and verifies they are consistent without leaving the editor opening the Ruby code.
4
4
 
5
- > [!IMPORTANT]
6
- > The syntax is experimental. We are still seeking the best syntax with your feedbacks.
7
-
8
5
  > [!IMPORTANT]
9
6
  > This gem is a prototype for testing. We plan to merge this feature to rbs-gem and deprecate rbs-inline gem after that.
10
7
 
@@ -21,6 +18,8 @@ class Person
21
18
 
22
19
  attr_reader :addresses #: Array[String]
23
20
 
21
+ # You can write the type of parameters and return types.
22
+ #
24
23
  # @rbs name: String
25
24
  # @rbs addresses: Array[String]
26
25
  # @rbs return: void
@@ -29,10 +28,20 @@ class Person
29
28
  @addresses = addresses
30
29
  end
31
30
 
32
- def to_s #: String
31
+ # Or write the type of the method just after `@rbs` keyword.
32
+ #
33
+ # @rbs () -> String
34
+ def to_s
33
35
  "Person(name = #{name}, addresses = #{addresses.join(", ")})"
34
36
  end
35
37
 
38
+ # The `:` syntax is the shortest one.
39
+ #
40
+ #: () -> String
41
+ def hash
42
+ [name, addresses].hash
43
+ end
44
+
36
45
  # @rbs &block: (String) -> void
37
46
  def each_address(&block) #: void
38
47
  addresses.each(&block)
@@ -482,7 +482,7 @@ module RBS
482
482
  case last_token
483
483
  when Array
484
484
  # `*` clause
485
- namespace = Namespace(token_strs.join)
485
+ namespace = RBS::Namespace.parse(token_strs.join)
486
486
  @clauses << RBS::AST::Directives::Use::WildcardClause.new(
487
487
  namespace: namespace,
488
488
  location: nil
@@ -189,7 +189,7 @@ module RBS
189
189
 
190
190
  # @rbs %a{pure}
191
191
  # @rbs return: Types::t
192
- def type
192
+ def type(default_type)
193
193
  if assertion
194
194
  case assertion.type
195
195
  when MethodType, nil
@@ -203,7 +203,7 @@ module RBS
203
203
  return literal
204
204
  end
205
205
 
206
- Types::Bases::Any.new(location: nil)
206
+ default_type
207
207
  end
208
208
 
209
209
  # @rbs %a{pure}
@@ -41,6 +41,10 @@ module RBS
41
41
  # ```
42
42
  attr_reader :visibility #: RBS::AST::Members::visibility?
43
43
 
44
+ # The function is defined as singleton and instance method (as known as module_function)
45
+ #
46
+ attr_accessor :singleton_instance #: bool
47
+
44
48
  # Assertion given at the end of the method name
45
49
  #
46
50
  attr_reader :assertion #: Annotations::TypeAssertion?
@@ -48,11 +52,13 @@ module RBS
48
52
  # @rbs node: Prism::DefNode
49
53
  # @rbs comments: AnnotationParser::ParsingResult?
50
54
  # @rbs visibility: RBS::AST::Members::visibility?
55
+ # @rbs singleton_instance: bool
51
56
  # @rbs assertion: Annotations::TypeAssertion?
52
- def initialize(node, comments, visibility, assertion) #: void
57
+ def initialize(node, comments, visibility, singleton_instance, assertion) #: void
53
58
  @node = node
54
59
  @comments = comments
55
60
  @visibility = visibility
61
+ @singleton_instance = singleton_instance
56
62
  @assertion = assertion
57
63
 
58
64
  super(node.location)
@@ -152,7 +158,8 @@ module RBS
152
158
  end
153
159
  end
154
160
 
155
- def method_overloads #: Array[RBS::AST::Members::MethodDefinition::Overload]
161
+ # @rbs (::RBS::Types::t default_type) -> Array[RBS::AST::Members::MethodDefinition::Overload]
162
+ def method_overloads(default_type)
156
163
  case
157
164
  when method_types = annotated_method_types
158
165
  method_types.map do |method_type|
@@ -175,7 +182,7 @@ module RBS
175
182
  when Prism::RequiredParameterNode
176
183
  required_positionals << Types::Function::Param.new(
177
184
  name: param.name,
178
- type: var_type_hash[param.name] || Types::Bases::Any.new(location: nil),
185
+ type: var_type_hash[param.name] || default_type,
179
186
  location: nil
180
187
  )
181
188
  end
@@ -186,7 +193,7 @@ module RBS
186
193
  when Prism::OptionalParameterNode
187
194
  optional_positionals << Types::Function::Param.new(
188
195
  name: param.name,
189
- type: var_type_hash[param.name] || Types::Bases::Any.new(location: nil),
196
+ type: var_type_hash[param.name] || default_type,
190
197
  location: nil
191
198
  )
192
199
  end
@@ -201,7 +208,7 @@ module RBS
201
208
 
202
209
  rest_positionals = Types::Function::Param.new(
203
210
  name: rest.name,
204
- type: splat_type || Types::Bases::Any.new(location: nil),
211
+ type: splat_type || default_type,
205
212
  location: nil
206
213
  )
207
214
  end
@@ -210,7 +217,7 @@ module RBS
210
217
  if node.is_a?(Prism::RequiredKeywordParameterNode)
211
218
  required_keywords[node.name] = Types::Function::Param.new(
212
219
  name: nil,
213
- type: var_type_hash[node.name] || Types::Bases::Any.new(location: nil),
220
+ type: var_type_hash[node.name] || default_type,
214
221
  location: nil
215
222
  )
216
223
  end
@@ -218,7 +225,7 @@ module RBS
218
225
  if node.is_a?(Prism::OptionalKeywordParameterNode)
219
226
  optional_keywords[node.name] = Types::Function::Param.new(
220
227
  name: nil,
221
- type: var_type_hash[node.name] || Types::Bases::Any.new(location: nil),
228
+ type: var_type_hash[node.name] || default_type,
222
229
  location: nil
223
230
  )
224
231
  end
@@ -233,13 +240,13 @@ module RBS
233
240
 
234
241
  rest_keywords = Types::Function::Param.new(
235
242
  name: kw_rest.name,
236
- type: double_splat_type || Types::Bases::Any.new(location: nil),
243
+ type: double_splat_type || default_type,
237
244
  location: nil)
238
245
  end
239
246
 
240
247
  if node.parameters.block
241
248
  block = Types::Block.new(
242
- type: Types::UntypedFunction.new(return_type: Types::Bases::Any.new(location: nil)),
249
+ type: Types::UntypedFunction.new(return_type: default_type),
243
250
  required: false,
244
251
  self_type: nil
245
252
  )
@@ -262,7 +269,7 @@ module RBS
262
269
  required_keywords: required_keywords,
263
270
  optional_keywords: optional_keywords,
264
271
  rest_keywords: rest_keywords,
265
- return_type: return_type || Types::Bases::Any.new(location: nil)
272
+ return_type: return_type || default_type
266
273
  ),
267
274
  block: block,
268
275
  location: nil
@@ -408,22 +415,26 @@ module RBS
408
415
  class RubyAttr < RubyBase
409
416
  attr_reader :node #: Prism::CallNode
410
417
  attr_reader :comments #: AnnotationParser::ParsingResult?
418
+ attr_reader :visibility #: RBS::AST::Members::visibility?
411
419
  attr_reader :assertion #: Annotations::TypeAssertion?
412
420
 
413
421
  # @rbs node: Prism::CallNode
414
422
  # @rbs comments: AnnotationParser::ParsingResult?
423
+ # @rbs visibility: RBS::AST::Members::visibility?
415
424
  # @rbs assertion: Annotations::TypeAssertion?
416
425
  # @rbs return: void
417
- def initialize(node, comments, assertion)
426
+ def initialize(node, comments, visibility, assertion)
418
427
  super(node.location)
419
428
 
420
429
  @node = node
421
430
  @comments = comments
431
+ @visibility = visibility
422
432
  @assertion = assertion
423
433
  end
424
434
 
425
435
  # @rbs return Array[RBS::AST::Members::AttrReader | RBS::AST::Members::AttrWriter | RBS::AST::Members::AttrAccessor]?
426
- def rbs
436
+ # @rbs default_type: RBS::Types::t
437
+ def rbs(default_type)
427
438
  if comments
428
439
  comment = RBS::AST::Comment.new(string: comments.content(trim: true), location: nil)
429
440
  end
@@ -454,13 +465,13 @@ module RBS
454
465
  args.map do |arg|
455
466
  klass.new(
456
467
  name: arg,
457
- type: attribute_type,
468
+ type: attribute_type || default_type,
458
469
  ivar_name: nil,
459
470
  kind: :instance,
460
471
  annotations: [],
461
472
  location: nil,
462
473
  comment: comment,
463
- visibility: nil
474
+ visibility: visibility
464
475
  )
465
476
  end
466
477
  end
@@ -468,13 +479,11 @@ module RBS
468
479
 
469
480
  # Returns the type of the attribute
470
481
  #
471
- # Returns `untyped` when not annotated.
472
- #
473
- def attribute_type #: Types::t
482
+ def attribute_type #: Types::t?
474
483
  type = assertion&.type
475
484
  raise if type.is_a?(MethodType)
476
485
 
477
- type || Types::Bases::Any.new(location: nil)
486
+ type
478
487
  end
479
488
  end
480
489
 
@@ -73,6 +73,7 @@ module RBS
73
73
  base_paths = [Pathname("lib"), Pathname("app")]
74
74
  output_path = nil #: Pathname?
75
75
  opt_in = true
76
+ unknown_type = nil #: String?
76
77
 
77
78
  OptionParser.new do |opts|
78
79
  opts.on("--base=BASE", "The path to calculate relative path of files (defaults to #{base_paths.join(File::PATH_SEPARATOR)})") do |str|
@@ -96,6 +97,10 @@ module RBS
96
97
  opt_in = true
97
98
  end
98
99
 
100
+ opts.on("--unknown-type=TYPE", "Use given type instead of untyped for unknown types (default: untyped)") do
101
+ unknown_type = _1
102
+ end
103
+
99
104
  opts.on("--verbose") do
100
105
  logger.level = :DEBUG
101
106
  end
@@ -141,6 +146,12 @@ module RBS
141
146
 
142
147
  if (uses, decls, rbs_decls = Parser.parse(Prism.parse_file(target.to_s), opt_in: opt_in))
143
148
  writer = Writer.new()
149
+
150
+ if unknown_type
151
+ type = RBS::Parser.parse_type(unknown_type, require_eof: true)
152
+ type && writer.default_type = type
153
+ end
154
+
144
155
  writer.header("Generated from #{target.relative? ? target : target.relative_path_from(Pathname.pwd)} with RBS::Inline")
145
156
  writer.write(uses, decls, rbs_decls)
146
157
 
@@ -37,10 +37,14 @@ module RBS
37
37
  #
38
38
  attr_reader :current_visibility #: RBS::AST::Members::visibility?
39
39
 
40
+ # The current module_function applied to single `def` node
41
+ attr_reader :current_module_function #: bool
42
+
40
43
  def initialize() #: void
41
44
  @decls = []
42
45
  @surrounding_decls = []
43
46
  @comments = {}
47
+ @current_module_function = false
44
48
  end
45
49
 
46
50
  # Parses the given Prism result to a three tuple
@@ -253,9 +257,7 @@ module RBS
253
257
 
254
258
  assertion = assertion_annotation(node.rparen_loc || node&.parameters&.location || node.name_loc)
255
259
 
256
- current_decl.members << AST::Members::RubyDef.new(node, associated_comment, current_visibility, assertion)
257
-
258
- super
260
+ current_decl.members << AST::Members::RubyDef.new(node, associated_comment, current_visibility, current_module_function, assertion)
259
261
  end
260
262
  end
261
263
 
@@ -302,7 +304,7 @@ module RBS
302
304
  end #: AST::Annotations::TypeAssertion?
303
305
  end
304
306
 
305
- current_class_module_decl!.members << AST::Members::RubyAttr.new(node, comment, assertion)
307
+ current_class_module_decl!.members << AST::Members::RubyAttr.new(node, comment, current_visibility, assertion)
306
308
 
307
309
  return
308
310
  end
@@ -331,6 +333,30 @@ module RBS
331
333
  end
332
334
  end
333
335
  end
336
+ when :module_function
337
+ if node.arguments && node.arguments.arguments.size > 0
338
+ args = node.arguments.arguments.filter_map do |arg|
339
+ case arg
340
+ when Prism::SymbolNode
341
+ arg.unescaped.to_sym
342
+ end
343
+ end
344
+
345
+ current_decl = current_class_module_decl
346
+
347
+ if current_decl
348
+ node.arguments.arguments.each do |arg|
349
+ current_decl.members.each do |member|
350
+ if member.is_a?(AST::Members::RubyDef) && args.include?(member.node.name)
351
+ member.singleton_instance = true
352
+ break
353
+ end
354
+ end
355
+ end
356
+ end
357
+ else
358
+ @current_module_function = true
359
+ end
334
360
  end
335
361
 
336
362
  super
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RBS
4
4
  module Inline
5
- VERSION = "0.9.0"
5
+ VERSION = "0.11.0"
6
6
  end
7
7
  end
@@ -1,5 +1,7 @@
1
1
  # rbs_inline: enabled
2
2
 
3
+ require 'stringio'
4
+
3
5
  module RBS
4
6
  module Inline
5
7
  class Writer
@@ -13,17 +15,22 @@ module RBS
13
15
  attr_reader :output #: String
14
16
  attr_reader :writer #: RBS::Writer
15
17
 
18
+ attr_accessor :default_type #: Types::t
19
+
16
20
  # @rbs buffer: String
17
21
  def initialize(buffer = +"") #: void
18
22
  @output = buffer
19
23
  @writer = RBS::Writer.new(out: StringIO.new(buffer))
24
+ @default_type = Types::Bases::Any.new(location: nil)
20
25
  end
21
26
 
22
27
  # @rbs uses: Array[AST::Annotations::Use]
23
28
  # @rbs decls: Array[AST::Declarations::t]
24
29
  # @rbs rbs_decls: Array[RBS::AST::Declarations::t]
25
- def self.write(uses, decls, rbs_decls) #: void
30
+ # @rbs &: ? (Writer) -> void
31
+ def self.write(uses, decls, rbs_decls, &) #: void
26
32
  writer = Writer.new()
33
+ yield writer if block_given?
27
34
  writer.write(uses, decls, rbs_decls)
28
35
  writer.output
29
36
  end
@@ -198,7 +205,7 @@ module RBS
198
205
  attributes = decl.each_attribute.map do |name, type|
199
206
  RBS::AST::Members::AttrReader.new(
200
207
  name: name,
201
- type: type&.type || Types::Bases::Any.new(location: nil),
208
+ type: type&.type || default_type,
202
209
  ivar_name: false,
203
210
  comment: nil,
204
211
  kind: :instance,
@@ -218,7 +225,7 @@ module RBS
218
225
  type: Types::Function.empty(Types::Bases::Instance.new(location: nil)).update(
219
226
  required_positionals: decl.each_attribute.map do |name, attr|
220
227
  RBS::Types::Function::Param.new(
221
- type: attr&.type || Types::Bases::Any.new(location: nil),
228
+ type: attr&.type || default_type,
222
229
  name: name,
223
230
  location: nil
224
231
  )
@@ -237,7 +244,7 @@ module RBS
237
244
  [
238
245
  name,
239
246
  RBS::Types::Function::Param.new(
240
- type: attr&.type || Types::Bases::Any.new(location: nil),
247
+ type: attr&.type || default_type,
241
248
  name: nil,
242
249
  location: nil
243
250
  )
@@ -315,7 +322,7 @@ module RBS
315
322
  if decl.readonly_attributes?
316
323
  RBS::AST::Members::AttrReader.new(
317
324
  name: name,
318
- type: type&.type || Types::Bases::Any.new(location: nil),
325
+ type: type&.type || default_type,
319
326
  ivar_name: false,
320
327
  comment: nil,
321
328
  kind: :instance,
@@ -326,7 +333,7 @@ module RBS
326
333
  else
327
334
  RBS::AST::Members::AttrAccessor.new(
328
335
  name: name,
329
- type: type&.type || Types::Bases::Any.new(location: nil),
336
+ type: type&.type || default_type,
330
337
  ivar_name: false,
331
338
  comment: nil,
332
339
  kind: :instance,
@@ -351,7 +358,7 @@ module RBS
351
358
  if decl.positional_init?
352
359
  attr_params = decl.each_attribute.map do |name, attr|
353
360
  RBS::Types::Function::Param.new(
354
- type: attr&.type || Types::Bases::Any.new(location: nil),
361
+ type: attr&.type || default_type,
355
362
  name: name,
356
363
  location: nil
357
364
  )
@@ -376,7 +383,7 @@ module RBS
376
383
  [
377
384
  name,
378
385
  RBS::Types::Function::Param.new(
379
- type: attr&.type || Types::Bases::Any.new(location: nil),
386
+ type: attr&.type || default_type,
380
387
  name: nil,
381
388
  location: nil
382
389
  )
@@ -405,7 +412,7 @@ module RBS
405
412
  t.update(required_positionals: [
406
413
  RBS::Types::Function::Param.new(
407
414
  type: RBS::Types::Record.new(all_fields: decl.each_attribute.map do |name, attr|
408
- [name, attr&.type || Types::Bases::Any.new(location: nil)]
415
+ [name, attr&.type || default_type]
409
416
  end.to_h, location: nil),
410
417
  name: nil,
411
418
  location: nil
@@ -426,7 +433,12 @@ module RBS
426
433
  members: [*attributes, new],
427
434
  super_class: RBS::AST::Declarations::Class::Super.new(
428
435
  name: RBS::TypeName.new(name: :Struct, namespace: RBS::Namespace.empty),
429
- args: [RBS::Types::Bases::Any.new(location: nil)],
436
+ args: [
437
+ RBS::Types::Union.new(
438
+ types: decl.each_attribute.map { |_, attr| attr&.type || default_type }.uniq,
439
+ location: nil
440
+ )
441
+ ],
430
442
  location: nil
431
443
  ),
432
444
  annotations: decl.class_annotations,
@@ -478,7 +490,7 @@ module RBS
478
490
  rbs << RBS::AST::Members::MethodDefinition.new(
479
491
  name: member.method_name,
480
492
  kind: kind,
481
- overloads: member.method_overloads,
493
+ overloads: member.method_overloads(default_type),
482
494
  annotations: member.method_annotations,
483
495
  location: nil,
484
496
  comment: comment,
@@ -490,10 +502,11 @@ module RBS
490
502
  comment = RBS::AST::Comment.new(string: member.comments.content(trim: true), location: nil)
491
503
  end
492
504
 
505
+ kind = decl ? :singleton : :instance #: RBS::AST::Members::Alias::kind
493
506
  rbs << RBS::AST::Members::Alias.new(
494
507
  new_name: member.new_name,
495
508
  old_name: member.old_name,
496
- kind: :instance,
509
+ kind: kind,
497
510
  annotations: [],
498
511
  location: nil,
499
512
  comment: comment
@@ -503,7 +516,7 @@ module RBS
503
516
  rbs << m
504
517
  end
505
518
  when AST::Members::RubyAttr
506
- if m = member.rbs
519
+ if m = member.rbs(default_type)
507
520
  rbs.concat m
508
521
  end
509
522
  when AST::Members::RubyPrivate
@@ -542,6 +555,7 @@ module RBS
542
555
  # @rbs return: RBS::AST::Members::MethodDefinition::kind
543
556
  def method_kind(member, decl)
544
557
  return :singleton if decl
558
+ return :singleton_instance if member.singleton_instance
545
559
 
546
560
  case member.node.receiver
547
561
  when Prism::SelfNode
@@ -612,24 +626,19 @@ module RBS
612
626
  # @rbs decl: AST::Declarations::ConstantDecl
613
627
  # @rbs return: RBS::Types::t
614
628
  def constant_decl_to_type(decl)
615
- type = decl.type
629
+ type = decl.type(default_type)
616
630
  return type unless type.is_a?(RBS::Types::ClassInstance)
617
631
  return type if type.args.any?
618
632
 
619
633
  case decl.node.value
620
634
  when Prism::ArrayNode
621
- RBS::BuiltinNames::Array.instance_type(untyped)
635
+ RBS::BuiltinNames::Array.instance_type(default_type)
622
636
  when Prism::HashNode
623
- RBS::BuiltinNames::Hash.instance_type(untyped, untyped)
637
+ RBS::BuiltinNames::Hash.instance_type(default_type, default_type)
624
638
  else
625
639
  type
626
640
  end
627
641
  end
628
-
629
- # @rbs return: RBS::Types::Bases::Any
630
- def untyped
631
- @untyped ||= RBS::Types::Bases::Any.new(location: nil)
632
- end
633
642
  end
634
643
  end
635
644
  end
@@ -34,7 +34,7 @@ gems:
34
34
  source:
35
35
  type: stdlib
36
36
  - name: prism
37
- version: 1.0.0
37
+ version: 1.2.0
38
38
  source:
39
39
  type: rubygems
40
40
  - name: rake
@@ -42,11 +42,11 @@ gems:
42
42
  source:
43
43
  type: git
44
44
  name: ruby/gem_rbs_collection
45
- revision: 25b8cf2135233e112d93d6b64083ee5e419875b6
45
+ revision: 218cf130d31f63e110e350efc3fa265311b0f238
46
46
  remote: https://github.com/ruby/gem_rbs_collection.git
47
47
  repo_dir: gems
48
48
  - name: rbs
49
- version: 3.6.0
49
+ version: 3.6.1
50
50
  source:
51
51
  type: rubygems
52
52
  - name: rdoc
@@ -99,7 +99,7 @@ module RBS
99
99
  # @rbs %a{pure}
100
100
  # @rbs return: Types::t
101
101
  %a{pure}
102
- def type: () -> Types::t
102
+ def type: (untyped default_type) -> Types::t
103
103
 
104
104
  # @rbs %a{pure}
105
105
  # @rbs return Types::t?
@@ -37,14 +37,18 @@ module RBS
37
37
  # ```
38
38
  attr_reader visibility: RBS::AST::Members::visibility?
39
39
 
40
+ # The function is defined as singleton and instance method (as known as module_function)
41
+ attr_accessor singleton_instance: bool
42
+
40
43
  # Assertion given at the end of the method name
41
44
  attr_reader assertion: Annotations::TypeAssertion?
42
45
 
43
46
  # @rbs node: Prism::DefNode
44
47
  # @rbs comments: AnnotationParser::ParsingResult?
45
48
  # @rbs visibility: RBS::AST::Members::visibility?
49
+ # @rbs singleton_instance: bool
46
50
  # @rbs assertion: Annotations::TypeAssertion?
47
- def initialize: (Prism::DefNode node, AnnotationParser::ParsingResult? comments, RBS::AST::Members::visibility? visibility, Annotations::TypeAssertion? assertion) -> void
51
+ def initialize: (Prism::DefNode node, AnnotationParser::ParsingResult? comments, RBS::AST::Members::visibility? visibility, bool singleton_instance, Annotations::TypeAssertion? assertion) -> void
48
52
 
49
53
  # Returns the name of the method
50
54
  def method_name: () -> Symbol
@@ -64,7 +68,8 @@ module RBS
64
68
 
65
69
  def overloading?: () -> bool
66
70
 
67
- def method_overloads: () -> Array[RBS::AST::Members::MethodDefinition::Overload]
71
+ # @rbs (::RBS::Types::t default_type) -> Array[RBS::AST::Members::MethodDefinition::Overload]
72
+ def method_overloads: (::RBS::Types::t default_type) -> Array[RBS::AST::Members::MethodDefinition::Overload]
68
73
 
69
74
  def method_annotations: () -> Array[RBS::AST::Annotation]
70
75
 
@@ -120,21 +125,23 @@ module RBS
120
125
 
121
126
  attr_reader comments: AnnotationParser::ParsingResult?
122
127
 
128
+ attr_reader visibility: RBS::AST::Members::visibility?
129
+
123
130
  attr_reader assertion: Annotations::TypeAssertion?
124
131
 
125
132
  # @rbs node: Prism::CallNode
126
133
  # @rbs comments: AnnotationParser::ParsingResult?
134
+ # @rbs visibility: RBS::AST::Members::visibility?
127
135
  # @rbs assertion: Annotations::TypeAssertion?
128
136
  # @rbs return: void
129
- def initialize: (Prism::CallNode node, AnnotationParser::ParsingResult? comments, Annotations::TypeAssertion? assertion) -> void
137
+ def initialize: (Prism::CallNode node, AnnotationParser::ParsingResult? comments, RBS::AST::Members::visibility? visibility, Annotations::TypeAssertion? assertion) -> void
130
138
 
131
139
  # @rbs return Array[RBS::AST::Members::AttrReader | RBS::AST::Members::AttrWriter | RBS::AST::Members::AttrAccessor]?
132
- def rbs: () -> Array[RBS::AST::Members::AttrReader | RBS::AST::Members::AttrWriter | RBS::AST::Members::AttrAccessor]?
140
+ # @rbs default_type: RBS::Types::t
141
+ def rbs: (RBS::Types::t default_type) -> Array[RBS::AST::Members::AttrReader | RBS::AST::Members::AttrWriter | RBS::AST::Members::AttrAccessor]?
133
142
 
134
143
  # Returns the type of the attribute
135
- #
136
- # Returns `untyped` when not annotated.
137
- def attribute_type: () -> Types::t
144
+ def attribute_type: () -> Types::t?
138
145
  end
139
146
 
140
147
  # `private` call without arguments
@@ -30,6 +30,9 @@ module RBS
30
30
  # `nil` when the `def` node is not inside `private` or `public` calls.
31
31
  attr_reader current_visibility: RBS::AST::Members::visibility?
32
32
 
33
+ # The current module_function applied to single `def` node
34
+ attr_reader current_module_function: bool
35
+
33
36
  def initialize: () -> void
34
37
 
35
38
  # Parses the given Prism result to a three tuple
@@ -13,13 +13,16 @@ module RBS
13
13
 
14
14
  attr_reader writer: RBS::Writer
15
15
 
16
+ attr_accessor default_type: Types::t
17
+
16
18
  # @rbs buffer: String
17
19
  def initialize: (?String buffer) -> void
18
20
 
19
21
  # @rbs uses: Array[AST::Annotations::Use]
20
22
  # @rbs decls: Array[AST::Declarations::t]
21
23
  # @rbs rbs_decls: Array[RBS::AST::Declarations::t]
22
- def self.write: (Array[AST::Annotations::Use] uses, Array[AST::Declarations::t] decls, Array[RBS::AST::Declarations::t] rbs_decls) -> void
24
+ # @rbs &: ? (Writer) -> void
25
+ def self.write: (Array[AST::Annotations::Use] uses, Array[AST::Declarations::t] decls, Array[RBS::AST::Declarations::t] rbs_decls) ?{ (Writer) -> void } -> void
23
26
 
24
27
  # @rbs *lines: String
25
28
  # @rbs return: void
@@ -111,9 +114,6 @@ module RBS
111
114
  # @rbs decl: AST::Declarations::ConstantDecl
112
115
  # @rbs return: RBS::Types::t
113
116
  def constant_decl_to_type: (AST::Declarations::ConstantDecl decl) -> RBS::Types::t
114
-
115
- # @rbs return: RBS::Types::Bases::Any
116
- def untyped: () -> RBS::Types::Bases::Any
117
117
  end
118
118
  end
119
119
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbs-inline
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Soutaro Matsumoto
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-10-01 00:00:00.000000000 Z
10
+ date: 2025-03-06 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: prism
@@ -19,7 +18,7 @@ dependencies:
19
18
  version: '0.29'
20
19
  - - "<"
21
20
  - !ruby/object:Gem::Version
22
- version: '1.1'
21
+ version: '1.3'
23
22
  type: :runtime
24
23
  prerelease: false
25
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +28,7 @@ dependencies:
29
28
  version: '0.29'
30
29
  - - "<"
31
30
  - !ruby/object:Gem::Version
32
- version: '1.1'
31
+ version: '1.3'
33
32
  - !ruby/object:Gem::Dependency
34
33
  name: rbs
35
34
  requirement: !ruby/object:Gem::Requirement
@@ -95,7 +94,6 @@ metadata:
95
94
  homepage_uri: https://github.com/soutaro/rbs-inline
96
95
  source_code_uri: https://github.com/soutaro/rbs-inline
97
96
  changelog_uri: https://github.com/soutaro/rbs-inline/blob/master/CHANGELOG.md
98
- post_install_message:
99
97
  rdoc_options: []
100
98
  require_paths:
101
99
  - lib
@@ -110,8 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
108
  - !ruby/object:Gem::Version
111
109
  version: '0'
112
110
  requirements: []
113
- rubygems_version: 3.5.11
114
- signing_key:
111
+ rubygems_version: 3.6.2
115
112
  specification_version: 4
116
113
  summary: Inline RBS type declaration.
117
114
  test_files: []