rbs 4.0.0.dev.4 → 4.0.0.dev.5

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.
Files changed (223) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +14 -14
  3. data/.github/workflows/bundle-update.yml +60 -0
  4. data/.github/workflows/c-check.yml +11 -8
  5. data/.github/workflows/comments.yml +3 -3
  6. data/.github/workflows/dependabot.yml +1 -1
  7. data/.github/workflows/ruby.yml +17 -34
  8. data/.github/workflows/typecheck.yml +2 -2
  9. data/.github/workflows/valgrind.yml +42 -0
  10. data/.github/workflows/windows.yml +2 -2
  11. data/.rubocop.yml +1 -1
  12. data/README.md +1 -1
  13. data/Rakefile +32 -5
  14. data/config.yml +46 -0
  15. data/core/array.rbs +96 -46
  16. data/core/binding.rbs +0 -2
  17. data/core/builtin.rbs +2 -2
  18. data/core/comparable.rbs +13 -6
  19. data/core/complex.rbs +55 -41
  20. data/core/dir.rbs +4 -4
  21. data/core/encoding.rbs +7 -10
  22. data/core/enumerable.rbs +90 -3
  23. data/core/enumerator/arithmetic_sequence.rbs +70 -0
  24. data/core/enumerator.rbs +63 -1
  25. data/core/errno.rbs +8 -0
  26. data/core/errors.rbs +28 -1
  27. data/core/exception.rbs +2 -2
  28. data/core/fiber.rbs +40 -20
  29. data/core/file.rbs +108 -78
  30. data/core/file_test.rbs +1 -1
  31. data/core/float.rbs +225 -69
  32. data/core/gc.rbs +417 -281
  33. data/core/hash.rbs +1023 -727
  34. data/core/integer.rbs +104 -110
  35. data/core/io/buffer.rbs +21 -10
  36. data/core/io/wait.rbs +11 -33
  37. data/core/io.rbs +82 -19
  38. data/core/kernel.rbs +70 -59
  39. data/core/marshal.rbs +1 -1
  40. data/core/match_data.rbs +1 -1
  41. data/core/math.rbs +42 -3
  42. data/core/method.rbs +63 -27
  43. data/core/module.rbs +103 -26
  44. data/core/nil_class.rbs +3 -3
  45. data/core/numeric.rbs +43 -35
  46. data/core/object.rbs +3 -3
  47. data/core/object_space.rbs +21 -15
  48. data/core/pathname.rbs +1272 -0
  49. data/core/proc.rbs +30 -25
  50. data/core/process.rbs +4 -2
  51. data/core/ractor.rbs +361 -509
  52. data/core/random.rbs +17 -0
  53. data/core/range.rbs +113 -16
  54. data/core/rational.rbs +56 -85
  55. data/core/rbs/unnamed/argf.rbs +2 -2
  56. data/core/rbs/unnamed/env_class.rbs +1 -1
  57. data/core/rbs/unnamed/random.rbs +4 -113
  58. data/core/regexp.rbs +25 -20
  59. data/core/ruby.rbs +53 -0
  60. data/core/ruby_vm.rbs +6 -4
  61. data/core/rubygems/errors.rbs +3 -70
  62. data/core/rubygems/rubygems.rbs +11 -79
  63. data/core/rubygems/version.rbs +2 -3
  64. data/core/set.rbs +488 -359
  65. data/core/signal.rbs +24 -14
  66. data/core/string.rbs +3171 -1241
  67. data/core/struct.rbs +1 -1
  68. data/core/symbol.rbs +17 -11
  69. data/core/thread.rbs +95 -33
  70. data/core/time.rbs +35 -9
  71. data/core/trace_point.rbs +7 -4
  72. data/core/unbound_method.rbs +14 -6
  73. data/docs/aliases.md +79 -0
  74. data/docs/collection.md +2 -2
  75. data/docs/encoding.md +56 -0
  76. data/docs/gem.md +0 -1
  77. data/docs/inline.md +470 -0
  78. data/docs/sigs.md +3 -3
  79. data/docs/syntax.md +33 -4
  80. data/docs/type_fingerprint.md +21 -0
  81. data/exe/rbs +1 -1
  82. data/ext/rbs_extension/ast_translation.c +77 -3
  83. data/ext/rbs_extension/ast_translation.h +3 -0
  84. data/ext/rbs_extension/class_constants.c +8 -2
  85. data/ext/rbs_extension/class_constants.h +4 -0
  86. data/ext/rbs_extension/extconf.rb +5 -1
  87. data/ext/rbs_extension/legacy_location.c +5 -5
  88. data/ext/rbs_extension/main.c +37 -20
  89. data/include/rbs/ast.h +85 -38
  90. data/include/rbs/defines.h +27 -0
  91. data/include/rbs/lexer.h +30 -11
  92. data/include/rbs/parser.h +6 -6
  93. data/include/rbs/string.h +0 -2
  94. data/include/rbs/util/rbs_allocator.h +34 -13
  95. data/include/rbs/util/rbs_assert.h +12 -1
  96. data/include/rbs/util/rbs_encoding.h +2 -0
  97. data/include/rbs/util/rbs_unescape.h +2 -1
  98. data/lib/rbs/ast/annotation.rb +1 -1
  99. data/lib/rbs/ast/comment.rb +1 -1
  100. data/lib/rbs/ast/declarations.rb +10 -10
  101. data/lib/rbs/ast/members.rb +14 -14
  102. data/lib/rbs/ast/ruby/annotations.rb +137 -0
  103. data/lib/rbs/ast/ruby/comment_block.rb +24 -0
  104. data/lib/rbs/ast/ruby/declarations.rb +198 -3
  105. data/lib/rbs/ast/ruby/helpers/constant_helper.rb +4 -0
  106. data/lib/rbs/ast/ruby/members.rb +159 -1
  107. data/lib/rbs/ast/type_param.rb +24 -4
  108. data/lib/rbs/buffer.rb +20 -15
  109. data/lib/rbs/cli/diff.rb +16 -15
  110. data/lib/rbs/cli/validate.rb +38 -51
  111. data/lib/rbs/cli.rb +52 -19
  112. data/lib/rbs/collection/config/lockfile_generator.rb +8 -0
  113. data/lib/rbs/collection/sources/git.rb +1 -0
  114. data/lib/rbs/definition.rb +1 -1
  115. data/lib/rbs/definition_builder/ancestor_builder.rb +62 -9
  116. data/lib/rbs/definition_builder/method_builder.rb +20 -0
  117. data/lib/rbs/definition_builder.rb +91 -2
  118. data/lib/rbs/diff.rb +7 -1
  119. data/lib/rbs/environment.rb +227 -74
  120. data/lib/rbs/environment_loader.rb +0 -6
  121. data/lib/rbs/errors.rb +27 -7
  122. data/lib/rbs/inline_parser.rb +341 -5
  123. data/lib/rbs/location_aux.rb +1 -1
  124. data/lib/rbs/locator.rb +5 -1
  125. data/lib/rbs/method_type.rb +5 -3
  126. data/lib/rbs/parser_aux.rb +2 -2
  127. data/lib/rbs/prototype/rb.rb +2 -2
  128. data/lib/rbs/prototype/rbi.rb +2 -0
  129. data/lib/rbs/prototype/runtime.rb +8 -0
  130. data/lib/rbs/resolver/constant_resolver.rb +2 -2
  131. data/lib/rbs/resolver/type_name_resolver.rb +116 -38
  132. data/lib/rbs/subtractor.rb +3 -1
  133. data/lib/rbs/test/type_check.rb +16 -2
  134. data/lib/rbs/type_name.rb +1 -1
  135. data/lib/rbs/types.rb +27 -27
  136. data/lib/rbs/validator.rb +2 -2
  137. data/lib/rbs/version.rb +1 -1
  138. data/lib/rbs.rb +1 -1
  139. data/lib/rdoc/discover.rb +1 -1
  140. data/lib/rdoc_plugin/parser.rb +1 -1
  141. data/rbs.gemspec +3 -2
  142. data/schema/typeParam.json +17 -1
  143. data/sig/ast/ruby/annotations.rbs +124 -0
  144. data/sig/ast/ruby/comment_block.rbs +8 -0
  145. data/sig/ast/ruby/declarations.rbs +102 -4
  146. data/sig/ast/ruby/members.rbs +87 -1
  147. data/sig/cli/diff.rbs +5 -11
  148. data/sig/cli/validate.rbs +13 -4
  149. data/sig/cli.rbs +18 -18
  150. data/sig/definition.rbs +6 -1
  151. data/sig/environment.rbs +70 -12
  152. data/sig/errors.rbs +13 -6
  153. data/sig/inline_parser.rbs +39 -2
  154. data/sig/locator.rbs +0 -2
  155. data/sig/manifest.yaml +0 -1
  156. data/sig/method_builder.rbs +3 -1
  157. data/sig/method_types.rbs +1 -1
  158. data/sig/parser.rbs +16 -2
  159. data/sig/resolver/type_name_resolver.rbs +35 -7
  160. data/sig/source.rbs +3 -3
  161. data/sig/type_param.rbs +13 -8
  162. data/sig/types.rbs +4 -4
  163. data/src/ast.c +80 -1
  164. data/src/lexer.c +1392 -1313
  165. data/src/lexer.re +3 -0
  166. data/src/lexstate.c +58 -37
  167. data/src/location.c +4 -4
  168. data/src/parser.c +412 -145
  169. data/src/string.c +0 -48
  170. data/src/util/rbs_allocator.c +89 -71
  171. data/src/util/rbs_assert.c +1 -1
  172. data/src/util/rbs_buffer.c +2 -2
  173. data/src/util/rbs_constant_pool.c +10 -10
  174. data/src/util/rbs_encoding.c +4 -8
  175. data/src/util/rbs_unescape.c +56 -20
  176. data/stdlib/bigdecimal/0/big_decimal.rbs +100 -82
  177. data/stdlib/bigdecimal-math/0/big_math.rbs +169 -8
  178. data/stdlib/cgi/0/core.rbs +9 -393
  179. data/stdlib/cgi/0/manifest.yaml +1 -0
  180. data/stdlib/cgi-escape/0/escape.rbs +171 -0
  181. data/stdlib/coverage/0/coverage.rbs +3 -1
  182. data/stdlib/date/0/date.rbs +67 -59
  183. data/stdlib/date/0/date_time.rbs +1 -1
  184. data/stdlib/delegate/0/delegator.rbs +10 -7
  185. data/stdlib/digest/0/digest.rbs +110 -0
  186. data/stdlib/erb/0/erb.rbs +737 -347
  187. data/stdlib/fileutils/0/fileutils.rbs +20 -14
  188. data/stdlib/forwardable/0/forwardable.rbs +3 -0
  189. data/stdlib/json/0/json.rbs +82 -28
  190. data/stdlib/net-http/0/net-http.rbs +3 -0
  191. data/stdlib/objspace/0/objspace.rbs +9 -27
  192. data/stdlib/open-uri/0/open-uri.rbs +40 -0
  193. data/stdlib/open3/0/open3.rbs +459 -1
  194. data/stdlib/openssl/0/openssl.rbs +331 -228
  195. data/stdlib/optparse/0/optparse.rbs +8 -3
  196. data/stdlib/pathname/0/pathname.rbs +9 -1379
  197. data/stdlib/psych/0/psych.rbs +4 -4
  198. data/stdlib/random-formatter/0/random-formatter.rbs +277 -0
  199. data/stdlib/rdoc/0/code_object.rbs +2 -1
  200. data/stdlib/rdoc/0/parser.rbs +1 -1
  201. data/stdlib/rdoc/0/rdoc.rbs +1 -1
  202. data/stdlib/rdoc/0/store.rbs +1 -1
  203. data/stdlib/resolv/0/resolv.rbs +25 -68
  204. data/stdlib/ripper/0/ripper.rbs +2 -2
  205. data/stdlib/securerandom/0/manifest.yaml +2 -0
  206. data/stdlib/securerandom/0/securerandom.rbs +6 -19
  207. data/stdlib/singleton/0/singleton.rbs +3 -0
  208. data/stdlib/socket/0/socket.rbs +13 -1
  209. data/stdlib/socket/0/tcp_socket.rbs +10 -2
  210. data/stdlib/stringio/0/stringio.rbs +1176 -85
  211. data/stdlib/strscan/0/string_scanner.rbs +31 -31
  212. data/stdlib/tempfile/0/tempfile.rbs +3 -3
  213. data/stdlib/time/0/time.rbs +1 -1
  214. data/stdlib/timeout/0/timeout.rbs +63 -7
  215. data/stdlib/tsort/0/cyclic.rbs +3 -0
  216. data/stdlib/uri/0/common.rbs +16 -2
  217. data/stdlib/uri/0/file.rbs +1 -1
  218. data/stdlib/uri/0/generic.rbs +24 -16
  219. data/stdlib/uri/0/rfc2396_parser.rbs +6 -7
  220. data/stdlib/zlib/0/gzip_reader.rbs +2 -2
  221. data/stdlib/zlib/0/gzip_writer.rbs +1 -1
  222. data/stdlib/zlib/0/zstream.rbs +1 -0
  223. metadata +30 -4
