rbs-inline 0.3.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +10 -7
  3. data/Rakefile +12 -0
  4. data/lib/rbs/inline/annotation_parser/tokenizer.rb +361 -0
  5. data/lib/rbs/inline/annotation_parser.rb +548 -326
  6. data/lib/rbs/inline/ast/annotations.rb +446 -136
  7. data/lib/rbs/inline/ast/comment_lines.rb +32 -18
  8. data/lib/rbs/inline/ast/declarations.rb +67 -28
  9. data/lib/rbs/inline/ast/members.rb +137 -140
  10. data/lib/rbs/inline/ast/tree.rb +104 -5
  11. data/lib/rbs/inline/cli.rb +12 -12
  12. data/lib/rbs/inline/node_utils.rb +4 -0
  13. data/lib/rbs/inline/parser.rb +140 -59
  14. data/lib/rbs/inline/version.rb +1 -1
  15. data/lib/rbs/inline/writer.rb +243 -94
  16. data/lib/rbs/inline.rb +4 -0
  17. data/rbs_collection.lock.yaml +3 -7
  18. data/rbs_collection.yaml +2 -0
  19. data/sig/generated/rbs/inline/annotation_parser/tokenizer.rbs +221 -0
  20. data/sig/generated/rbs/inline/annotation_parser.rbs +148 -92
  21. data/sig/generated/rbs/inline/ast/annotations.rbs +142 -36
  22. data/sig/generated/rbs/inline/ast/comment_lines.rbs +35 -0
  23. data/sig/generated/rbs/inline/ast/declarations.rbs +29 -10
  24. data/sig/generated/rbs/inline/ast/members.rbs +33 -24
  25. data/sig/generated/rbs/inline/ast/tree.rbs +132 -0
  26. data/sig/generated/rbs/inline/cli.rbs +3 -3
  27. data/sig/generated/rbs/inline/node_utils.rbs +11 -0
  28. data/sig/generated/rbs/inline/parser.rbs +38 -18
  29. data/sig/generated/rbs/inline/version.rbs +7 -0
  30. data/sig/generated/rbs/inline/writer.rbs +104 -0
  31. data/sig/generated/rbs/inline.rbs +7 -0
  32. metadata +14 -14
  33. data/sig/rbs/inline/annotation_parser.rbs +0 -0
  34. data/sig/rbs/inline/ast/comment_lines.rbs +0 -27
  35. data/sig/rbs/inline/ast/tree.rbs +0 -98
  36. data/sig/rbs/inline/node_utils.rbs +0 -7
  37. data/sig/rbs/inline/writer.rbs +0 -27
  38. data/sig/rbs/inline.rbs +0 -41
  39. data/yard-samples/hello.rb +0 -6
  40. data/yard-samples/sample1.rb +0 -26
@@ -4,6 +4,25 @@ module RBS
4
4
  module Inline
5
5
  module AST
6
6
  module Annotations
7
+ type t = VarType | ReturnType | Use | Inherits | Generic | ModuleSelf | Skip | MethodTypeAssertion | TypeAssertion | SyntaxErrorAssertion | Dot3Assertion | Application | RBSAnnotation | Override | IvarType | Embedded | Method | SplatParamType | DoubleSplatParamType | BlockType | ModuleDecl | ClassDecl
8
+
9
+ module Utils
10
+ # @rbs (Tree) -> RBS::AST::TypeParam?
11
+ def translate_type_param: (Tree) -> RBS::AST::TypeParam?
12
+
13
+ # @rbs (Types::t) -> RBS::AST::Declarations::Class::Super?
14
+ def translate_super_class: (Types::t) -> RBS::AST::Declarations::Class::Super?
15
+
16
+ # Assumes the tree is generated through `#parse_module_name`
17
+ #
18
+ # Returns a type name, or `nil` if the tree is something invalid.
19
+ #
20
+ # @param tree -- A tree object that is generated through `#parse_module_name`
21
+ #
22
+ # @rbs (AST::Tree) -> TypeName?
23
+ def translate_type_name: (AST::Tree) -> TypeName?
24
+ end
25
+
7
26
  class Base
8
27
  attr_reader source: CommentLines
