rbs 3.9.2 → 4.0.0.dev.1

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 (115) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +1 -1
  3. data/.github/workflows/windows.yml +1 -1
  4. data/CHANGELOG.md +0 -13
  5. data/Rakefile +28 -21
  6. data/Steepfile +1 -0
  7. data/config.yml +232 -62
  8. data/ext/rbs_extension/ast_translation.c +1149 -0
  9. data/ext/rbs_extension/ast_translation.h +30 -0
  10. data/{src/constants.c → ext/rbs_extension/class_constants.c} +15 -1
  11. data/{include/rbs/constants.h → ext/rbs_extension/class_constants.h} +10 -1
  12. data/ext/rbs_extension/extconf.rb +3 -1
  13. data/ext/rbs_extension/{location.c → legacy_location.c} +25 -34
  14. data/ext/rbs_extension/legacy_location.h +40 -0
  15. data/ext/rbs_extension/main.c +402 -8
  16. data/ext/rbs_extension/rbs_extension.h +3 -21
  17. data/ext/rbs_extension/rbs_string_bridging.c +9 -0
  18. data/ext/rbs_extension/rbs_string_bridging.h +20 -0
  19. data/include/rbs/ast.h +748 -0
  20. data/include/rbs/defines.h +60 -0
  21. data/{ext/rbs_extension → include/rbs}/lexer.h +40 -32
  22. data/include/rbs/location.h +59 -0
  23. data/include/rbs/parser.h +151 -0
  24. data/include/rbs/string.h +49 -0
  25. data/include/rbs/util/rbs_allocator.h +38 -0
  26. data/include/rbs/util/rbs_assert.h +9 -0
  27. data/include/rbs/util/rbs_buffer.h +83 -0
  28. data/include/rbs/util/rbs_constant_pool.h +3 -64
  29. data/include/rbs/util/rbs_encoding.h +280 -0
  30. data/include/rbs/util/rbs_unescape.h +23 -0
  31. data/include/rbs.h +1 -2
  32. data/lib/rbs/annotate/formatter.rb +3 -13
  33. data/lib/rbs/annotate/rdoc_annotator.rb +3 -1
  34. data/lib/rbs/annotate/rdoc_source.rb +1 -1
  35. data/lib/rbs/ast/ruby/annotations.rb +119 -0
  36. data/lib/rbs/ast/ruby/comment_block.rb +221 -0
  37. data/lib/rbs/ast/ruby/declarations.rb +86 -0
  38. data/lib/rbs/ast/ruby/helpers/constant_helper.rb +24 -0
  39. data/lib/rbs/ast/ruby/helpers/location_helper.rb +15 -0
  40. data/lib/rbs/ast/ruby/members.rb +213 -0
  41. data/lib/rbs/buffer.rb +104 -24
  42. data/lib/rbs/cli/validate.rb +39 -34
  43. data/lib/rbs/cli.rb +4 -5
  44. data/lib/rbs/definition.rb +6 -1
  45. data/lib/rbs/definition_builder/ancestor_builder.rb +63 -60
  46. data/lib/rbs/definition_builder/method_builder.rb +45 -30
  47. data/lib/rbs/definition_builder.rb +44 -9
  48. data/lib/rbs/environment/class_entry.rb +69 -0
  49. data/lib/rbs/environment/module_entry.rb +66 -0
  50. data/lib/rbs/environment.rb +185 -154
  51. data/lib/rbs/environment_loader.rb +2 -2
  52. data/lib/rbs/errors.rb +4 -3
  53. data/lib/rbs/inline_parser/comment_association.rb +117 -0
  54. data/lib/rbs/inline_parser.rb +206 -0
  55. data/lib/rbs/location_aux.rb +35 -3
  56. data/lib/rbs/parser_aux.rb +11 -1
  57. data/lib/rbs/prototype/runtime.rb +2 -2
  58. data/lib/rbs/source.rb +99 -0
  59. data/lib/rbs/subtractor.rb +4 -3
  60. data/lib/rbs/version.rb +1 -1
  61. data/lib/rbs.rb +12 -0
  62. data/lib/rdoc/discover.rb +1 -1
  63. data/lib/rdoc_plugin/parser.rb +2 -2
  64. data/rbs.gemspec +1 -0
  65. data/sig/ancestor_builder.rbs +1 -1
  66. data/sig/annotate/formatter.rbs +2 -2
  67. data/sig/annotate/rdoc_annotater.rbs +1 -1
  68. data/sig/ast/ruby/annotations.rbs +110 -0
  69. data/sig/ast/ruby/comment_block.rbs +119 -0
  70. data/sig/ast/ruby/declarations.rbs +60 -0
  71. data/sig/ast/ruby/helpers/constant_helper.rbs +11 -0
  72. data/sig/ast/ruby/helpers/location_helper.rbs +15 -0
  73. data/sig/ast/ruby/members.rbs +72 -0
  74. data/sig/buffer.rbs +63 -5
  75. data/sig/definition.rbs +1 -0
  76. data/sig/definition_builder.rbs +1 -1
  77. data/sig/environment/class_entry.rbs +50 -0
  78. data/sig/environment/module_entry.rbs +50 -0
  79. data/sig/environment.rbs +22 -76
  80. data/sig/errors.rbs +13 -6
  81. data/sig/inline_parser/comment_association.rbs +71 -0
  82. data/sig/inline_parser.rbs +87 -0
  83. data/sig/location.rbs +32 -7
  84. data/sig/method_builder.rbs +7 -4
  85. data/sig/parser.rbs +16 -0
  86. data/sig/source.rbs +48 -0
  87. data/src/ast.c +1345 -0
  88. data/src/lexer.c +2867 -0
  89. data/src/lexer.re +151 -0
  90. data/{ext/rbs_extension → src}/lexstate.c +58 -42
  91. data/src/location.c +71 -0
  92. data/src/parser.c +3739 -0
  93. data/src/string.c +89 -0
  94. data/src/util/rbs_allocator.c +149 -0
  95. data/src/util/rbs_assert.c +19 -0
  96. data/src/util/rbs_buffer.c +54 -0
  97. data/src/util/rbs_constant_pool.c +13 -81
  98. data/src/util/rbs_encoding.c +5273 -0
  99. data/src/util/rbs_unescape.c +130 -0
  100. data/stdlib/rdoc/0/code_object.rbs +2 -2
  101. data/stdlib/rdoc/0/comment.rbs +2 -0
  102. data/stdlib/rdoc/0/options.rbs +76 -0
  103. data/stdlib/rdoc/0/rdoc.rbs +6 -4
  104. data/stdlib/rdoc/0/store.rbs +1 -1
  105. metadata +70 -17
  106. data/ext/rbs_extension/lexer.c +0 -2728
  107. data/ext/rbs_extension/lexer.re +0 -147
  108. data/ext/rbs_extension/location.h +0 -85
  109. data/ext/rbs_extension/parser.c +0 -2982
  110. data/ext/rbs_extension/parser.h +0 -18
  111. data/ext/rbs_extension/parserstate.c +0 -411
  112. data/ext/rbs_extension/parserstate.h +0 -163
  113. data/ext/rbs_extension/unescape.c +0 -32
  114. data/include/rbs/ruby_objs.h +0 -72
  115. data/src/ruby_objs.c +0 -799