@@ -6,8 +6,12 @@ module RBS
6
6
  | MethodTypesAnnotation
7
7
  | SkipAnnotation
8
8
  | ReturnTypeAnnotation
9
+ | InstanceVariableAnnotation
9
10
 
10
11
  type trailing_annotation = NodeTypeAssertion
12
+ | TypeApplicationAnnotation
13
+ | ClassAliasAnnotation
14
+ | ModuleAliasAnnotation
11
15
 
12
16
  type t = leading_annotation | trailing_annotation
13
17
 
@@ -23,6 +27,9 @@ module RBS
23
27
  def initialize: (Location location, Location prefix_location) -> void
24
28
 
25
29
  def buffer: () -> Buffer
30
+
31
+ # Returns the type fingerprint for this annotation
32
+ def type_fingerprint: () -> untyped
26
33
  end
27
34
 
28
35
  # `: TYPE` annotation attached to nodes
@@ -33,6 +40,51 @@ module RBS
33
40
  def initialize: (location: Location, prefix_location: Location, type: Types::t) -> void
34
41
 
35
42
  def map_type_name: () { (TypeName) -> TypeName } -> self
43
+
44
+ def type_fingerprint: () -> untyped
45
+ end
46
+
47
+ class AliasAnnotation < Base
48
+ attr_reader keyword_location: Location
49
+
50
+ attr_reader type_name_location: Location?
51
+
52
+ # The name of the module that will be the target of the alias
53
+ #
54
+ # - `nil` if the module/class name is unspecified
55
+ # - `TypeName` object if the module/class name is specified
56
+ #
57
+ attr_reader type_name: TypeName?
58
+
59
+ def initialize: (location: Location, prefix_location: Location, keyword_location: Location, type_name: TypeName?, type_name_location: Location?) -> void
60
+
61
+ def map_type_name: () { (TypeName) -> TypeName } -> self
62
+ end
63
+
64
+ # `: class-alias` annotation
65
+ #
66
+ # ```
67
+ # : class-alias Foo::Bar
68
+ # ^ -- prefix_location
69
+ # ^^^^^^^^^^^^ -- keyword_location
70
+ # ^^^^^^^^ -- type_name_location
71
+ # ```
72
+ #
73
+ class ClassAliasAnnotation < AliasAnnotation
74
+ def type_fingerprint: () -> untyped
75
+ end
76
+
77
+ # `: module-alias` annotation
78
+ #
79
+ # ```
80
+ # : module-alias Foo::Bar
81
+ # ^ -- prefix_location
82
+ # ^^^^^^^^^^^^ -- keyword_location
83
+ # ^^^^^^^^ -- type_name_location
84
+ # ```
85
+ #
86
+ class ModuleAliasAnnotation < AliasAnnotation
87
+ def type_fingerprint: () -> untyped
36
88
  end