9
28
 
@@ -11,7 +30,7 @@ module RBS
11
30
 
12
31
  # @rbs tree: Tree
13
32
  # @rbs source: CommentLines
14
- # @rbs returns void
33
+ # @rbs return: void
15
34
  def initialize: (Tree tree, CommentLines source) -> void
16
35
  end
17
36
 
@@ -25,11 +44,46 @@ module RBS
25
44
  # @rbs override
26
45
  def initialize: ...
27
46
 
28
- # :: () -> bool
47
+ # : () -> bool
29
48
  def complete?: () -> bool
30
49
  end
31
50
 
32
- # `@rbs returns T`
51
+ class SpecialVarTypeAnnotation < Base
52
+ attr_reader name: Symbol?
53
+
54
+ attr_reader type: Types::t?
55
+
56
+ attr_reader comment: String?
57
+
58
+ attr_reader type_source: String
59
+
60
+ # @rbs override
61
+ def initialize: ...
62
+ end
63
+
64
+ # `@rbs *x: T`
65
+ class SplatParamType < SpecialVarTypeAnnotation
66
+ end
67
+
68
+ # `@rbs` **x: T
69
+ class DoubleSplatParamType < SpecialVarTypeAnnotation
70
+ end
71
+
72
+ # `@rbs &block: METHOD-TYPE` or `@rbs &block: ? METHOD-TYPE`
73
+ class BlockType < Base
74
+ attr_reader name: Symbol?
75
+
76
+ attr_reader type: Types::Block?
77
+
78
+ attr_reader comment: String?
79
+
80
+ attr_reader type_source: String
81
+
82
+ # @rbs override
83
+ def initialize: ...
84
+ end
85
+
86
+ # `@rbs return: T`
33
87
  class ReturnType < Base
34
88
  attr_reader type: Types::t?
35
89
 
@@ -38,7 +92,7 @@ module RBS
38
92
  # @rbs override
39
93
  def initialize: ...
40
94
 
41
- # @rbs returns bool
95
+ # @rbs return: bool
42
96
  def complete?: () -> bool
43
97
  end
44
98
 
@@ -56,53 +110,45 @@ module RBS
56
110
  def initialize: ...
57
111
  end
58
112
 
59
- # `#:: TYPE`
60
- class Assertion < Base
61
- attr_reader type: Types::t | MethodType | nil
113
+ class MethodTypeAssertion < Base
114
+ attr_reader method_type: MethodType
62
115
 
63
- def initialize: (untyped tree, untyped source) -> untyped
64
-
65
- # @rbs returns bool
66
- def complete?: () -> bool
67
-
68
- # Returns a type if it's type
69
- def type?: () -> Types::t?
116
+ # @rbs override
117
+ def initialize: ...
70
118
 
71
- # Returns a method type if it's a method type
72
- def method_type?: () -> MethodType?
119
+ def type_source: () -> String
73
120
  end
74
121
 
75
- # `#[TYPE, ..., TYPE]`
76
- class Application < Base
77
- attr_reader types: Array[Types::t]?
122
+ class TypeAssertion < Base
123
+ attr_reader type: Types::t
78
124
 
79
125
  # @rbs override
80
126
  def initialize: ...
81
127
 
82
- # @rbs returns bool
83
- def complete?: () -> bool
128
+ def type_source: () -> String
84
129
  end
85
130
 
86
- # `# @rbs yields () -> void -- Comment`
87
- class Yields < Base
88
- # The type of block
89
- #
90
- # * Types::Block when syntactically correct input is given
91
- # * String when syntax error is reported
92
- # * `nil` when nothing is given
93
- attr_reader block_type: Types::Block | String | nil
131
+ class SyntaxErrorAssertion < Base
132
+ attr_reader error_string: String
94
133
 
95
- # The content of the comment or `nil`
96
- attr_reader comment: String?
134
+ # @rbs override
135
+ def initialize: ...
136
+ end
97
137
 
