rbs 1.6.2 → 1.7.0.beta.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 (57) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +0 -4
  3. data/.gitignore +1 -0
  4. data/CHANGELOG.md +6 -0
  5. data/Gemfile +1 -0
  6. data/Rakefile +7 -22
  7. data/core/kernel.rbs +4 -4
  8. data/core/trace_point.rbs +1 -1
  9. data/ext/rbs/extension/constants.c +140 -0
  10. data/ext/rbs/extension/constants.h +72 -0
  11. data/ext/rbs/extension/extconf.rb +3 -0
  12. data/ext/rbs/extension/lexer.c +1070 -0
  13. data/ext/rbs/extension/lexer.h +145 -0
  14. data/ext/rbs/extension/location.c +295 -0
  15. data/ext/rbs/extension/location.h +59 -0
  16. data/ext/rbs/extension/main.c +9 -0
  17. data/ext/rbs/extension/parser.c +2418 -0
  18. data/ext/rbs/extension/parser.h +23 -0
  19. data/ext/rbs/extension/parserstate.c +313 -0
  20. data/ext/rbs/extension/parserstate.h +141 -0
  21. data/ext/rbs/extension/rbs_extension.h +40 -0
  22. data/ext/rbs/extension/ruby_objs.c +585 -0
  23. data/ext/rbs/extension/ruby_objs.h +46 -0
  24. data/ext/rbs/extension/unescape.c +65 -0
  25. data/goodcheck.yml +1 -1
  26. data/lib/rbs/ast/comment.rb +0 -12
  27. data/lib/rbs/buffer.rb +4 -0
  28. data/lib/rbs/cli.rb +5 -8
  29. data/lib/rbs/collection/sources/git.rb +18 -3
  30. data/lib/rbs/errors.rb +14 -1
  31. data/lib/rbs/location.rb +221 -217
  32. data/lib/rbs/location_aux.rb +108 -0
  33. data/lib/rbs/locator.rb +10 -7
  34. data/lib/rbs/parser_aux.rb +24 -0
  35. data/lib/rbs/types.rb +2 -3
  36. data/lib/rbs/version.rb +1 -1
  37. data/lib/rbs/writer.rb +4 -2
  38. data/lib/rbs.rb +3 -7
  39. data/rbs.gemspec +2 -1
  40. data/sig/ancestor_builder.rbs +2 -2
  41. data/sig/annotation.rbs +2 -2
  42. data/sig/comment.rbs +7 -7
  43. data/sig/constant_table.rbs +1 -1
  44. data/sig/declarations.rbs +9 -9
  45. data/sig/definition.rbs +1 -1
  46. data/sig/definition_builder.rbs +2 -2
  47. data/sig/errors.rbs +30 -25
  48. data/sig/location.rbs +42 -79
  49. data/sig/locator.rbs +2 -2
  50. data/sig/members.rbs +7 -7
  51. data/sig/method_types.rbs +3 -3
  52. data/sig/parser.rbs +11 -21
  53. data/sig/types.rbs +45 -27
  54. data/sig/writer.rbs +1 -1
  55. data/stdlib/json/0/json.rbs +3 -3
  56. metadata +24 -6
  57. data/lib/rbs/parser.rb +0 -3614