37
89
 
38
90
  # `: METHOD-TYPE` annotation in leading comments
@@ -45,6 +97,8 @@ module RBS
45
97
  def initialize: (location: Location, prefix_location: Location, annotations: Array[AST::Annotation], method_type: MethodType) -> void
46
98
 
47
99
  def map_type_name: () { (TypeName) -> TypeName } -> self
100
+
101
+ def type_fingerprint: () -> untyped
48
102
  end
49
103
 
50
104
  # `@rbs METHOD-TYPEs` annotation in leading comments
@@ -64,6 +118,8 @@ module RBS
64
118
  def initialize: (location: Location, prefix_location: Location, overloads: Array[Overload], vertical_bar_locations: Array[Location]) -> void
65
119
 
66
120
  def map_type_name: () { (TypeName) -> TypeName } -> self
121
+
122
+ def type_fingerprint: () -> untyped
67
123
  end
68
124
 
69
125
  # `@rbs skip -- comment` annotation in leading comments
@@ -73,6 +129,8 @@ module RBS
73
129
  attr_reader comment_location: Location?
74
130
 
75
131
  def initialize: (location: Location, prefix_location: Location, skip_location: Location, comment_location: Location?) -> void
132
+
133
+ def type_fingerprint: () -> untyped
76
134
  end