98
- # If `[optional]` token is inserted just after `yields` token
99
- #
100
- # The Types::Block instance has correct `required` attribute based on the `[optional]` token.
101
- # This is for the other cases, syntax error or omitted.
102
- attr_reader optional: bool
138
+ class Dot3Assertion < Base
139
+ # @rbs override
140
+ def initialize: ...
141
+ end
142
+
143
+ # `#[TYPE, ..., TYPE]`
144
+ class Application < Base
145
+ attr_reader types: Array[Types::t]?
103
146
 
104
147
  # @rbs override
105
148
  def initialize: ...
149
+
150
+ # @rbs return: bool
151
+ def complete?: () -> bool
106
152
  end
107
153
 
108
154
  # `# @rbs %a{a} %a{a} ...`
@@ -168,6 +214,8 @@ module RBS
168
214
 
169
215
  attr_reader comment: String?
170
216
 
217
+ include Utils
218
+
171
219
  # @rbs override
172
220
  def initialize: ...
173
221
  end
@@ -179,6 +227,64 @@ module RBS
179
227
  # @rbs override
180
228
  def initialize: ...
181
229
  end
230
+
231
+ # `@rbs METHOD-TYPE``
232
+ class Method < Base
233
+ type method_type = [ MethodType, method_type? ] | String
234
+
235
+ attr_reader method_types: method_type?
236
+
237
+ # `true` if the method definition is overloading something
238
+ attr_reader overloading: bool
239
+
240
+ attr_reader type: MethodType?
241
+
242
+ attr_reader method_type_source: String
243
+
244
+ # @rbs override
245
+ def initialize: ...
246
+
247
+ # : (Array[tree]) -> method_type?
248
+ def construct_method_types: (Array[tree]) -> method_type?
249
+
250
+ # @rbs () { (MethodType) -> void } -> void
251
+ # | () -> Enumerator[MethodType, void]
252
+ def each_method_type: () { (MethodType) -> void } -> void
253
+ | () -> Enumerator[MethodType, void]
254
+
255
+ # Returns the parsing error overload string
256
+ #
257
+ # Returns `nil` if no parsing error found.
258
+ def error_source: () -> String?
259
+ end
260
+
261
+ # `@rbs module Foo`
262
+ class ModuleDecl < Base
263
+ attr_reader name: TypeName?
264
+
265
+ attr_reader type_params: Array[RBS::AST::TypeParam]
266
+
267
+ attr_reader self_types: Array[RBS::AST::Declarations::Module::Self]
268
+
269
+ include Utils
270
+
271
+ # @rbs override
272
+ def initialize: ...
273
+ end
274
+
275
+ # `@rbs class Foo`
276
+ class ClassDecl < Base
277
+ attr_reader name: TypeName?
278
+
279
+ attr_reader type_params: Array[RBS::AST::TypeParam]
280
+
281
+ attr_reader super_class: RBS::AST::Declarations::Class::Super?
282
+
283
+ include Utils
284
+
285
+ # @rbs override
286
+ def initialize: ...
287
+ end
182
288
  end
183
289
  end
184
290
  end
@@ -0,0 +1,35 @@
1
+ # Generated from lib/rbs/inline/ast/comment_lines.rb with RBS::Inline
2
+
3
+ module RBS
4
+ module Inline
5
+ module AST
6
+ # CommentLines represents consecutive comments, providing a mapping from locations in `#string` to a pair of a comment and its offset
7
+ #
8
+ # The comments construct one String.
9
+ #
10
+ # ```ruby
11
+ # # Hello <-- Comment1
12
+ # # World <-- Comment2
13
+ # ```
14
+ #
15
+ # We want to get a String of comment1 and comment2, `"Hello\nWorld".
16
+ # And want to translate a location in the string into the location in comment1 and comment2.
17
+ class CommentLines
18
+ attr_reader comments: Array[Prism::Comment]
19
+
20
+ # @rbs comments: Array[Prism::Comment]
21
+ def initialize: (Array[Prism::Comment] comments) -> void
22
+
23
+ def lines: () -> Array[String]
24
+
25
+ def string: () -> String
26
+
27
+ # Translates the cursor index of `#string` into the cursor index of a specific comment object
28
+ #
29
+ # @rbs index: Integer
30
+ # @rbs return: [Prism::Comment, Integer]?
31
+ def comment_location: (Integer index) -> [ Prism::Comment, Integer ]?
32
+ end
33
+ end
34
+ end
35
+ end
@@ -6,11 +6,11 @@ module RBS
6
6
  module Declarations