@@ -0,0 +1,40 @@
1
+ #include <stdbool.h>
2
+
3
+ #include "ruby.h"
4
+ #include "ruby/re.h"
5
+ #include "ruby/encoding.h"
6
+
7
+ #include "lexer.h"
8
+ #include "parser.h"
9
+ #include "constants.h"
10
+ #include "ruby_objs.h"
11
+
12
+ /**
13
+ * Unescape escape sequences in the given string inplace:
14
+ *
15
+ * '\\n' => "\n"
16
+ *
17
+ * */
18
+ void rbs_unescape_string(VALUE string);
19
+
20
+ /**
21
+ * Receives `parserstate` and `range`, which represents a string token or symbol token, and returns a string VALUE.
22
+ *
23
+ * Input token | Output string
24
+ * ------------+-------------
25
+ * "foo\\n" | foo\n
26
+ * 'foo' | foo
27
+ * `bar` | bar
28
+ * :"baz\\t" | baz\t
29
+ * :'baz' | baz
30
+ * */
31
+ VALUE rbs_unquote_string(parserstate *state, range rg, int offset_bytes);
32
+
33
+ /**
34
+ * Raises RBS::ParsingError on `tok` with message constructed with given `fmt`.
35
+ *
36
+ * ```
37
+ * foo.rbs:11:21...11:25: Syntax error: {message}, token=`{tok source}` ({tok type})
38
+ * ```
39
+ * */
40
+ NORETURN(void) raise_syntax_error(parserstate *state, token tok, const char *fmt, ...);
@@ -0,0 +1,585 @@
1
+ #include "rbs_extension.h"
2
+
3
+ VALUE rbs_base_type(VALUE klass, VALUE location) {
4
+ VALUE args = rb_hash_new();
5
+ rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
6
+
7
+ return rb_funcallv_kw(
8
+ klass,
9
+ rb_intern("new"),
10
+ 1,
11
+ &args,
12
+ RB_PASS_KEYWORDS
13
+ );
14
+ }
15
+
16
+ VALUE rbs_namespace(VALUE path, VALUE absolute) {
17
+ VALUE args = rb_hash_new();
18
+ rb_hash_aset(args, ID2SYM(rb_intern("path")), path);
19
+ rb_hash_aset(args, ID2SYM(rb_intern("absolute")), absolute);
20
+
21
+ return rb_funcallv_kw(
22
+ RBS_Namespace,
23
+ rb_intern("new"),
24
+ 1,
25
+ &args,
26
+ RB_PASS_KEYWORDS
27
+ );
28
+ }
29
+
30
+ VALUE rbs_type_name(VALUE namespace, VALUE name) {
31
+ VALUE args = rb_hash_new();
32
+ rb_hash_aset(args, ID2SYM(rb_intern("namespace")), namespace);
33
+ rb_hash_aset(args, ID2SYM(rb_intern("name")), name);
34
+
35
+ return rb_funcallv_kw(
36
+ RBS_TypeName,
37
+ rb_intern("new"),
38
+ 1,
39
+ &args,
40
+ RB_PASS_KEYWORDS
41
+ );
42
+ }
43
+
44
+ VALUE rbs_class_instance(VALUE typename, VALUE type_args, VALUE location) {
45
+ VALUE args = rb_hash_new();
46
+ rb_hash_aset(args, ID2SYM(rb_intern("name")), typename);
47
+ rb_hash_aset(args, ID2SYM(rb_intern("args")), type_args);
48
+ rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
49
+
50
+ return rb_funcallv_kw(
51
+ RBS_Types_ClassInstance,
52
+ rb_intern("new"),
53
+ 1,
54
+ &args,
55
+ RB_PASS_KEYWORDS
56
+ );
57
+ }
58
+
59
+ VALUE rbs_class_singleton(VALUE typename, VALUE location) {
60
+ VALUE args = rb_hash_new();
61
+ rb_hash_aset(args, ID2SYM(rb_intern("name")), typename);
62
+ rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
63
+
64
+ return rb_funcallv_kw(
65
+ RBS_Types_ClassSingleton,
66
+ rb_intern("new"),
67
+ 1,
68
+ &args,
69
+ RB_PASS_KEYWORDS
70
+ );
71
+ }
72
+
73
+ VALUE rbs_alias(VALUE typename, VALUE location) {
74
+ VALUE args = rb_hash_new();
75
+ rb_hash_aset(args, ID2SYM(rb_intern("name")), typename);
76
+ rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
77
+
78
+ return rb_funcallv_kw(
79
+ RBS_Types_Alias,
80
+ rb_intern("new"),
81
+ 1,
82
+ &args,
83
+ RB_PASS_KEYWORDS
84
+ );
85
+ }
86
+
87
+ VALUE rbs_interface(VALUE typename, VALUE type_args, VALUE location) {
88
+ VALUE args = rb_hash_new();
89
+ rb_hash_aset(args, ID2SYM(rb_intern("name")), typename);
90
+ rb_hash_aset(args, ID2SYM(rb_intern("args")), type_args);
91
+ rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
92
+
93
+ return rb_funcallv_kw(
94
+ RBS_Types_Interface,
95
+ rb_intern("new"),
96
+ 1,
97
+ &args,
98
+ RB_PASS_KEYWORDS
99
+ );
100
+ }
101
+
102
+ VALUE rbs_union(VALUE types, VALUE location) {
103
+ VALUE args = rb_hash_new();
104
+ rb_hash_aset(args, ID2SYM(rb_intern("types")), types);
105
+ rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
106
+
107
+ return rb_funcallv_kw(
108
+ RBS_Types_Union,
109
+ rb_intern("new"),
110
+ 1,
111
+ &args,
112
+ RB_PASS_KEYWORDS
113
+ );
114
+ }
115
+
116
+ VALUE rbs_intersection(VALUE types, VALUE location) {
117
+ VALUE args = rb_hash_new();
118
+ rb_hash_aset(args, ID2SYM(rb_intern("types")), types);
119
+ rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
120
+
121
+ return rb_funcallv_kw(
122
+ RBS_Types_Intersection,
123
+ rb_intern("new"),
124
+ 1,
125
+ &args,
126
+ RB_PASS_KEYWORDS
127
+ );
128
+ }
129
+
130
+ VALUE rbs_tuple(VALUE types, VALUE location) {
131
+ VALUE args = rb_hash_new();
132
+ rb_hash_aset(args, ID2SYM(rb_intern("types")), types);
133
+ rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
134
+
135
+ return rb_funcallv_kw(
136
+ RBS_Types_Tuple,
137
+ rb_intern("new"),
138
+ 1,
139
+ &args,
140
+ RB_PASS_KEYWORDS
141
+ );
142
+ }
143
+
144
+ VALUE rbs_optional(VALUE type, VALUE location) {
145
+ VALUE args = rb_hash_new();
146
+ rb_hash_aset(args, ID2SYM(rb_intern("type")), type);
147
+ rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
148
+
149
+ return rb_funcallv_kw(
150
+ RBS_Types_Optional,
151
+ rb_intern("new"),
152
+ 1,
153
+ &args,
154
+ RB_PASS_KEYWORDS
155
+ );
156
+ }
157
+
158
+ VALUE rbs_block(VALUE type, VALUE required) {
159
+ VALUE args = rb_hash_new();
160
+ rb_hash_aset(args, ID2SYM(rb_intern("type")), type);
161
+ rb_hash_aset(args, ID2SYM(rb_intern("required")), required);
162
+
163
+ return rb_funcallv_kw(
164
+ RBS_Types_Block,
165
+ rb_intern("new"),
166
+ 1,
167
+ &args,
168
+ RB_PASS_KEYWORDS
169
+ );
170
+ }
171
+
172
+ VALUE rbs_function_param(VALUE type, VALUE name, VALUE location) {
173
+ VALUE args = rb_hash_new();
174
+ rb_hash_aset(args, ID2SYM(rb_intern("type")), type);
175
+ rb_hash_aset(args, ID2SYM(rb_intern("name")), name);
176
+ rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
177
+
178
+ return rb_funcallv_kw(
179
+ RBS_Types_Function_Param,
180
+ rb_intern("new"),
181
+ 1,
182
+ &args,
183
+ RB_PASS_KEYWORDS
184
+ );
185
+ }
186
+
187
+ VALUE rbs_function(
188
+ VALUE required_positional_params,
189
+ VALUE optional_positional_params,
190
+ VALUE rest_positional_param,
191
+ VALUE trailing_positional_params,
192
+ VALUE required_keyword_params,
193
+ VALUE optional_keyword_params,
194
+ VALUE rest_keyword_param,
195
+ VALUE return_type
196
+ ) {
197
+ VALUE args = rb_hash_new();
198
+ rb_hash_aset(args, ID2SYM(rb_intern("required_positionals")), required_positional_params);
199
+ rb_hash_aset(args, ID2SYM(rb_intern("optional_positionals")), optional_positional_params);
200
+ rb_hash_aset(args, ID2SYM(rb_intern("rest_positionals")), rest_positional_param);
201
+ rb_hash_aset(args, ID2SYM(rb_intern("trailing_positionals")), trailing_positional_params);
202
+ rb_hash_aset(args, ID2SYM(rb_intern("required_keywords")), required_keyword_params);
203
+ rb_hash_aset(args, ID2SYM(rb_intern("optional_keywords")), optional_keyword_params);
204
+ rb_hash_aset(args, ID2SYM(rb_intern("rest_keywords")), rest_keyword_param);
205
+ rb_hash_aset(args, ID2SYM(rb_intern("return_type")), return_type);
206
+
207
+ return rb_funcallv_kw(
208
+ RBS_Types_Function,
209
+ rb_intern("new"),
210
+ 1,
211
+ &args,
212
+ RB_PASS_KEYWORDS
213
+ );
214
+ }
215
+
216
+ VALUE rbs_proc(VALUE function, VALUE block, VALUE location) {
217
+ VALUE args = rb_hash_new();
218
+ rb_hash_aset(args, ID2SYM(rb_intern("type")), function);
219
+ rb_hash_aset(args, ID2SYM(rb_intern("block")), block);
220
+ rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
221
+
222
+ return rb_funcallv_kw(
223
+ RBS_Types_Proc,
224
+ rb_intern("new"),
225
+ 1,
226
+ &args,
227
+ RB_PASS_KEYWORDS
228
+ );
229
+ }
230
+
231
+ VALUE rbs_void(VALUE location) {
232
+ VALUE args = rb_hash_new();
233
+ rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
234
+
235
+ return rb_funcallv_kw(
236
+ RBS_Types_Bases_Void,
237
+ rb_intern("new"),
238
+ 1,
239
+ &args,
240
+ RB_PASS_KEYWORDS
241
+ );
242
+ }
243
+
244
+ VALUE rbs_literal(VALUE literal, VALUE location) {
245
+ VALUE args = rb_hash_new();
246
+ rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
247
+ rb_hash_aset(args, ID2SYM(rb_intern("literal")), literal);
248
+
249
+ return rb_funcallv_kw(
250
+ RBS_Types_Literal,
251
+ rb_intern("new"),
252
+ 1,
253
+ &args,
254
+ RB_PASS_KEYWORDS
255
+ );
256
+ }
257
+
258
+ VALUE rbs_record(VALUE fields, VALUE location) {
259
+ VALUE args = rb_hash_new();
260
+ rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
261
+ rb_hash_aset(args, ID2SYM(rb_intern("fields")), fields);
262
+
263
+ return rb_funcallv_kw(
264
+ RBS_Types_Record,
265
+ rb_intern("new"),
266
+ 1,
267
+ &args,
268
+ RB_PASS_KEYWORDS
269
+ );
270
+ }
271
+
272
+ VALUE rbs_variable(VALUE name, VALUE location) {
273
+ VALUE args = rb_hash_new();
274
+ rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
275
+ rb_hash_aset(args, ID2SYM(rb_intern("name")), name);
276
+
277
+ return rb_funcallv_kw(
278
+ RBS_Types_Variable,
279
+ rb_intern("new"),
280
+ 1,
281
+ &args,
282
+ RB_PASS_KEYWORDS
283
+ );
284
+ }
285
+
286
+ VALUE rbs_method_type(VALUE type_params, VALUE type, VALUE block, VALUE location) {
287
+ VALUE args = rb_hash_new();
288
+ rb_hash_aset(args, ID2SYM(rb_intern("type_params")), type_params);
289
+ rb_hash_aset(args, ID2SYM(rb_intern("type")), type);
290
+ rb_hash_aset(args, ID2SYM(rb_intern("block")), block);
291
+ rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
292
+
293
+ return rb_funcallv_kw(
294
+ RBS_MethodType,
295
+ rb_intern("new"),
296
+ 1,
297
+ &args,
298
+ RB_PASS_KEYWORDS
299
+ );
300
+ }
301
+
302
+ VALUE rbs_ast_comment(VALUE string, VALUE location) {
303
+ VALUE args = rb_hash_new();
304
+ rb_hash_aset(args, ID2SYM(rb_intern("string")), string);
305
+ rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
306
+
307
+ return rb_funcallv_kw(
308
+ RBS_AST_Comment,
309
+ rb_intern("new"),
310
+ 1,
311
+ &args,
312
+ RB_PASS_KEYWORDS
313
+ );
314
+ }
315
+
316
+ VALUE rbs_ast_annotation(VALUE string, VALUE location) {
317
+ VALUE args = rb_hash_new();
318
+ rb_hash_aset(args, ID2SYM(rb_intern("string")), string);
319
+ rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
320
+
321
+ return rb_funcallv_kw(
322
+ RBS_AST_Annotation,
323
+ rb_intern("new"),
324
+ 1,
325
+ &args,
326
+ RB_PASS_KEYWORDS
327
+ );
328
+ }
329
+
330
+ VALUE rbs_ast_decl_module_type_params() {
331
+ return rb_funcall(RBS_AST_Declarations_ModuleTypeParams, rb_intern("new"), 0);
332
+ }
333
+
334
+ VALUE rbs_ast_decl_module_type_params_param(VALUE name, VALUE variance, VALUE skip_validation, VALUE location) {
335
+ VALUE args = rb_hash_new();
336
+ rb_hash_aset(args, ID2SYM(rb_intern("name")), name);
337
+ rb_hash_aset(args, ID2SYM(rb_intern("variance")), variance);
338
+ rb_hash_aset(args, ID2SYM(rb_intern("skip_validation")), skip_validation);
339
+ rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
340
+
341
+ return rb_funcallv_kw(
342
+ RBS_AST_Declarations_ModuleTypeParams_TypeParam,
343
+ rb_intern("new"),
344
+ 1,
345
+ &args,
346
+ RB_PASS_KEYWORDS
347
+ );
348
+ }
349
+
350
+ VALUE rbs_ast_decl_constant(VALUE name, VALUE type, VALUE location, VALUE comment) {
351
+ VALUE args = rb_hash_new();
352
+ rb_hash_aset(args, ID2SYM(rb_intern("name")), name);
353
+ rb_hash_aset(args, ID2SYM(rb_intern("type")), type);
354
+ rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
355
+ rb_hash_aset(args, ID2SYM(rb_intern("comment")), comment);
356
+
357
+ return rb_funcallv_kw(
358
+ RBS_AST_Declarations_Constant,
359
+ rb_intern("new"),
360
+ 1,
361
+ &args,
362
+ RB_PASS_KEYWORDS
363
+ );
364
+ }
365
+
366
+ VALUE rbs_ast_decl_global(VALUE name, VALUE type, VALUE location, VALUE comment) {
367
+ VALUE args = rb_hash_new();
368
+ rb_hash_aset(args, ID2SYM(rb_intern("name")), name);
369
+ rb_hash_aset(args, ID2SYM(rb_intern("type")), type);
370
+ rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
371
+ rb_hash_aset(args, ID2SYM(rb_intern("comment")), comment);
372
+
373
+ return rb_funcallv_kw(
374
+ RBS_AST_Declarations_Global,
375
+ rb_intern("new"),
376
+ 1,
377
+ &args,
378
+ RB_PASS_KEYWORDS
379
+ );
380
+ }
381
+
382
+ VALUE rbs_ast_decl_alias(VALUE name, VALUE type, VALUE annotations, VALUE location, VALUE comment) {
383
+ VALUE args = rb_hash_new();
384
+ rb_hash_aset(args, ID2SYM(rb_intern("name")), name);
385
+ rb_hash_aset(args, ID2SYM(rb_intern("type")), type);
386
+ rb_hash_aset(args, ID2SYM(rb_intern("annotations")), annotations);
387
+ rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
388
+ rb_hash_aset(args, ID2SYM(rb_intern("comment")), comment);
389
+
390
+ return rb_funcallv_kw(
391
+ RBS_AST_Declarations_Alias,
392
+ rb_intern("new"),
393
+ 1,
394
+ &args,
395
+ RB_PASS_KEYWORDS
396
+ );
397
+ }
398
+
399
+ VALUE rbs_ast_decl_interface(VALUE name, VALUE type_params, VALUE members, VALUE annotations, VALUE location, VALUE comment) {
400
+ VALUE args = rb_hash_new();
401
+ rb_hash_aset(args, ID2SYM(rb_intern("name")), name);
402
+ rb_hash_aset(args, ID2SYM(rb_intern("type_params")), type_params);
403
+ rb_hash_aset(args, ID2SYM(rb_intern("members")), members);
404
+ rb_hash_aset(args, ID2SYM(rb_intern("annotations")), annotations);
405
+ rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
406
+ rb_hash_aset(args, ID2SYM(rb_intern("comment")), comment);
407
+
408
+ return rb_funcallv_kw(
409
+ RBS_AST_Declarations_Interface,
410
+ rb_intern("new"),
411
+ 1,
412
+ &args,
413
+ RB_PASS_KEYWORDS
414
+ );
415
+ }
416
+
417
+ VALUE rbs_ast_decl_module_self(VALUE name, VALUE args, VALUE location) {
418
+ VALUE kw_args = rb_hash_new();
419
+ rb_hash_aset(kw_args, ID2SYM(rb_intern("name")), name);
420
+ rb_hash_aset(kw_args, ID2SYM(rb_intern("args")), args);
421
+ rb_hash_aset(kw_args, ID2SYM(rb_intern("location")), location);
422
+
423
+ return rb_funcallv_kw(
424
+ RBS_AST_Declarations_Module_Self,
425
+ rb_intern("new"),
426
+ 1,
427
+ &kw_args,
428
+ RB_PASS_KEYWORDS
429
+ );
430
+ }
431
+
432
+ VALUE rbs_ast_decl_module(VALUE name, VALUE type_params, VALUE self_types, VALUE members, VALUE annotations, VALUE location, VALUE comment) {
433
+ VALUE args = rb_hash_new();
434
+ rb_hash_aset(args, ID2SYM(rb_intern("name")), name);
435
+ rb_hash_aset(args, ID2SYM(rb_intern("type_params")), type_params);
436
+ rb_hash_aset(args, ID2SYM(rb_intern("self_types")), self_types);
437
+ rb_hash_aset(args, ID2SYM(rb_intern("members")), members);
438
+ rb_hash_aset(args, ID2SYM(rb_intern("annotations")), annotations);
439
+ rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
440
+ rb_hash_aset(args, ID2SYM(rb_intern("comment")), comment);
441
+
442
+ return rb_funcallv_kw(
443
+ RBS_AST_Declarations_Module,
444
+ rb_intern("new"),
445
+ 1,
446
+ &args,
447
+ RB_PASS_KEYWORDS
448
+ );
449
+ }
450
+
451
+ VALUE rbs_ast_members_method_definition(VALUE name, VALUE kind, VALUE types, VALUE annotations, VALUE location, VALUE comment, VALUE overload) {
452
+ VALUE args = rb_hash_new();
453
+ rb_hash_aset(args, ID2SYM(rb_intern("name")), name);
454
+ rb_hash_aset(args, ID2SYM(rb_intern("kind")), kind);
455
+ rb_hash_aset(args, ID2SYM(rb_intern("types")), types);
456
+ rb_hash_aset(args, ID2SYM(rb_intern("annotations")), annotations);
457
+ rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
458
+ rb_hash_aset(args, ID2SYM(rb_intern("comment")), comment);
459
+ rb_hash_aset(args, ID2SYM(rb_intern("overload")), overload);
460
+
461
+ return rb_funcallv_kw(
462
+ RBS_AST_Members_MethodDefinition,
463
+ rb_intern("new"),
464
+ 1,
465
+ &args,
466
+ RB_PASS_KEYWORDS
467
+ );
468
+ }
469
+
470
+ VALUE rbs_ast_members_variable(VALUE klass, VALUE name, VALUE type, VALUE location, VALUE comment) {
471
+ VALUE args = rb_hash_new();
472
+ rb_hash_aset(args, ID2SYM(rb_intern("name")), name);
473
+ rb_hash_aset(args, ID2SYM(rb_intern("type")), type);
474
+ rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
475
+ rb_hash_aset(args, ID2SYM(rb_intern("comment")), comment);
476
+
477
+ return rb_funcallv_kw(
478
+ klass,
479
+ rb_intern("new"),
480
+ 1,
481
+ &args,
482
+ RB_PASS_KEYWORDS
483
+ );
484
+ }
485
+
486
+ VALUE rbs_ast_members_mixin(VALUE klass, VALUE name, VALUE module_args, VALUE annotations, VALUE location, VALUE comment) {
487
+ VALUE args = rb_hash_new();
488
+ rb_hash_aset(args, ID2SYM(rb_intern("name")), name);
489
+ rb_hash_aset(args, ID2SYM(rb_intern("args")), module_args);
490
+ rb_hash_aset(args, ID2SYM(rb_intern("annotations")), annotations);
491
+ rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
492
+ rb_hash_aset(args, ID2SYM(rb_intern("comment")), comment);
493
+
494
+ return rb_funcallv_kw(
495
+ klass,
496
+ rb_intern("new"),
497
+ 1,
498
+ &args,
499
+ RB_PASS_KEYWORDS
500
+ );
501
+ }
502
+
503
+ VALUE rbs_ast_members_attribute(VALUE klass, VALUE name, VALUE type, VALUE ivar_name, VALUE kind, VALUE annotations, VALUE location, VALUE comment) {
504
+ VALUE args = rb_hash_new();
505
+ rb_hash_aset(args, ID2SYM(rb_intern("name")), name);
506
+ rb_hash_aset(args, ID2SYM(rb_intern("type")), type);
507
+ rb_hash_aset(args, ID2SYM(rb_intern("ivar_name")), ivar_name);
508
+ rb_hash_aset(args, ID2SYM(rb_intern("kind")), kind);
509
+ rb_hash_aset(args, ID2SYM(rb_intern("annotations")), annotations);
510
+ rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
511
+ rb_hash_aset(args, ID2SYM(rb_intern("comment")), comment);
512
+
513
+ return rb_funcallv_kw(
514
+ klass,
515
+ rb_intern("new"),
516
+ 1,
517
+ &args,
518
+ RB_PASS_KEYWORDS
519
+ );
520
+ }
521
+
522
+ VALUE rbs_ast_members_visibility(VALUE klass, VALUE location) {
523
+ VALUE args = rb_hash_new();
524
+ rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
525
+
526
+ return rb_funcallv_kw(
527
+ klass,
528
+ rb_intern("new"),
529
+ 1,
530
+ &args,
531
+ RB_PASS_KEYWORDS
532
+ );
533
+ }
534
+
535
+ VALUE rbs_ast_members_alias(VALUE new_name, VALUE old_name, VALUE kind, VALUE annotations, VALUE location, VALUE comment) {
536
+ VALUE args = rb_hash_new();
537
+ rb_hash_aset(args, ID2SYM(rb_intern("new_name")), new_name);
538
+ rb_hash_aset(args, ID2SYM(rb_intern("old_name")), old_name);
539
+ rb_hash_aset(args, ID2SYM(rb_intern("kind")), kind);
540
+ rb_hash_aset(args, ID2SYM(rb_intern("annotations")), annotations);
541
+ rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
542
+ rb_hash_aset(args, ID2SYM(rb_intern("comment")), comment);
543
+
544
+ return rb_funcallv_kw(
545
+ RBS_AST_Members_Alias,
546
+ rb_intern("new"),
547
+ 1,
548
+ &args,
549
+ RB_PASS_KEYWORDS
550
+ );
551
+ }
552
+
553
+ VALUE rbs_ast_decl_class_super(VALUE name, VALUE args, VALUE location) {
554
+ VALUE kwargs = rb_hash_new();
555
+ rb_hash_aset(kwargs, ID2SYM(rb_intern("name")), name);
556
+ rb_hash_aset(kwargs, ID2SYM(rb_intern("args")), args);
557
+ rb_hash_aset(kwargs, ID2SYM(rb_intern("location")), location);
558
+
559
+ return rb_funcallv_kw(
560
+ RBS_AST_Declarations_Class_Super,
561
+ rb_intern("new"),
562
+ 1,
563
+ &kwargs,
564
+ RB_PASS_KEYWORDS
565
+ );
566
+ }
567
+
568
+ VALUE rbs_ast_decl_class(VALUE name, VALUE type_params, VALUE super_class, VALUE members, VALUE annotations, VALUE location, VALUE comment) {
569
+ VALUE kwargs = rb_hash_new();
570
+ rb_hash_aset(kwargs, ID2SYM(rb_intern("name")), name);
571
+ rb_hash_aset(kwargs, ID2SYM(rb_intern("type_params")), type_params);
572
+ rb_hash_aset(kwargs, ID2SYM(rb_intern("super_class")), super_class);
573
+ rb_hash_aset(kwargs, ID2SYM(rb_intern("members")), members);
574
+ rb_hash_aset(kwargs, ID2SYM(rb_intern("annotations")), annotations);
575
+ rb_hash_aset(kwargs, ID2SYM(rb_intern("location")), location);
576
+ rb_hash_aset(kwargs, ID2SYM(rb_intern("comment")), comment);
577
+
578
+ return rb_funcallv_kw(
579
+ RBS_AST_Declarations_Class,
580
+ rb_intern("new"),
581
+ 1,
582
+ &kwargs,
583
+ RB_PASS_KEYWORDS
584
+ );
585
+ }