77
135
 
78
136
  # `@rbs return: T -- comment` annotation in leading comments
@@ -103,6 +161,72 @@ module RBS
103
161
  ) -> void
104
162
 
105
163
  def map_type_name: () { (TypeName) -> TypeName } -> self
164
+
165
+ def type_fingerprint: () -> untyped
166
+ end
167
+
168
+ # `[T1, T2, ...]` annotation in trailing comments
169
+ #
170
+ # ```
171
+ # #[String, Integer]
172
+ # ^ -- prefix_location
173
+ # ^ -- comma_locations[0]
174
+ # ^ -- close_bracket_location
175
+ # ```
176
+ #
177
+ class TypeApplicationAnnotation < Base
178
+ attr_reader type_args: Array[Types::t]
179
+
180
+ attr_reader close_bracket_location: Location
181
+
182
+ attr_reader comma_locations: Array[Location]
183
+
184
+ def initialize: (
185
+ location: Location,
186
+ prefix_location: Location,
187
+ type_args: Array[Types::t],
188
+ close_bracket_location: Location,
189
+ comma_locations: Array[Location],
190
+ ) -> void
191
+
192
+ def map_type_name: () { (TypeName) -> TypeName } -> self
193
+
194
+ def type_fingerprint: () -> untyped
195
+ end
196
+
197
+ # `@rbs IVAR-NAME : TYPE` annotation in leading comments
198
+ #
199
+ # ```
200
+ # @rbs @foo : String -- comment
201
+ # ^^^^ -- prefix_location
202
+ # ^^^^ -- ivar_name_location
203
+ # ^ -- colon_location
204
+ # ^^^^^^^^^^ -- comment_location
205
+ # ```
206
+ class InstanceVariableAnnotation < Base
207
+ attr_reader ivar_name: Symbol
208
+
209
+ attr_reader ivar_name_location: Location
210
+
211
+ attr_reader colon_location: Location
212
+
213
+ attr_reader type: Types::t
214
+
215
+ attr_reader comment_location: Location?
216
+
217
+ def initialize: (
218
+ location: Location,
219
+ prefix_location: Location,
220
+ ivar_name: Symbol,
221
+ ivar_name_location: Location,
222
+ colon_location: Location,
223
+ type: Types::t,
224
+ comment_location: Location?,
225
+ ) -> void
226
+
227
+ def map_type_name: () { (TypeName) -> TypeName } -> self
228
+
229
+ def type_fingerprint: () -> untyped
106
230
  end