7
7
  module ConstantUtil
8
8
  # @rbs node: Prism::Node
9
- # @rbs returns TypeName?
9
+ # @rbs return: TypeName?
10
10
  def type_name: (Prism::Node node) -> TypeName?
11
11
  end
12
12
 
13
- type t = ClassDecl | ModuleDecl | ConstantDecl
13
+ type t = ClassDecl | ModuleDecl | ConstantDecl | SingletonClassDecl | BlockDecl
14
14
 
15
15
  interface _WithComments
16
16
  def comments: () -> AnnotationParser::ParsingResult?
@@ -18,7 +18,7 @@ module RBS
18
18
 
19
19
  # @rbs module-self _WithComments
20
20
  module Generics : _WithComments
21
- # @rbs returns Array[RBS::AST::TypeParam]
21
+ # @rbs return: Array[RBS::AST::TypeParam]
22
22
  def type_params: () -> Array[RBS::AST::TypeParam]
23
23
  end
24
24
 
@@ -55,7 +55,7 @@ module RBS
55
55
  # @rbs node: Prism::ClassNode
56
56
  # @rbs comments: AnnotationParser::ParsingResult?
57
57
  # @rbs super_app: Annotations::Application?
58
- # @rbs returns void
58
+ # @rbs return: void
59
59
  def initialize: (Prism::ClassNode node, AnnotationParser::ParsingResult? comments, Annotations::Application? super_app) -> void
60
60
 
61
61
  # @rbs %a{pure}
@@ -86,30 +86,49 @@ module RBS
86
86
 
87
87
  attr_reader comments: AnnotationParser::ParsingResult?
88
88
 
89
- attr_reader assertion: Annotations::Assertion?
89
+ attr_reader assertion: Annotations::TypeAssertion?
90
90
 
91
91
  # @rbs node: Prism::ConstantWriteNode
92
92
  # @rbs comments: AnnotationParser::ParsingResult?
93
- # @rbs assertion: Annotations::Assertion?
94
- def initialize: (Prism::ConstantWriteNode node, AnnotationParser::ParsingResult? comments, Annotations::Assertion? assertion) -> untyped
93
+ # @rbs assertion: Annotations::TypeAssertion?
94
+ def initialize: (Prism::ConstantWriteNode node, AnnotationParser::ParsingResult? comments, Annotations::TypeAssertion? assertion) -> void
95
95
 
96
96
  # @rbs %a{pure}
97
- # @rbs returns Types::t
97
+ # @rbs return: Types::t
98
98
  %a{pure}
99
99
  def type: () -> Types::t
100
100
 
101
101
  # @rbs %a{pure}
102
102
  # @rbs return Types::t?
103
103
  %a{pure}
104
- def literal_type: () -> untyped
104
+ def literal_type: () -> Types::t?
105
105
 
106
106
  # @rbs %a{pure}
107
- # @rbs returns TypeName?
107
+ # @rbs return: TypeName?
108
108
  %a{pure}
109
109
  def constant_name: () -> TypeName?
110
110
 
111
111
  def start_line: () -> Integer
112
112
  end
113
+
114
+ class SingletonClassDecl < ModuleOrClass[Prism::SingletonClassNode]
115
+ end
116
+
117
+ class BlockDecl < Base
118
+ attr_reader node: Prism::BlockNode
119
+
120
+ attr_reader comments: AnnotationParser::ParsingResult?
121
+
122
+ # Members included in the declaration
123
+ attr_reader members: Array[Members::t | t]
124
+
125
+ # @rbs (Prism::BlockNode, AnnotationParser::ParsingResult?) -> void
126
+ def initialize: (Prism::BlockNode, AnnotationParser::ParsingResult?) -> void
127
+
128
+ def start_line: () -> Integer
129
+
130
+ def module_class_annotation: () -> (Annotations::ModuleDecl | Annotations::ClassDecl | nil)
131
+ end
113
132
  end
114
133
  end