data/src/ruby_objs.c DELETED
@@ -1,799 +0,0 @@
1
- /*----------------------------------------------------------------------------*/
2
- /* This file is generated by the templates/template.rb script and should not */
3
- /* be modified manually. */
4
- /* To change the template see */
5
- /* templates/src/ruby_objs.c.erb */
6
- /*----------------------------------------------------------------------------*/
7
-
8
- #include "rbs_extension.h"
9
-
10
- #ifdef RB_PASS_KEYWORDS
11
- // Ruby 2.7 or later
12
- #define CLASS_NEW_INSTANCE(klass, argc, argv)\
13
- rb_class_new_instance_kw(argc, argv, klass, RB_PASS_KEYWORDS)
14
- #else
15
- // Ruby 2.6
16
- #define CLASS_NEW_INSTANCE(receiver, argc, argv)\
17
- rb_class_new_instance(argc, argv, receiver)
18
- #endif
19
-
20
- VALUE rbs_ast_annotation(VALUE string, VALUE location) {
21
- VALUE _init_kwargs = rb_hash_new();
22
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("string")), string);
23
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
24
-
25
- return CLASS_NEW_INSTANCE(
26
- RBS_AST_Annotation,
27
- 1,
28
- &_init_kwargs
29
- );
30
- }
31
-
32
- VALUE rbs_ast_comment(VALUE string, VALUE location) {
33
- VALUE _init_kwargs = rb_hash_new();
34
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("string")), string);
35
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
36
-
37
- return CLASS_NEW_INSTANCE(
38
- RBS_AST_Comment,
39
- 1,
40
- &_init_kwargs
41
- );
42
- }
43
-
44
- VALUE rbs_ast_decl_class(VALUE name, VALUE type_params, VALUE super_class, VALUE members, VALUE annotations, VALUE location, VALUE comment) {
45
- VALUE _init_kwargs = rb_hash_new();
46
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("name")), name);
47
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("type_params")), type_params);
48
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("super_class")), super_class);
49
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("members")), members);
50
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("annotations")), annotations);
51
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
52
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("comment")), comment);
53
-
54
- return CLASS_NEW_INSTANCE(
55
- RBS_AST_Declarations_Class,
56
- 1,
57
- &_init_kwargs
58
- );
59
- }
60
-
61
- VALUE rbs_ast_decl_class_super(VALUE name, VALUE args, VALUE location) {
62
- VALUE _init_kwargs = rb_hash_new();
63
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("name")), name);
64
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("args")), args);
65
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
66
-
67
- return CLASS_NEW_INSTANCE(
68
- RBS_AST_Declarations_Class_Super,
69
- 1,
70
- &_init_kwargs
71
- );
72
- }
73
-
74
- VALUE rbs_ast_decl_class_alias(VALUE new_name, VALUE old_name, VALUE location, VALUE comment, VALUE annotations) {
75
- VALUE _init_kwargs = rb_hash_new();
76
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("new_name")), new_name);
77
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("old_name")), old_name);
78
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
79
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("comment")), comment);
80
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("annotations")), annotations);
81
-
82
- return CLASS_NEW_INSTANCE(
83
- RBS_AST_Declarations_ClassAlias,
84
- 1,
85
- &_init_kwargs
86
- );
87
- }
88
-
89
- VALUE rbs_ast_decl_constant(VALUE name, VALUE type, VALUE location, VALUE comment, VALUE annotations) {
90
- VALUE _init_kwargs = rb_hash_new();
91
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("name")), name);
92
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("type")), type);
93
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
94
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("comment")), comment);
95
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("annotations")), annotations);
96
-
97
- return CLASS_NEW_INSTANCE(
98
- RBS_AST_Declarations_Constant,
99
- 1,
100
- &_init_kwargs
101
- );
102
- }
103
-
104
- VALUE rbs_ast_decl_global(VALUE name, VALUE type, VALUE location, VALUE comment, VALUE annotations) {
105
- VALUE _init_kwargs = rb_hash_new();
106
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("name")), name);
107
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("type")), type);
108
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
109
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("comment")), comment);
110
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("annotations")), annotations);
111
-
112
- return CLASS_NEW_INSTANCE(
113
- RBS_AST_Declarations_Global,
114
- 1,
115
- &_init_kwargs
116
- );
117
- }
118
-
119
- VALUE rbs_ast_decl_interface(VALUE name, VALUE type_params, VALUE members, VALUE annotations, VALUE location, VALUE comment) {
120
- VALUE _init_kwargs = rb_hash_new();
121
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("name")), name);
122
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("type_params")), type_params);
123
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("members")), members);
124
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("annotations")), annotations);
125
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
126
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("comment")), comment);
127
-
128
- return CLASS_NEW_INSTANCE(
129
- RBS_AST_Declarations_Interface,
130
- 1,
131
- &_init_kwargs
132
- );
133
- }
134
-
135
- VALUE rbs_ast_decl_module(VALUE name, VALUE type_params, VALUE self_types, VALUE members, VALUE annotations, VALUE location, VALUE comment) {
136
- VALUE _init_kwargs = rb_hash_new();
137
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("name")), name);
138
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("type_params")), type_params);
139
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("self_types")), self_types);
140
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("members")), members);
141
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("annotations")), annotations);
142
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
143
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("comment")), comment);
144
-
145
- return CLASS_NEW_INSTANCE(
146
- RBS_AST_Declarations_Module,
147
- 1,
148
- &_init_kwargs
149
- );
150
- }
151
-
152
- VALUE rbs_ast_decl_module_self(VALUE name, VALUE args, VALUE location) {
153
- VALUE _init_kwargs = rb_hash_new();
154
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("name")), name);
155
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("args")), args);
156
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
157
-
158
- return CLASS_NEW_INSTANCE(
159
- RBS_AST_Declarations_Module_Self,
160
- 1,
161
- &_init_kwargs
162
- );
163
- }
164
-
165
- VALUE rbs_ast_decl_module_alias(VALUE new_name, VALUE old_name, VALUE location, VALUE comment, VALUE annotations) {
166
- VALUE _init_kwargs = rb_hash_new();
167
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("new_name")), new_name);
168
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("old_name")), old_name);
169
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
170
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("comment")), comment);
171
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("annotations")), annotations);
172
-
173
- return CLASS_NEW_INSTANCE(
174
- RBS_AST_Declarations_ModuleAlias,
175
- 1,
176
- &_init_kwargs
177
- );
178
- }
179
-
180
- VALUE rbs_ast_decl_type_alias(VALUE name, VALUE type_params, VALUE type, VALUE annotations, VALUE location, VALUE comment) {
181
- VALUE _init_kwargs = rb_hash_new();
182
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("name")), name);
183
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("type_params")), type_params);
184
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("type")), type);
185
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("annotations")), annotations);
186
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
187
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("comment")), comment);
188
-
189
- return CLASS_NEW_INSTANCE(
190
- RBS_AST_Declarations_TypeAlias,
191
- 1,
192
- &_init_kwargs
193
- );
194
- }
195
-
196
- VALUE rbs_ast_directives_use(VALUE clauses, VALUE location) {
197
- VALUE _init_kwargs = rb_hash_new();
198
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("clauses")), clauses);
199
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
200
-
201
- return CLASS_NEW_INSTANCE(
202
- RBS_AST_Directives_Use,
203
- 1,
204
- &_init_kwargs
205
- );
206
- }
207
-
208
- VALUE rbs_ast_directives_use_single_clause(VALUE type_name, VALUE new_name, VALUE location) {
209
- VALUE _init_kwargs = rb_hash_new();
210
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("type_name")), type_name);
211
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("new_name")), new_name);
212
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
213
-
214
- return CLASS_NEW_INSTANCE(
215
- RBS_AST_Directives_Use_SingleClause,
216
- 1,
217
- &_init_kwargs
218
- );
219
- }
220
-
221
- VALUE rbs_ast_directives_use_wildcard_clause(VALUE namespace, VALUE location) {
222
- VALUE _init_kwargs = rb_hash_new();
223
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("namespace")), namespace);
224
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
225
-
226
- return CLASS_NEW_INSTANCE(
227
- RBS_AST_Directives_Use_WildcardClause,
228
- 1,
229
- &_init_kwargs
230
- );
231
- }
232
-
233
- VALUE rbs_ast_members_alias(VALUE new_name, VALUE old_name, VALUE kind, VALUE annotations, VALUE location, VALUE comment) {
234
- VALUE _init_kwargs = rb_hash_new();
235
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("new_name")), new_name);
236
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("old_name")), old_name);
237
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("kind")), kind);
238
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("annotations")), annotations);
239
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
240
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("comment")), comment);
241
-
242
- return CLASS_NEW_INSTANCE(
243
- RBS_AST_Members_Alias,
244
- 1,
245
- &_init_kwargs
246
- );
247
- }
248
-
249
- VALUE rbs_ast_members_attr_accessor(VALUE name, VALUE type, VALUE ivar_name, VALUE kind, VALUE annotations, VALUE location, VALUE comment, VALUE visibility) {
250
- VALUE _init_kwargs = rb_hash_new();
251
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("name")), name);
252
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("type")), type);
253
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("ivar_name")), ivar_name);
254
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("kind")), kind);
255
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("annotations")), annotations);
256
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
257
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("comment")), comment);
258
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("visibility")), visibility);
259
-
260
- return CLASS_NEW_INSTANCE(
261
- RBS_AST_Members_AttrAccessor,
262
- 1,
263
- &_init_kwargs
264
- );
265
- }
266
-
267
- VALUE rbs_ast_members_attr_reader(VALUE name, VALUE type, VALUE ivar_name, VALUE kind, VALUE annotations, VALUE location, VALUE comment, VALUE visibility) {
268
- VALUE _init_kwargs = rb_hash_new();
269
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("name")), name);
270
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("type")), type);
271
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("ivar_name")), ivar_name);
272
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("kind")), kind);
273
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("annotations")), annotations);
274
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
275
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("comment")), comment);
276
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("visibility")), visibility);
277
-
278
- return CLASS_NEW_INSTANCE(
279
- RBS_AST_Members_AttrReader,
280
- 1,
281
- &_init_kwargs
282
- );
283
- }
284
-
285
- VALUE rbs_ast_members_attr_writer(VALUE name, VALUE type, VALUE ivar_name, VALUE kind, VALUE annotations, VALUE location, VALUE comment, VALUE visibility) {
286
- VALUE _init_kwargs = rb_hash_new();
287
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("name")), name);
288
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("type")), type);
289
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("ivar_name")), ivar_name);
290
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("kind")), kind);
291
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("annotations")), annotations);
292
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
293
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("comment")), comment);
294
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("visibility")), visibility);
295
-
296
- return CLASS_NEW_INSTANCE(
297
- RBS_AST_Members_AttrWriter,
298
- 1,
299
- &_init_kwargs
300
- );
301
- }
302
-
303
- VALUE rbs_ast_members_class_instance_variable(VALUE name, VALUE type, VALUE location, VALUE comment) {
304
- VALUE _init_kwargs = rb_hash_new();
305
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("name")), name);
306
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("type")), type);
307
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
308
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("comment")), comment);
309
-
310
- return CLASS_NEW_INSTANCE(
311
- RBS_AST_Members_ClassInstanceVariable,
312
- 1,
313
- &_init_kwargs
314
- );
315
- }
316
-
317
- VALUE rbs_ast_members_class_variable(VALUE name, VALUE type, VALUE location, VALUE comment) {
318
- VALUE _init_kwargs = rb_hash_new();
319
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("name")), name);
320
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("type")), type);
321
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
322
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("comment")), comment);
323
-
324
- return CLASS_NEW_INSTANCE(
325
- RBS_AST_Members_ClassVariable,
326
- 1,
327
- &_init_kwargs
328
- );
329
- }
330
-
331
- VALUE rbs_ast_members_extend(VALUE name, VALUE args, VALUE annotations, VALUE location, VALUE comment) {
332
- VALUE _init_kwargs = rb_hash_new();
333
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("name")), name);
334
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("args")), args);
335
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("annotations")), annotations);
336
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
337
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("comment")), comment);
338
-
339
- return CLASS_NEW_INSTANCE(
340
- RBS_AST_Members_Extend,
341
- 1,
342
- &_init_kwargs
343
- );
344
- }
345
-
346
- VALUE rbs_ast_members_include(VALUE name, VALUE args, VALUE annotations, VALUE location, VALUE comment) {
347
- VALUE _init_kwargs = rb_hash_new();
348
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("name")), name);
349
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("args")), args);
350
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("annotations")), annotations);
351
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
352
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("comment")), comment);
353
-
354
- return CLASS_NEW_INSTANCE(
355
- RBS_AST_Members_Include,
356
- 1,
357
- &_init_kwargs
358
- );
359
- }
360
-
361
- VALUE rbs_ast_members_instance_variable(VALUE name, VALUE type, VALUE location, VALUE comment) {
362
- VALUE _init_kwargs = rb_hash_new();
363
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("name")), name);
364
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("type")), type);
365
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
366
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("comment")), comment);
367
-
368
- return CLASS_NEW_INSTANCE(
369
- RBS_AST_Members_InstanceVariable,
370
- 1,
371
- &_init_kwargs
372
- );
373
- }
374
-
375
- VALUE rbs_ast_members_method_definition(VALUE name, VALUE kind, VALUE overloads, VALUE annotations, VALUE location, VALUE comment, VALUE overloading, VALUE visibility) {
376
- VALUE _init_kwargs = rb_hash_new();
377
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("name")), name);
378
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("kind")), kind);
379
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("overloads")), overloads);
380
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("annotations")), annotations);
381
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
382
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("comment")), comment);
383
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("overloading")), overloading);
384
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("visibility")), visibility);
385
-
386
- return CLASS_NEW_INSTANCE(
387
- RBS_AST_Members_MethodDefinition,
388
- 1,
389
- &_init_kwargs
390
- );
391
- }
392
-
393
- VALUE rbs_ast_members_method_definition_overload(VALUE annotations, VALUE method_type) {
394
- VALUE _init_kwargs = rb_hash_new();
395
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("annotations")), annotations);
396
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("method_type")), method_type);
397
-
398
- return CLASS_NEW_INSTANCE(
399
- RBS_AST_Members_MethodDefinition_Overload,
400
- 1,
401
- &_init_kwargs
402
- );
403
- }
404
-
405
- VALUE rbs_ast_members_prepend(VALUE name, VALUE args, VALUE annotations, VALUE location, VALUE comment) {
406
- VALUE _init_kwargs = rb_hash_new();
407
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("name")), name);
408
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("args")), args);
409
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("annotations")), annotations);
410
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
411
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("comment")), comment);
412
-
413
- return CLASS_NEW_INSTANCE(
414
- RBS_AST_Members_Prepend,
415
- 1,
416
- &_init_kwargs
417
- );
418
- }
419
-
420
- VALUE rbs_ast_members_private(VALUE location) {
421
- VALUE _init_kwargs = rb_hash_new();
422
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
423
-
424
- return CLASS_NEW_INSTANCE(
425
- RBS_AST_Members_Private,
426
- 1,
427
- &_init_kwargs
428
- );
429
- }
430
-
431
- VALUE rbs_ast_members_public(VALUE location) {
432
- VALUE _init_kwargs = rb_hash_new();
433
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
434
-
435
- return CLASS_NEW_INSTANCE(
436
- RBS_AST_Members_Public,
437
- 1,
438
- &_init_kwargs
439
- );
440
- }
441
-
442
- VALUE rbs_ast_type_param(VALUE name, VALUE variance, VALUE upper_bound, VALUE default_type, VALUE unchecked, VALUE location) {
443
- VALUE _init_kwargs = rb_hash_new();
444
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("name")), name);
445
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("variance")), variance);
446
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("upper_bound")), upper_bound);
447
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("default_type")), default_type);
448
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("unchecked")), unchecked);
449
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
450
-
451
- return CLASS_NEW_INSTANCE(
452
- RBS_AST_TypeParam,
453
- 1,
454
- &_init_kwargs
455
- );
456
- }
457
-
458
- VALUE rbs_method_type(VALUE type_params, VALUE type, VALUE block, VALUE location) {
459
- VALUE _init_kwargs = rb_hash_new();
460
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("type_params")), type_params);
461
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("type")), type);
462
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("block")), block);
463
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
464
-
465
- return CLASS_NEW_INSTANCE(
466
- RBS_MethodType,
467
- 1,
468
- &_init_kwargs
469
- );
470
- }
471
-
472
- VALUE rbs_namespace(VALUE path, VALUE absolute) {
473
- VALUE _init_kwargs = rb_hash_new();
474
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("path")), path);
475
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("absolute")), absolute);
476
-
477
- return CLASS_NEW_INSTANCE(
478
- RBS_Namespace,
479
- 1,
480
- &_init_kwargs
481
- );
482
- }
483
-
484
- VALUE rbs_type_name(VALUE namespace, VALUE name) {
485
- VALUE _init_kwargs = rb_hash_new();
486
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("namespace")), namespace);
487
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("name")), name);
488
-
489
- return CLASS_NEW_INSTANCE(
490
- RBS_TypeName,
491
- 1,
492
- &_init_kwargs
493
- );
494
- }
495
-
496
- VALUE rbs_alias(VALUE name, VALUE args, VALUE location) {
497
- VALUE _init_kwargs = rb_hash_new();
498
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("name")), name);
499
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("args")), args);
500
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
501
-
502
- return CLASS_NEW_INSTANCE(
503
- RBS_Types_Alias,
504
- 1,
505
- &_init_kwargs
506
- );
507
- }
508
-
509
- VALUE rbs_bases_any(VALUE todo, VALUE location) {
510
- VALUE _init_kwargs = rb_hash_new();
511
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("todo")), todo);
512
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
513
-
514
- return CLASS_NEW_INSTANCE(
515
- RBS_Types_Bases_Any,
516
- 1,
517
- &_init_kwargs
518
- );
519
- }
520
-
521
- VALUE rbs_bases_bool(VALUE location) {
522
- VALUE _init_kwargs = rb_hash_new();
523
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
524
-
525
- return CLASS_NEW_INSTANCE(
526
- RBS_Types_Bases_Bool,
527
- 1,
528
- &_init_kwargs
529
- );
530
- }
531
-
532
- VALUE rbs_bases_bottom(VALUE location) {
533
- VALUE _init_kwargs = rb_hash_new();
534
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
535
-
536
- return CLASS_NEW_INSTANCE(
537
- RBS_Types_Bases_Bottom,
538
- 1,
539
- &_init_kwargs
540
- );
541
- }
542
-
543
- VALUE rbs_bases_class(VALUE location) {
544
- VALUE _init_kwargs = rb_hash_new();
545
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
546
-
547
- return CLASS_NEW_INSTANCE(
548
- RBS_Types_Bases_Class,
549
- 1,
550
- &_init_kwargs
551
- );
552
- }
553
-
554
- VALUE rbs_bases_instance(VALUE location) {
555
- VALUE _init_kwargs = rb_hash_new();
556
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
557
-
558
- return CLASS_NEW_INSTANCE(
559
- RBS_Types_Bases_Instance,
560
- 1,
561
- &_init_kwargs
562
- );
563
- }
564
-
565
- VALUE rbs_bases_nil(VALUE location) {
566
- VALUE _init_kwargs = rb_hash_new();
567
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
568
-
569
- return CLASS_NEW_INSTANCE(
570
- RBS_Types_Bases_Nil,
571
- 1,
572
- &_init_kwargs
573
- );
574
- }
575
-
576
- VALUE rbs_bases_self(VALUE location) {
577
- VALUE _init_kwargs = rb_hash_new();
578
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
579
-
580
- return CLASS_NEW_INSTANCE(
581
- RBS_Types_Bases_Self,
582
- 1,
583
- &_init_kwargs
584
- );
585
- }
586
-
587
- VALUE rbs_bases_top(VALUE location) {
588
- VALUE _init_kwargs = rb_hash_new();
589
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
590
-
591
- return CLASS_NEW_INSTANCE(
592
- RBS_Types_Bases_Top,
593
- 1,
594
- &_init_kwargs
595
- );
596
- }
597
-
598
- VALUE rbs_bases_void(VALUE location) {
599
- VALUE _init_kwargs = rb_hash_new();
600
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
601
-
602
- return CLASS_NEW_INSTANCE(
603
- RBS_Types_Bases_Void,
604
- 1,
605
- &_init_kwargs
606
- );
607
- }
608
-
609
- VALUE rbs_block(VALUE type, VALUE required, VALUE self_type) {
610
- VALUE _init_kwargs = rb_hash_new();
611
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("type")), type);
612
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("required")), required);
613
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("self_type")), self_type);
614
-
615
- return CLASS_NEW_INSTANCE(
616
- RBS_Types_Block,
617
- 1,
618
- &_init_kwargs
619
- );
620
- }
621
-
622
- VALUE rbs_class_instance(VALUE name, VALUE args, VALUE location) {
623
- VALUE _init_kwargs = rb_hash_new();
624
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("name")), name);
625
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("args")), args);
626
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
627
-
628
- return CLASS_NEW_INSTANCE(
629
- RBS_Types_ClassInstance,
630
- 1,
631
- &_init_kwargs
632
- );
633
- }
634
-
635
- VALUE rbs_class_singleton(VALUE name, VALUE location) {
636
- VALUE _init_kwargs = rb_hash_new();
637
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("name")), name);
638
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
639
-
640
- return CLASS_NEW_INSTANCE(
641
- RBS_Types_ClassSingleton,
642
- 1,
643
- &_init_kwargs
644
- );
645
- }
646
-
647
- VALUE rbs_function(VALUE required_positionals, VALUE optional_positionals, VALUE rest_positionals, VALUE trailing_positionals, VALUE required_keywords, VALUE optional_keywords, VALUE rest_keywords, VALUE return_type) {
648
- VALUE _init_kwargs = rb_hash_new();
649
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("required_positionals")), required_positionals);
650
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("optional_positionals")), optional_positionals);
651
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("rest_positionals")), rest_positionals);
652
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("trailing_positionals")), trailing_positionals);
653
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("required_keywords")), required_keywords);
654
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("optional_keywords")), optional_keywords);
655
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("rest_keywords")), rest_keywords);
656
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("return_type")), return_type);
657
-
658
- return CLASS_NEW_INSTANCE(
659
- RBS_Types_Function,
660
- 1,
661
- &_init_kwargs
662
- );
663
- }
664
-
665
- VALUE rbs_function_param(VALUE type, VALUE name, VALUE location) {
666
- VALUE _init_kwargs = rb_hash_new();
667
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("type")), type);
668
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("name")), name);
669
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
670
-
671
- return CLASS_NEW_INSTANCE(
672
- RBS_Types_Function_Param,
673
- 1,
674
- &_init_kwargs
675
- );
676
- }
677
-
678
- VALUE rbs_interface(VALUE name, VALUE args, VALUE location) {
679
- VALUE _init_kwargs = rb_hash_new();
680
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("name")), name);
681
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("args")), args);
682
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
683
-
684
- return CLASS_NEW_INSTANCE(
685
- RBS_Types_Interface,
686
- 1,
687
- &_init_kwargs
688
- );
689
- }
690
-
691
- VALUE rbs_intersection(VALUE types, VALUE location) {
692
- VALUE _init_kwargs = rb_hash_new();
693
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("types")), types);
694
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
695
-
696
- return CLASS_NEW_INSTANCE(
697
- RBS_Types_Intersection,
698
- 1,
699
- &_init_kwargs
700
- );
701
- }
702
-
703
- VALUE rbs_literal(VALUE literal, VALUE location) {
704
- VALUE _init_kwargs = rb_hash_new();
705
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("literal")), literal);
706
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
707
-
708
- return CLASS_NEW_INSTANCE(
709
- RBS_Types_Literal,
710
- 1,
711
- &_init_kwargs
712
- );
713
- }
714
-
715
- VALUE rbs_optional(VALUE type, VALUE location) {
716
- VALUE _init_kwargs = rb_hash_new();
717
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("type")), type);
718
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
719
-
720
- return CLASS_NEW_INSTANCE(
721
- RBS_Types_Optional,
722
- 1,
723
- &_init_kwargs
724
- );
725
- }
726
-
727
- VALUE rbs_proc(VALUE type, VALUE block, VALUE location, VALUE self_type) {
728
- VALUE _init_kwargs = rb_hash_new();
729
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("type")), type);
730
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("block")), block);
731
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
732
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("self_type")), self_type);
733
-
734
- return CLASS_NEW_INSTANCE(
735
- RBS_Types_Proc,
736
- 1,
737
- &_init_kwargs
738
- );
739
- }
740
-
741
- VALUE rbs_record(VALUE all_fields, VALUE location) {
742
- VALUE _init_kwargs = rb_hash_new();
743
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("all_fields")), all_fields);
744
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
745
-
746
- return CLASS_NEW_INSTANCE(
747
- RBS_Types_Record,
748
- 1,
749
- &_init_kwargs
750
- );
751
- }
752
-
753
- VALUE rbs_tuple(VALUE types, VALUE location) {
754
- VALUE _init_kwargs = rb_hash_new();
755
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("types")), types);
756
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
757
-
758
- return CLASS_NEW_INSTANCE(
759
- RBS_Types_Tuple,
760
- 1,
761
- &_init_kwargs
762
- );
763
- }
764
-
765
- VALUE rbs_union(VALUE types, VALUE location) {
766
- VALUE _init_kwargs = rb_hash_new();
767
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("types")), types);
768
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
769
-
770
- return CLASS_NEW_INSTANCE(
771
- RBS_Types_Union,
772
- 1,
773
- &_init_kwargs
774
- );
775
- }
776
-
777
- VALUE rbs_untyped_function(VALUE return_type) {
778
- VALUE _init_kwargs = rb_hash_new();
779
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("return_type")), return_type);
780
-
781
- return CLASS_NEW_INSTANCE(
782
- RBS_Types_UntypedFunction,
783
- 1,
784
- &_init_kwargs
785
- );
786
- }
787
-
788
- VALUE rbs_variable(VALUE name, VALUE location) {
789
- VALUE _init_kwargs = rb_hash_new();
790
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("name")), name);
791
- rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
792
-
793
- return CLASS_NEW_INSTANCE(
794
- RBS_Types_Variable,
795
- 1,
796
- &_init_kwargs
797
- );
798
- }
799
-