107
231
  end
108
232
  end
@@ -112,7 +112,15 @@ module RBS
112
112
 
113
113
  def line_location: (Integer start_line, Integer end_line) -> Location
114
114
 
115
+ def location: () -> Location
116
+
115
117
  private def leading_annotation?: (Integer index) -> bool
118
+
119
+ # Returns an comment object that contains the docs of from the comment block
120
+ #
121
+ # It ignores type annotations and syntax errors.
122
+ #
123
+ def as_comment: () -> AST::Comment?
116
124
  end
117
125
  end
118
126
  end
@@ -2,7 +2,7 @@ module RBS
2
2
  module AST
3
3
  module Ruby
4
4
  module Declarations
5
- type t = ClassDecl | ModuleDecl
5
+ type t = ClassDecl | ModuleDecl | ConstantDecl | ClassModuleAliasDecl
6
6
 
7
7
  class Base
8
8
  attr_reader buffer: Buffer
@@ -11,27 +11,55 @@ module RBS
11
11
  include Helpers::LocationHelper
12
12
 
13
13
  def initialize: (Buffer) -> void
14
+
15
+ def type_fingerprint: () -> untyped
14
16
  end
15
17
 
16
18
  class ClassDecl < Base
19
+ class SuperClass
20
+ attr_reader operator_location: Location
21
+
22
+ attr_reader type_name_location: Location
23
+
24
+ attr_reader type_name: TypeName
25
+
26
+ attr_reader type_annotation: Annotations::TypeApplicationAnnotation?
27
+
28
+ def type_args: () -> Array[Types::t]
29
+
30
+ alias name type_name
31
+
32
+ alias args type_args
33
+
34
+ def initialize: (Location type_name_location, Location operator_location, TypeName, RBS::AST::Ruby::Annotations::TypeApplicationAnnotation?) -> void
35
+
36
+ def location: () -> Location
37
+
38
+ def type_fingerprint: () -> untyped
39
+ end
40
+
17
41
  type member = t | Members::t
18
42
 
19
43
  attr_reader class_name: TypeName
20
44
 
21
45
  attr_reader node: Prism::ClassNode
22
46
 
47
+ attr_reader super_class: SuperClass?
48
+
23
49
  attr_reader members: Array[member]
24
50
 
25
- def initialize: (Buffer, TypeName, Prism::ClassNode) -> void
51
+ def initialize: (Buffer, TypeName, Prism::ClassNode, SuperClass?) -> void
26
52
 
27
53
  def each_decl: () { (t) -> void } -> void
28
54
  | () -> Enumerator[t]
29
55
 
30
- def super_class: () -> nil
31
-
32
56
  def type_params: () -> Array[AST::TypeParam]
33
57
 
34
58
  def location: () -> Location
59
+
60
+ def name_location: () -> Location
61
+
62
+ def type_fingerprint: () -> untyped
35
63
  end
36
64
 
37
65
  class ModuleDecl < Base
@@ -53,6 +81,76 @@ module RBS
53
81
  def location: () -> Location
54
82
 
55
83
  def self_types: () -> Array[AST::Declarations::Module::Self]