115
134
  end
@@ -4,6 +4,12 @@ module RBS
4
4
  module Inline
5
5
  module AST
6
6
  module Members
7
+ type ruby = RubyDef | RubyAlias | RubyMixin | RubyAttr | RubyPublic | RubyPrivate
8
+
9
+ type rbs = RBSIvar | RBSEmbedded
10
+
11
+ type t = ruby | rbs
12
+
7
13
  class Base
8
14
  attr_reader location: Prism::Location
9
15
 
@@ -31,40 +37,41 @@ module RBS
31
37
  # ```
32
38
  attr_reader visibility: RBS::AST::Members::visibility?
33
39
 
34
- attr_reader assertion: Annotations::Assertion?
40
+ # Assertion given at the end of the method name
41
+ attr_reader assertion: Annotations::TypeAssertion?
35
42
 
36
43
  # @rbs node: Prism::DefNode
37
44
  # @rbs comments: AnnotationParser::ParsingResult?
38
45
  # @rbs visibility: RBS::AST::Members::visibility?
39
- # @rbs assertion: Annotations::Assertion?
40
- def initialize: (Prism::DefNode node, AnnotationParser::ParsingResult? comments, RBS::AST::Members::visibility? visibility, Annotations::Assertion? assertion) -> void
46
+ # @rbs assertion: Annotations::TypeAssertion?
47
+ def initialize: (Prism::DefNode node, AnnotationParser::ParsingResult? comments, RBS::AST::Members::visibility? visibility, Annotations::TypeAssertion? assertion) -> void
41
48
 
42
49
  # Returns the name of the method
43
50
  def method_name: () -> Symbol
44
51
 
45
- def method_type_annotations: () -> Array[Annotations::Assertion]
46
-
47
- # Returns the `kind` of the method definition
48
- #
49
- # [FIXME] It only supports `self` receiver.
52
+ # Returns `nil` if no `@rbs METHOD-TYPE` or `#:` annotation is given
50
53
  #
51
- # ```rb
52
- # def self.foo = () # :singleton
53
- # def object.foo = () # Not supported (returns :instance)
54
- # ```
55
- def method_kind: () -> RBS::AST::Members::MethodDefinition::kind
54
+ # Returns an empty array if only `...` method type is given.
55
+ def annotated_method_types: () -> Array[MethodType]?
56
56
 
57
57
  def return_type: () -> Types::t?
58
58
 
59
59
  def var_type_hash: () -> Hash[Symbol, Types::t?]
60
60
 
61
+ def splat_param_type_annotation: () -> Annotations::SplatParamType?
62
+
63
+ def double_splat_param_type_annotation: () -> Annotations::DoubleSplatParamType?
64
+
65
+ def overloading?: () -> bool
66
+
61
67
  def method_overloads: () -> Array[RBS::AST::Members::MethodDefinition::Overload]
62
68
 
63
69
  def method_annotations: () -> Array[RBS::AST::Annotation]
64
70
 
71
+ # Returns the `@rbs override` annotation
65
72
  def override_annotation: () -> AST::Annotations::Override?
66
73
 
67
- def yields_annotation: () -> AST::Annotations::Yields?
74
+ def block_type_annotation: () -> AST::Annotations::BlockType?
68
75
  end
69
76
 
70
77
  class RubyAlias < RubyBase
@@ -74,16 +81,18 @@ module RBS
74
81
 
75
82
  # @rbs node: Prism::AliasMethodNode
76
83
  # @rbs comments: AnnotationParser::ParsingResult?
77
- def initialize: (Prism::AliasMethodNode node, AnnotationParser::ParsingResult? comments) -> untyped
84
+ def initialize: (Prism::AliasMethodNode node, AnnotationParser::ParsingResult? comments) -> void
78
85
 
79
- # @rbs returns Symbol -- the name of *old* method
86
+ # @rbs return: Symbol -- the name of *old* method
80
87
  def old_name: () -> Symbol
81
88
 
82
- # @rbs returns Symbol -- the name of *new* method
89
+ # @rbs return: Symbol -- the name of *new* method
83
90
  def new_name: () -> Symbol
84
91
  end
85
92
 