84
+
85
+ def name_location: () -> Location
86
+
87
+ def type_fingerprint: () -> untyped
88
+ end
89
+
90
+ class ConstantDecl < Base
91
+ type node = Prism::ConstantWriteNode | Prism::ConstantPathWriteNode
92
+
93
+ attr_reader leading_comment: CommentBlock?
94
+
95
+ attr_reader constant_name: TypeName
96
+
97
+ attr_reader node: node
98
+
99
+ attr_reader type_annotation: Annotations::NodeTypeAssertion?
100
+
101
+ def initialize: (Buffer, TypeName, node, CommentBlock?, Annotations::NodeTypeAssertion?) -> void
102
+
103
+ def location: () -> Location
104
+
105
+ def name_location: () -> Location
106
+
107
+ # Returns the type of the constant
108
+ #
109
+ # - When type_anntoation is given, it returns the type from the annotation.
110
+ # - When type_annotation is not given, it returns infered type from the right-hand-side of the constant assignment
111
+ # - Or it returns `untyped` type
112
+ #
113
+ def type: () -> Types::t
114
+
115
+ # Returns the comment content extracted from the leading comment block
116
+ #
117
+ def comment: () -> AST::Comment?
118
+
119
+ def type_fingerprint: () -> untyped
120
+ end
121
+
122
+ class ClassModuleAliasDecl < Base
123
+ type node = Prism::ConstantWriteNode | Prism::ConstantPathWriteNode
124
+
125
+ type annotation = Annotations::ClassAliasAnnotation | Annotations::ModuleAliasAnnotation
126
+
127
+ attr_reader node: node
128
+
129
+ attr_reader leading_comment: CommentBlock?
130
+
131
+ attr_reader new_name: TypeName
132
+
133
+ # The infered old name from the right-hand side of the constant declaration
134
+ #
135
+ # - `nil` if the annotation has the type name
136
+ #
137
+ attr_reader infered_old_name: TypeName?
138
+
139
+ attr_reader annotation: annotation
140
+
141
+ def initialize: (Buffer, node, TypeName, TypeName?, CommentBlock?, annotation) -> void
142
+
143
+ def name_location: () -> Location
144
+
145
+ def location: () -> Location
146
+
147
+ # Returns the old name of the class/module alias
148
+ #
149
+ def old_name: () -> TypeName
150
+
151
+ def comment: () -> Comment?
152
+
153
+ def type_fingerprint: () -> untyped
56
154
  end
57
155
  end
58
156
  end
@@ -8,9 +8,14 @@ module RBS
8
8
  def initialize: (Buffer) -> void
9
9
 
10
10
  include Helpers::LocationHelper
11
+
12
+ def type_fingerprint: () -> untyped
11
13
  end
12
14
 
13
15
  type t = DefMember
16
+ | IncludeMember | ExtendMember | PrependMember
17
+ | AttrReaderMember | AttrWriterMember | AttrAccessorMember
18
+ | InstanceVariableMember
14
19
 
15
20
  class MethodTypeAnnotation
16
21
  class DocStyle
@@ -21,6 +26,8 @@ module RBS
21
26
  def map_type_name: () { (TypeName) -> TypeName } -> self
22
27
 
23
28
  def method_type: () -> MethodType
29
+
30
+ def type_fingerprint: () -> untyped
24
31
  end
25
32
 
26
33
  type type_annotations = DocStyle | Array[Annotations::ColonMethodTypeAnnotation | Annotations::MethodTypesAnnotation] | nil
@@ -47,6 +54,8 @@ module RBS
47
54
  # Returns the method type overloads
48
55
  #
49
56
  def overloads: () -> Array[AST::Members::MethodDefinition::Overload]
57
+
58
+ def type_fingerprint: () -> untyped
50
59
  end
51
60
 
52
61
  class DefMember < Base
@@ -55,8 +64,9 @@ module RBS
55
64
  attr_reader name: Symbol
56
65
  attr_reader node: Prism::DefNode
57
66
  attr_reader method_type: MethodTypeAnnotation
67
+ attr_reader leading_comment: CommentBlock?
58
68
 
59
- def initialize: (Buffer, Symbol name, Prism::DefNode node, MethodTypeAnnotation) -> void
69
+ def initialize: (Buffer, Symbol name, Prism::DefNode node, MethodTypeAnnotation, CommentBlock? leading_comment) -> void
60
70
 
61
71
  def location: () -> Location
62
72
 
@@ -65,6 +75,82 @@ module RBS
65
75
  def overloading?: () -> bool
66
76
 
67
77
  def annotations: () -> Array[AST::Annotation]
78
+
79
+ def name_location: () -> Location
80
+
81
+ def type_fingerprint: () -> untyped
82
+ end
83
+
84
+ class MixinMember < Base
85
+ attr_reader node: Prism::CallNode
86
+
87
+ attr_reader module_name: TypeName
88
+
89
+ attr_reader annotation: Annotations::TypeApplicationAnnotation | nil
90
+
91
+ def initialize: (Buffer, Prism::CallNode, TypeName, Annotations::TypeApplicationAnnotation | nil) -> void
92
+
93
+ def location: () -> Location
94
+
95
+ def name_location: () -> Location
96
+
97
+ def type_args: () -> Array[Types::t]
98
+
99
+ def type_fingerprint: () -> untyped
100
+ end
101
+
102
+ class IncludeMember < MixinMember
103
+ end
104
+
105
+ class ExtendMember < MixinMember
106
+ end
107
+
108
+ class PrependMember < MixinMember
109
+ end
110
+
111
+ class AttributeMember < Base
112
+ attr_reader node: Prism::CallNode
113
+
114
+ attr_reader name_nodes: Array[Prism::SymbolNode]
115
+
116
+ attr_reader type_annotation: Annotations::NodeTypeAssertion?
117
+
118
+ attr_reader leading_comment: CommentBlock?
119
+
120
+ def initialize: (Buffer, Prism::CallNode, Array[Prism::SymbolNode] name_nodes, RBS::AST::Ruby::CommentBlock? leading_comment, Annotations::NodeTypeAssertion? type_annotation) -> void
121
+
122
+ def names: () -> Array[Symbol]
123
+
124
+ def location: () -> Location
125
+
126
+ def name_locations: () -> Array[Location]
127
+
128
+ def type: () -> Types::t?
129
+
130
+ def type_fingerprint: () -> untyped
131
+ end
132
+
133
+ class AttrReaderMember < AttributeMember
134
+ end
135
+
136
+ class AttrWriterMember < AttributeMember
137
+ end
138
+
139
+ class AttrAccessorMember < AttributeMember
140
+ end
141
+
142
+ class InstanceVariableMember < Base
143
+ attr_reader annotation: Annotations::InstanceVariableAnnotation
144
+
145
+ def initialize: (Buffer, Annotations::InstanceVariableAnnotation) -> void
146
+
147
+ def name: () -> Symbol
148
+
149
+ def type: () -> Types::t
150
+
151
+ def location: () -> Location
152
+
153
+ def type_fingerprint: () -> untyped
68
154
  end
69
155
  end
70
156
  end
data/sig/cli/diff.rbs CHANGED
@@ -1,21 +1,15 @@
1
1
  module RBS
2
2
  class CLI
3
3
  class Diff
4
- @format: String
5
4
  @stdout: _IO
6
5
  @stderr: _IO
7
- @diff: RBS::Diff
8
6
 
9
- def initialize: (
10
- argv: Array[String],
11
- library_options: RBS::CLI::LibraryOptions,
12
- ?stdout: _IO,
13
- ?stderr: _IO,
14
- ) -> void
7
+ def initialize: (?stdout: _IO, ?stderr: _IO) -> void
15
8
 
16
- def run: () -> void
17
- def run_diff: () -> void
18
- def run_markdown: () -> void
9
+ def run: (library_options: RBS::CLI::LibraryOptions, argv: Array[String]) -> Integer
10
+
11
+ def run_diff: (RBS::Diff) -> void
12
+ def run_markdown: (RBS::Diff) -> void
19
13
  end
20
14
  end
21
15
  end
data/sig/cli/validate.rbs CHANGED
@@ -7,11 +7,20 @@ module RBS
7
7
  @has_syntax_error: bool
8
8
  @errors: Array[BaseError]
9
9
 
10
+ # The tag that will be thrown in #finish method
11
+ @tag: top
12
+
10
13
  def initialize: (limit: Integer?, exit_error: boolish) -> void
11
14
 
12
15
  def add: (BaseError) -> void
13
16
 
14
- def finish: () -> void
17
+ # Throws the `@tag` with 0 or 1
18
+ #
19
+ # Must be called from the block passed to `#try` method.
20
+ #
21
+ def finish: () -> Integer
22
+
23
+ def try: () { () -> void } -> Integer
15
24
 
16
25
  private
17
26
 
@@ -25,7 +34,7 @@ module RBS
25
34
 
26
35
  def initialize: (args: Array[String], options: LibraryOptions) -> void
27
36
 
28
- def run: () -> void
37
+ def run: () -> Integer
29
38
 
30
39
  private
31
40
 
@@ -35,9 +44,9 @@ module RBS
35
44
  def validate_constant: () -> void
36
45
  def validate_global: () -> void
37
46
  def validate_type_alias: () -> void
38
- def no_self_type_validator: (::RBS::Types::t | ::RBS::MethodType type) -> void
39
47
  def no_classish_type_validator: (::RBS::Types::t | ::RBS::MethodType type) -> void
40
- def void_type_context_validator: (::RBS::Types::t | ::RBS::MethodType type, ?bool allowed_here) -> void
48
+ def no_self_type_validator: (::RBS::Types::t | ::RBS::MethodType type) -> void
49
+ %a{deprecated} def void_type_context_validator: (::RBS::Types::t | ::RBS::MethodType type, ?bool allowed_here) -> void
41
50
  end
42
51
  end
43
52
  end