86
93
  class RubyMixin < RubyBase
94
+ include Declarations::ConstantUtil
95
+
87
96
  # CallNode that calls `include`, `prepend`, and `extend` method
88
97
  attr_reader node: Prism::CallNode
89
98
 
@@ -96,10 +105,10 @@ module RBS
96
105
  # @rbs node: Prism::CallNode
97
106
  # @rbs comments: AnnotationParser::ParsingResult?
98
107
  # @rbs application: Annotations::Application?
99
- # @rbs returns void
108
+ # @rbs return: void
100
109
  def initialize: (Prism::CallNode node, AnnotationParser::ParsingResult? comments, Annotations::Application? application) -> void
101
110
 
102
- # @rbs returns ::RBS::AST::Members::Include
111
+ # @rbs return: ::RBS::AST::Members::Include
103
112
  # | ::RBS::AST::Members::Extend
104
113
  # | ::RBS::AST::Members::Prepend
105
114
  # | nil
@@ -111,16 +120,16 @@ module RBS
111
120
 
112
121
  attr_reader comments: AnnotationParser::ParsingResult?
113
122
 
114
- attr_reader assertion: Annotations::Assertion?
123
+ attr_reader assertion: Annotations::TypeAssertion?
115
124
 
116
125
  # @rbs node: Prism::CallNode
117
126
  # @rbs comments: AnnotationParser::ParsingResult?
118
- # @rbs assertion: Annotations::Assertion?
119
- # @rbs returns void
120
- def initialize: (Prism::CallNode node, AnnotationParser::ParsingResult? comments, Annotations::Assertion? assertion) -> void
127
+ # @rbs assertion: Annotations::TypeAssertion?
128
+ # @rbs return: void
129
+ def initialize: (Prism::CallNode node, AnnotationParser::ParsingResult? comments, Annotations::TypeAssertion? assertion) -> void
121
130
 
122
131
  # @rbs return Array[RBS::AST::Members::AttrReader | RBS::AST::Members::AttrWriter | RBS::AST::Members::AttrAccessor]?
123
- def rbs: () -> untyped
132
+ def rbs: () -> Array[RBS::AST::Members::AttrReader | RBS::AST::Members::AttrWriter | RBS::AST::Members::AttrAccessor]?
124
133
 
125
134
  # Returns the type of the attribute
126
135
  #
@@ -0,0 +1,132 @@
1
+ # Generated from lib/rbs/inline/ast/tree.rb with RBS::Inline
2
+
3
+ module RBS
4
+ module Inline
5
+ module AST
6
+ type token = [ Symbol, String ]
7
+
8
+ type tree = token | Tree | Types::t | MethodType | nil
9
+
10
+ class Tree
11
+ attr_reader trees: Array[tree]
12
+
13
+ attr_reader type: Symbol
14
+
15
+ # Children but without `tWHITESPACE` tokens
16
+ attr_reader non_trivia_trees: Array[tree]
17
+
18
+ # @rbs type: Symbol
19
+ def initialize: (Symbol type) -> void
20
+
21
+ # @rbs tok: tree
22
+ # @rbs return: self
23
+ def <<: (tree tok) -> self
24
+
25
+ # Returns the source code associated to the tree
26
+ def to_s: () -> String
27
+
28
+ # Returns `true` if token at the given index is of the given type
29
+ def token?: (untyped type, at: untyped) -> untyped
30
+
31
+ # Returns `true` if tree at the given index is of the given type
32
+ def tree?: (untyped type, at: untyped) -> untyped
33
+
34
+ # Returns n-th token from the children
35
+ #
36
+ # Raises if the value is not a token or nil.
37
+ #
38
+ # @rbs index: Integer
39
+ # @rbs return: token?
40
+ def nth_token: (Integer index) -> token?
41
+
42
+ # Returns n-th token from the children
43
+ #
44
+ # Returns `nil` if the value is not a token.
45
+ #
46
+ # @rbs index: Integer
47
+ # @rbs return: token?
48
+ def nth_token?: (Integer index) -> token?
49
+
50
+ # Returns n-th token from the children
51
+ #
52
+ # Raises if the value is not token.
53
+ #
54
+ # @rbs index: Integer
55
+ # @rbs return: token
56
+ def nth_token!: (Integer index) -> token
57
+
58
+ # Returns n-th tree from the children
59
+ #
60
+ # Raises if the value is not a tree or nil.
61
+ #
62
+ # @rbs index: Integer
63
+ # @rbs return: Tree?
64
+ def nth_tree: (Integer index) -> Tree?
65
+
66
+ # Returns n-th tree from the children
67
+ #
68
+ # Returns `nil` if the value is not a tree or nil.
69
+ #
70
+ # @rbs index: Integer
71
+ # @rbs return: Tree?
72
+ def nth_tree?: (Integer index) -> Tree?
73
+
74
+ # Returns n-th tree from the children
75
+ #
76
+ # Raises if the value is not a tree.
77
+ #
78
+ # @rbs index: Integer
79
+ # @rbs return: Tree
80
+ def nth_tree!: (Integer index) -> Tree
81
+
82
+ # Returns n-th type from the children
83
+ #
84
+ # Raises if the value is not a type or nil.
85
+ #
86
+ # @rbs index: Integer
87
+ # @rbs return: Types::t?
88
+ def nth_type: (Integer index) -> Types::t?
89
+
90
+ # Returns n-th type from the children
91
+ #
92
+ # Returns `nil` if the value is not a type.
93
+ #
94
+ # @rbs index: Integer
95
+ # @rbs return: Types::t?
96
+ def nth_type?: (Integer index) -> Types::t?
97
+
98
+ # Returns n-th type from the children
99
+ #
100
+ # Raises if the value is not a type.
101
+ #
102
+ # @rbs index: Integer
103
+ # @rbs return: Types::t
104
+ def nth_type!: (Integer index) -> Types::t
105
+
106
+ # Returns n-th method type from the children
107
+ #
108
+ # Raises if the value is not a method type or `nil`.
109
+ #
110
+ # @rbs index: Integer
111
+ # @rbs return: MethodType?
112
+ def nth_method_type: (Integer index) -> MethodType?
113
+
114
+ # Returns n-th method type from the children
115
+ #
116
+ # Returns `nil` if the value is not a method type.
117
+ #
118
+ # @rbs index: Integer
119
+ # @rbs return: MethodType?
120
+ def nth_method_type?: (Integer index) -> MethodType?
121
+
122
+ # Returns n-th method tree from the children
123
+ #
124
+ # Raises if the value is not a method tree.
125
+ #
126
+ # @rbs index: Integer
127
+ # @rbs return: MethodType
128
+ def nth_method_type!: (Integer index) -> MethodType
129
+ end
130
+ end
131
+ end
132
+ end
@@ -25,12 +25,12 @@ module RBS
25
25
  # @rbs output_path: Pathname
26
26
  def initialize: (Pathname pwd, Array[Pathname] base_paths, Pathname output_path) -> void
27
27
 
28
- # :: (Pathname) -> Pathname?
28
+ # : (Pathname) -> Pathname?
29
29
  def calculate: (Pathname) -> Pathname?
30
30
 
31
31
  # @rbs path: Pathname
32
32
  # @rbs prefix: Pathname
33
- # @rbs returns bool
33
+ # @rbs return: bool
34
34
  def has_prefix?: (Pathname path, prefix: Pathname) -> bool
35
35
  end
36
36
 
@@ -45,7 +45,7 @@ module RBS
45
45
  def initialize: (?stdout: IO, ?stderr: IO) -> void
46
46
 
47
47
  # @rbs args: Array[String]
48
- # @rbs returns Integer
48
+ # @rbs return: Integer
49
49
  def run: (Array[String] args) -> Integer
50
50
  end
51
51
  end
@@ -0,0 +1,11 @@
1
+ # Generated from lib/rbs/inline/node_utils.rb with RBS::Inline
2
+
3
+ module RBS
4
+ module Inline
5
+ module NodeUtils
6
+ # @rbs node: Prism::Node
7
+ # @rbs return: TypeName?
8
+ def type_name: (Prism::Node node) -> TypeName?
9
+ end
10
+ end
11
+ end