data/sig/cli.rbs CHANGED
@@ -46,41 +46,41 @@ module RBS
46
46
 
47
47
  def has_parser?: () -> bool
48
48
 
49
- def run: (Array[String] args) -> void
49
+ def run: (Array[String] args) -> Integer
50
50
 
51
- def run_ast: (Array[String], LibraryOptions) -> void
51
+ def run_ast: (Array[String], LibraryOptions) -> Integer
52
52
 
53
- def run_list: (Array[String], LibraryOptions) -> void
53
+ def run_list: (Array[String], LibraryOptions) -> Integer
54
54
 
55
- def run_ancestors: (Array[String], LibraryOptions) -> void
55
+ def run_ancestors: (Array[String], LibraryOptions) -> Integer
56
56
 
57
- def run_methods: (Array[String], LibraryOptions) -> void
57
+ def run_methods: (Array[String], LibraryOptions) -> Integer
58
58
 
59
- def run_method: (Array[String], LibraryOptions) -> void
59
+ def run_method: (Array[String], LibraryOptions) -> Integer
60
60
 
61
- def run_validate: (Array[String], LibraryOptions) -> void
61
+ def run_validate: (Array[String], LibraryOptions) -> Integer
62
62
 
63
- def run_constant: (Array[String], LibraryOptions) -> void
63
+ def run_constant: (Array[String], LibraryOptions) -> Integer
64
64
 
65
- def run_paths: (Array[String], LibraryOptions) -> void
65
+ def run_paths: (Array[String], LibraryOptions) -> Integer
66
66
 
67
- def run_prototype: (Array[String], LibraryOptions) -> void
67
+ def run_prototype: (Array[String], LibraryOptions) -> Integer
68
68
 
69
- def run_prototype_file: (String format, Array[String]) -> void
69
+ def run_prototype_file: (String format, Array[String]) -> Integer
70
70
 
71
- def run_vendor: (Array[String], LibraryOptions) -> void
71
+ def run_vendor: (Array[String], LibraryOptions) -> Integer
72
72
 
73
- def run_parse: (Array[String], LibraryOptions) -> void
73
+ def run_parse: (Array[String], LibraryOptions) -> Integer
74
74
 
75
- def run_test: (Array[String], LibraryOptions) -> void
75
+ def run_test: (Array[String], LibraryOptions) -> Integer
76
76
 
77
- def run_collection: (Array[String], LibraryOptions) -> void
77
+ def run_collection: (Array[String], LibraryOptions) -> Integer
78
78
 
79
- def run_annotate: (Array[String], top) -> void
79
+ def run_annotate: (Array[String], top) -> Integer
80
80
 
81
- def run_subtract: (Array[String], top) -> void
81
+ def run_subtract: (Array[String], top) -> Integer
82
82
 
83
- def run_diff: (Array[String], LibraryOptions) -> void
83
+ def run_diff: (Array[String], LibraryOptions) -> Integer
84
84
 
85
85
  def test_opt: (LibraryOptions) -> String?
86
86
 
data/sig/definition.rbs CHANGED
@@ -12,6 +12,10 @@ module RBS
12
12
  | AST::Members::InstanceVariable
13
13
  | AST::Members::ClassVariable
14
14
  | AST::Members::ClassInstanceVariable
15
+ | AST::Ruby::Members::AttrReaderMember
16
+ | AST::Ruby::Members::AttrWriterMember
17
+ | AST::Ruby::Members::AttrAccessorMember
18
+ | AST::Ruby::Members::InstanceVariableMember
15
19
  attr_reader source: source
16
20
 
17
21
  def initialize: (parent_variable: Variable?, type: Types::t, declared_in: TypeName, source: source) -> void
@@ -21,7 +25,7 @@ module RBS
21
25
 
22
26
  class Method
23
27
  type method_member = AST::Members::MethodDefinition | AST::Members::AttrReader | AST::Members::AttrAccessor | AST::Members::AttrWriter
24
- | AST::Ruby::Members::DefMember
28
+ | AST::Ruby::Members::DefMember | AST::Ruby::Members::AttrReaderMember | AST::Ruby::Members::AttrWriterMember | AST::Ruby::Members::AttrAccessorMember
25
29
 
26
30
  class TypeDef
27
31
  attr_reader type: MethodType
@@ -155,6 +159,7 @@ module RBS
155
159
  type source = :super # Inheritance
156
160
  | nil # Itself
157
161
  | AST::Members::Include | AST::Members::Extend | AST::Members::Prepend # AST
162
+ | AST::Ruby::Members::IncludeMember | AST::Ruby::Members::ExtendMember | AST::Ruby::Members::PrependMember # Ruby AST
158
163
  | AST::Declarations::Module::Self
159
164
 
160
165
  attr_reader name: TypeName