rbs 1.7.0.beta.2 → 1.7.0.beta.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,15 +1,23 @@
1
1
  #include "rbs_extension.h"
2
2
 
3
+ #ifdef RB_PASS_KEYWORDS
4
+ // Ruby 2.7 or later
5
+ #define CLASS_NEW_INSTANCE(klass, argc, argv)\
6
+ rb_class_new_instance_kw(argc, argv, klass, RB_PASS_KEYWORDS)
7
+ #else
8
+ // Ruby 2.6
9
+ #define CLASS_NEW_INSTANCE(receiver, argc, argv)\
10
+ rb_class_new_instance(argc, argv, receiver)
11
+ #endif
12
+
3
13
  VALUE rbs_base_type(VALUE klass, VALUE location) {
4
14
  VALUE args = rb_hash_new();
5
15
  rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
6
16
 
7
- return rb_funcallv_kw(
17
+ return CLASS_NEW_INSTANCE(
8
18
  klass,
9
- rb_intern("new"),
10
19
  1,
11
- &args,
12
- RB_PASS_KEYWORDS
20
+ &args
13
21
  );
14
22
  }
15
23
 
@@ -18,12 +26,10 @@ VALUE rbs_namespace(VALUE path, VALUE absolute) {
18
26
  rb_hash_aset(args, ID2SYM(rb_intern("path")), path);
19
27
  rb_hash_aset(args, ID2SYM(rb_intern("absolute")), absolute);
20
28
 
21
- return rb_funcallv_kw(
29
+ return CLASS_NEW_INSTANCE(
22
30
  RBS_Namespace,
23
- rb_intern("new"),
24
31
  1,
25
- &args,
26
- RB_PASS_KEYWORDS
32
+ &args
27
33
  );
28
34
  }
29
35
 
@@ -32,12 +38,10 @@ VALUE rbs_type_name(VALUE namespace, VALUE name) {
32
38
  rb_hash_aset(args, ID2SYM(rb_intern("namespace")), namespace);
33
39
  rb_hash_aset(args, ID2SYM(rb_intern("name")), name);
34
40
 
35
- return rb_funcallv_kw(
41
+ return CLASS_NEW_INSTANCE(
36
42
  RBS_TypeName,
37
- rb_intern("new"),
38
43
  1,
39
- &args,
40
- RB_PASS_KEYWORDS
44
+ &args
41
45
  );
42
46
  }
43
47
 
@@ -47,12 +51,10 @@ VALUE rbs_class_instance(VALUE typename, VALUE type_args, VALUE location) {
47
51
  rb_hash_aset(args, ID2SYM(rb_intern("args")), type_args);
48
52
  rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
49
53
 
50
- return rb_funcallv_kw(
54
+ return CLASS_NEW_INSTANCE(
51
55
  RBS_Types_ClassInstance,
52
- rb_intern("new"),
53
56
  1,
54
- &args,
55
- RB_PASS_KEYWORDS
57
+ &args
56
58
  );
57
59
  }
58
60
 
@@ -61,12 +63,10 @@ VALUE rbs_class_singleton(VALUE typename, VALUE location) {
61
63
  rb_hash_aset(args, ID2SYM(rb_intern("name")), typename);
62
64
  rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
63
65
 
64
- return rb_funcallv_kw(
66
+ return CLASS_NEW_INSTANCE(
65
67
  RBS_Types_ClassSingleton,
66
- rb_intern("new"),
67
68
  1,
68
- &args,
69
- RB_PASS_KEYWORDS
69
+ &args
70
70
  );
71
71
  }
72
72
 
@@ -75,12 +75,10 @@ VALUE rbs_alias(VALUE typename, VALUE location) {
75
75
  rb_hash_aset(args, ID2SYM(rb_intern("name")), typename);
76
76
  rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
77
77
 
78
- return rb_funcallv_kw(
78
+ return CLASS_NEW_INSTANCE(
79
79
  RBS_Types_Alias,
80
- rb_intern("new"),
81
80
  1,
82
- &args,
83
- RB_PASS_KEYWORDS
81
+ &args
84
82
  );
85
83
  }
86
84
 
@@ -90,12 +88,10 @@ VALUE rbs_interface(VALUE typename, VALUE type_args, VALUE location) {
90
88
  rb_hash_aset(args, ID2SYM(rb_intern("args")), type_args);
91
89
  rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
92
90
 
93
- return rb_funcallv_kw(
91
+ return CLASS_NEW_INSTANCE(
94
92
  RBS_Types_Interface,
95
- rb_intern("new"),
96
93
  1,
97
- &args,
98
- RB_PASS_KEYWORDS
94
+ &args
99
95
  );
100
96
  }
101
97
 
@@ -104,12 +100,10 @@ VALUE rbs_union(VALUE types, VALUE location) {
104
100
  rb_hash_aset(args, ID2SYM(rb_intern("types")), types);
105
101
  rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
106
102
 
107
- return rb_funcallv_kw(
103
+ return CLASS_NEW_INSTANCE(
108
104
  RBS_Types_Union,
109
- rb_intern("new"),
110
105
  1,
111
- &args,
112
- RB_PASS_KEYWORDS
106
+ &args
113
107
  );
114
108
  }
115
109
 
@@ -118,12 +112,10 @@ VALUE rbs_intersection(VALUE types, VALUE location) {
118
112
  rb_hash_aset(args, ID2SYM(rb_intern("types")), types);
119
113
  rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
120
114
 
121
- return rb_funcallv_kw(
115
+ return CLASS_NEW_INSTANCE(
122
116
  RBS_Types_Intersection,
123
- rb_intern("new"),
124
117
  1,
125
- &args,
126
- RB_PASS_KEYWORDS
118
+ &args
127
119
  );
128
120
  }
129
121
 
@@ -132,12 +124,10 @@ VALUE rbs_tuple(VALUE types, VALUE location) {
132
124
  rb_hash_aset(args, ID2SYM(rb_intern("types")), types);
133
125
  rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
134
126
 
135
- return rb_funcallv_kw(
127
+ return CLASS_NEW_INSTANCE(
136
128
  RBS_Types_Tuple,
137
- rb_intern("new"),
138
129
  1,
139
- &args,
140
- RB_PASS_KEYWORDS
130
+ &args
141
131
  );
142
132
  }
143
133
 
@@ -146,12 +136,10 @@ VALUE rbs_optional(VALUE type, VALUE location) {
146
136
  rb_hash_aset(args, ID2SYM(rb_intern("type")), type);
147
137
  rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
148
138
 
149
- return rb_funcallv_kw(
139
+ return CLASS_NEW_INSTANCE(
150
140
  RBS_Types_Optional,
151
- rb_intern("new"),
152
141
  1,
153
- &args,
154
- RB_PASS_KEYWORDS
142
+ &args
155
143
  );
156
144
  }
157
145
 
@@ -160,12 +148,10 @@ VALUE rbs_block(VALUE type, VALUE required) {
160
148
  rb_hash_aset(args, ID2SYM(rb_intern("type")), type);
161
149
  rb_hash_aset(args, ID2SYM(rb_intern("required")), required);
162
150
 
163
- return rb_funcallv_kw(
151
+ return CLASS_NEW_INSTANCE(
164
152
  RBS_Types_Block,
165
- rb_intern("new"),
166
153
  1,
167
- &args,
168
- RB_PASS_KEYWORDS
154
+ &args
169
155
  );
170
156
  }
171
157
 
@@ -175,12 +161,10 @@ VALUE rbs_function_param(VALUE type, VALUE name, VALUE location) {
175
161
  rb_hash_aset(args, ID2SYM(rb_intern("name")), name);
176
162
  rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
177
163
 
178
- return rb_funcallv_kw(
164
+ return CLASS_NEW_INSTANCE(
179
165
  RBS_Types_Function_Param,
180
- rb_intern("new"),
181
166
  1,
182
- &args,
183
- RB_PASS_KEYWORDS
167
+ &args
184
168
  );
185
169
  }
186
170
 
@@ -204,12 +188,10 @@ VALUE rbs_function(
204
188
  rb_hash_aset(args, ID2SYM(rb_intern("rest_keywords")), rest_keyword_param);
205
189
  rb_hash_aset(args, ID2SYM(rb_intern("return_type")), return_type);
206
190
 
207
- return rb_funcallv_kw(
191
+ return CLASS_NEW_INSTANCE(
208
192
  RBS_Types_Function,
209
- rb_intern("new"),
210
193
  1,
211
- &args,
212
- RB_PASS_KEYWORDS
194
+ &args
213
195
  );
214
196
  }
215
197
 
@@ -219,12 +201,10 @@ VALUE rbs_proc(VALUE function, VALUE block, VALUE location) {
219
201
  rb_hash_aset(args, ID2SYM(rb_intern("block")), block);
220
202
  rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
221
203
 
222
- return rb_funcallv_kw(
204
+ return CLASS_NEW_INSTANCE(
223
205
  RBS_Types_Proc,
224
- rb_intern("new"),
225
206
  1,
226
- &args,
227
- RB_PASS_KEYWORDS
207
+ &args
228
208
  );
229
209
  }
230
210
 
@@ -232,12 +212,10 @@ VALUE rbs_void(VALUE location) {
232
212
  VALUE args = rb_hash_new();
233
213
  rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
234
214
 
235
- return rb_funcallv_kw(
215
+ return CLASS_NEW_INSTANCE(
236
216
  RBS_Types_Bases_Void,
237
- rb_intern("new"),
238
217
  1,
239
- &args,
240
- RB_PASS_KEYWORDS
218
+ &args
241
219
  );
242
220
  }
243
221
 
@@ -246,12 +224,10 @@ VALUE rbs_literal(VALUE literal, VALUE location) {
246
224
  rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
247
225
  rb_hash_aset(args, ID2SYM(rb_intern("literal")), literal);
248
226
 
249
- return rb_funcallv_kw(
227
+ return CLASS_NEW_INSTANCE(
250
228
  RBS_Types_Literal,
251
- rb_intern("new"),
252
229
  1,
253
- &args,
254
- RB_PASS_KEYWORDS
230
+ &args
255
231
  );
256
232
  }
257
233
 
@@ -260,12 +236,10 @@ VALUE rbs_record(VALUE fields, VALUE location) {
260
236
  rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
261
237
  rb_hash_aset(args, ID2SYM(rb_intern("fields")), fields);
262
238
 
263
- return rb_funcallv_kw(
239
+ return CLASS_NEW_INSTANCE(
264
240
  RBS_Types_Record,
265
- rb_intern("new"),
266
241
  1,
267
- &args,
268
- RB_PASS_KEYWORDS
242
+ &args
269
243
  );
270
244
  }
271
245
 
@@ -274,12 +248,10 @@ VALUE rbs_variable(VALUE name, VALUE location) {
274
248
  rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
275
249
  rb_hash_aset(args, ID2SYM(rb_intern("name")), name);
276
250
 
277
- return rb_funcallv_kw(
251
+ return CLASS_NEW_INSTANCE(
278
252
  RBS_Types_Variable,
279
- rb_intern("new"),
280
253
  1,
281
- &args,
282
- RB_PASS_KEYWORDS
254
+ &args
283
255
  );
284
256
  }
285
257
 
@@ -290,12 +262,10 @@ VALUE rbs_method_type(VALUE type_params, VALUE type, VALUE block, VALUE location
290
262
  rb_hash_aset(args, ID2SYM(rb_intern("block")), block);
291
263
  rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
292
264
 
293
- return rb_funcallv_kw(
265
+ return CLASS_NEW_INSTANCE(
294
266
  RBS_MethodType,
295
- rb_intern("new"),
296
267
  1,
297
- &args,
298
- RB_PASS_KEYWORDS
268
+ &args
299
269
  );
300
270
  }
301
271
 
@@ -304,12 +274,10 @@ VALUE rbs_ast_comment(VALUE string, VALUE location) {
304
274
  rb_hash_aset(args, ID2SYM(rb_intern("string")), string);
305
275
  rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
306
276
 
307
- return rb_funcallv_kw(
277
+ return CLASS_NEW_INSTANCE(
308
278
  RBS_AST_Comment,
309
- rb_intern("new"),
310
279
  1,
311
- &args,
312
- RB_PASS_KEYWORDS
280
+ &args
313
281
  );
314
282
  }
315
283
 
@@ -318,12 +286,10 @@ VALUE rbs_ast_annotation(VALUE string, VALUE location) {
318
286
  rb_hash_aset(args, ID2SYM(rb_intern("string")), string);
319
287
  rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
320
288
 
321
- return rb_funcallv_kw(
289
+ return CLASS_NEW_INSTANCE(
322
290
  RBS_AST_Annotation,
323
- rb_intern("new"),
324
291
  1,
325
- &args,
326
- RB_PASS_KEYWORDS
292
+ &args
327
293
  );
328
294
  }
329
295
 
@@ -338,12 +304,10 @@ VALUE rbs_ast_decl_module_type_params_param(VALUE name, VALUE variance, VALUE sk
338
304
  rb_hash_aset(args, ID2SYM(rb_intern("skip_validation")), skip_validation);
339
305
  rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
340
306
 
341
- return rb_funcallv_kw(
307
+ return CLASS_NEW_INSTANCE(
342
308
  RBS_AST_Declarations_ModuleTypeParams_TypeParam,
343
- rb_intern("new"),
344
309
  1,
345
- &args,
346
- RB_PASS_KEYWORDS
310
+ &args
347
311
  );
348
312
  }
349
313
 
@@ -354,12 +318,10 @@ VALUE rbs_ast_decl_constant(VALUE name, VALUE type, VALUE location, VALUE commen
354
318
  rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
355
319
  rb_hash_aset(args, ID2SYM(rb_intern("comment")), comment);
356
320
 
357
- return rb_funcallv_kw(
321
+ return CLASS_NEW_INSTANCE(
358
322
  RBS_AST_Declarations_Constant,
359
- rb_intern("new"),
360
323
  1,
361
- &args,
362
- RB_PASS_KEYWORDS
324
+ &args
363
325
  );
364
326
  }
365
327
 
@@ -370,12 +332,10 @@ VALUE rbs_ast_decl_global(VALUE name, VALUE type, VALUE location, VALUE comment)
370
332
  rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
371
333
  rb_hash_aset(args, ID2SYM(rb_intern("comment")), comment);
372
334
 
373
- return rb_funcallv_kw(
335
+ return CLASS_NEW_INSTANCE(
374
336
  RBS_AST_Declarations_Global,
375
- rb_intern("new"),
376
337
  1,
377
- &args,
378
- RB_PASS_KEYWORDS
338
+ &args
379
339
  );
380
340
  }
381
341
 
@@ -387,12 +347,10 @@ VALUE rbs_ast_decl_alias(VALUE name, VALUE type, VALUE annotations, VALUE locati
387
347
  rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
388
348
  rb_hash_aset(args, ID2SYM(rb_intern("comment")), comment);
389
349
 
390
- return rb_funcallv_kw(
350
+ return CLASS_NEW_INSTANCE(
391
351
  RBS_AST_Declarations_Alias,
392
- rb_intern("new"),
393
352
  1,
394
- &args,
395
- RB_PASS_KEYWORDS
353
+ &args
396
354
  );
397
355
  }
398
356
 
@@ -405,12 +363,10 @@ VALUE rbs_ast_decl_interface(VALUE name, VALUE type_params, VALUE members, VALUE
405
363
  rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
406
364
  rb_hash_aset(args, ID2SYM(rb_intern("comment")), comment);
407
365
 
408
- return rb_funcallv_kw(
366
+ return CLASS_NEW_INSTANCE(
409
367
  RBS_AST_Declarations_Interface,
410
- rb_intern("new"),
411
368
  1,
412
- &args,
413
- RB_PASS_KEYWORDS
369
+ &args
414
370
  );
415
371
  }
416
372
 
@@ -420,12 +376,10 @@ VALUE rbs_ast_decl_module_self(VALUE name, VALUE args, VALUE location) {
420
376
  rb_hash_aset(kw_args, ID2SYM(rb_intern("args")), args);
421
377
  rb_hash_aset(kw_args, ID2SYM(rb_intern("location")), location);
422
378
 
423
- return rb_funcallv_kw(
379
+ return CLASS_NEW_INSTANCE(
424
380
  RBS_AST_Declarations_Module_Self,
425
- rb_intern("new"),
426
381
  1,
427
- &kw_args,
428
- RB_PASS_KEYWORDS
382
+ &kw_args
429
383
  );
430
384
  }
431
385
 
@@ -439,12 +393,10 @@ VALUE rbs_ast_decl_module(VALUE name, VALUE type_params, VALUE self_types, VALUE
439
393
  rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
440
394
  rb_hash_aset(args, ID2SYM(rb_intern("comment")), comment);
441
395
 
442
- return rb_funcallv_kw(
396
+ return CLASS_NEW_INSTANCE(
443
397
  RBS_AST_Declarations_Module,
444
- rb_intern("new"),
445
398
  1,
446
- &args,
447
- RB_PASS_KEYWORDS
399
+ &args
448
400
  );
449
401
  }
450
402
 
@@ -458,12 +410,10 @@ VALUE rbs_ast_members_method_definition(VALUE name, VALUE kind, VALUE types, VAL
458
410
  rb_hash_aset(args, ID2SYM(rb_intern("comment")), comment);
459
411
  rb_hash_aset(args, ID2SYM(rb_intern("overload")), overload);
460
412
 
461
- return rb_funcallv_kw(
413
+ return CLASS_NEW_INSTANCE(
462
414
  RBS_AST_Members_MethodDefinition,
463
- rb_intern("new"),
464
415
  1,
465
- &args,
466
- RB_PASS_KEYWORDS
416
+ &args
467
417
  );
468
418
  }
469
419
 
@@ -474,12 +424,10 @@ VALUE rbs_ast_members_variable(VALUE klass, VALUE name, VALUE type, VALUE locati
474
424
  rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
475
425
  rb_hash_aset(args, ID2SYM(rb_intern("comment")), comment);
476
426
 
477
- return rb_funcallv_kw(
427
+ return CLASS_NEW_INSTANCE(
478
428
  klass,
479
- rb_intern("new"),
480
429
  1,
481
- &args,
482
- RB_PASS_KEYWORDS
430
+ &args
483
431
  );
484
432
  }
485
433
 
@@ -491,12 +439,10 @@ VALUE rbs_ast_members_mixin(VALUE klass, VALUE name, VALUE module_args, VALUE an
491
439
  rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
492
440
  rb_hash_aset(args, ID2SYM(rb_intern("comment")), comment);
493
441
 
494
- return rb_funcallv_kw(
442
+ return CLASS_NEW_INSTANCE(
495
443
  klass,
496
- rb_intern("new"),
497
444
  1,
498
- &args,
499
- RB_PASS_KEYWORDS
445
+ &args
500
446
  );
501
447
  }
502
448
 
@@ -510,12 +456,10 @@ VALUE rbs_ast_members_attribute(VALUE klass, VALUE name, VALUE type, VALUE ivar_
510
456
  rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
511
457
  rb_hash_aset(args, ID2SYM(rb_intern("comment")), comment);
512
458
 
513
- return rb_funcallv_kw(
459
+ return CLASS_NEW_INSTANCE(
514
460
  klass,
515
- rb_intern("new"),
516
461
  1,
517
- &args,
518
- RB_PASS_KEYWORDS
462
+ &args
519
463
  );
520
464
  }
521
465
 
@@ -523,12 +467,10 @@ VALUE rbs_ast_members_visibility(VALUE klass, VALUE location) {
523
467
  VALUE args = rb_hash_new();
524
468
  rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
525
469
 
526
- return rb_funcallv_kw(
470
+ return CLASS_NEW_INSTANCE(
527
471
  klass,
528
- rb_intern("new"),
529
472
  1,
530
- &args,
531
- RB_PASS_KEYWORDS
473
+ &args
532
474
  );
533
475
  }
534
476
 
@@ -541,12 +483,10 @@ VALUE rbs_ast_members_alias(VALUE new_name, VALUE old_name, VALUE kind, VALUE an
541
483
  rb_hash_aset(args, ID2SYM(rb_intern("location")), location);
542
484
  rb_hash_aset(args, ID2SYM(rb_intern("comment")), comment);
543
485
 
544
- return rb_funcallv_kw(
486
+ return CLASS_NEW_INSTANCE(
545
487
  RBS_AST_Members_Alias,
546
- rb_intern("new"),
547
488
  1,
548
- &args,
549
- RB_PASS_KEYWORDS
489
+ &args
550
490
  );
551
491
  }
552
492
 
@@ -556,12 +496,10 @@ VALUE rbs_ast_decl_class_super(VALUE name, VALUE args, VALUE location) {
556
496
  rb_hash_aset(kwargs, ID2SYM(rb_intern("args")), args);
557
497
  rb_hash_aset(kwargs, ID2SYM(rb_intern("location")), location);
558
498
 
559
- return rb_funcallv_kw(
499
+ return CLASS_NEW_INSTANCE(
560
500
  RBS_AST_Declarations_Class_Super,
561
- rb_intern("new"),
562
501
  1,
563
- &kwargs,
564
- RB_PASS_KEYWORDS
502
+ &kwargs
565
503
  );
566
504
  }
567
505
 
@@ -575,11 +513,9 @@ VALUE rbs_ast_decl_class(VALUE name, VALUE type_params, VALUE super_class, VALUE
575
513
  rb_hash_aset(kwargs, ID2SYM(rb_intern("location")), location);
576
514
  rb_hash_aset(kwargs, ID2SYM(rb_intern("comment")), comment);
577
515
 
578
- return rb_funcallv_kw(
516
+ return CLASS_NEW_INSTANCE(
579
517
  RBS_AST_Declarations_Class,
580
- rb_intern("new"),
581
518
  1,
582
- &kwargs,
583
- RB_PASS_KEYWORDS
519
+ &kwargs
584
520
  );
585
521
  }
@@ -11,6 +11,7 @@ module RBS
11
11
 
12
12
  def install_from_lockfile
13
13
  install_to = lockfile.repo_path
14
+ install_to.mkpath
14
15
  lockfile.gems.each do |config_entry|
15
16
  source_for(config_entry).install(dest: install_to, config_entry: config_entry, stdout: stdout)
16
17
  end
data/lib/rbs/errors.rb CHANGED
@@ -32,10 +32,16 @@ module RBS
32
32
  end
33
33
 
34
34
  def error_value
35
+ RBS.print_warning {
36
+ "#{self.class.name}#error_value is deprecated and will be deleted in RBS 2.0. Consider using `location.source` instead."
37
+ }
35
38
  location.source
36
39
  end
37
40
 
38
41
  def token_str
42
+ RBS.print_warning {
43
+ "#{self.class.name}#token_str is deprecated and will be deleted in RBS 2.0. Consider using `token_type` instead."
44
+ }
39
45
  token_type
40
46
  end
41
47
  end
@@ -21,11 +21,43 @@ module RBS
21
21
  end
22
22
  end
23
23
 
24
- SyntaxError = ParsingError
25
- SemanticsError = ParsingError
26
- LexerError = ParsingError
24
+ autoload :SyntaxError, "rbs/parser_compat/syntax_error"
25
+ autoload :SemanticsError, "rbs/parser_compat/semantics_error"
26
+ autoload :LexerError, "rbs/parser_compat/lexer_error"
27
+ autoload :LocatedValue, "rbs/parser_compat/located_value"
27
28
 
28
- class LocatedValue
29
- end
29
+ KEYWORDS = Set.new(
30
+ %w(
31
+ bool
32
+ bot
33
+ class
34
+ instance
35
+ interface
36
+ nil
37
+ self
38
+ singleton
39
+ top
40
+ void
41
+ type
42
+ unchecked
43
+ in
44
+ out
45
+ end
46
+ def
47
+ include
48
+ extend
49
+ prepend
50
+ alias
51
+ module
52
+ attr_reader
53
+ attr_writer
54
+ attr_accessor
55
+ public
56
+ private
57
+ untyped
58
+ true
59
+ false
60
+ )
61
+ )
30
62
  end
31
63
  end
@@ -0,0 +1,4 @@
1
+ RBS.print_warning {
2
+ "RBS::Parser::LexerError is deprecated and will be deleted in RBS 2.0."
3
+ }
4
+ RBS::Parser::LexerError = RBS::ParsingError
@@ -0,0 +1,5 @@
1
+ RBS.print_warning {
2
+ "RBS::Parser::LocatedValue is deprecated and will be deleted in RBS 2.0."
3
+ }
4
+ class RBS::Parser::LocatedValue
5
+ end
@@ -0,0 +1,4 @@
1
+ RBS.print_warning {
2
+ "RBS::Parser::SemanticsError is deprecated and will be deleted in RBS 2.0."
3
+ }
4
+ RBS::Parser::SemanticsError = RBS::ParsingError
@@ -0,0 +1,4 @@
1
+ RBS.print_warning {
2
+ "RBS::Parser::SyntaxError is deprecated and will be deleted in RBS 2.0."
3
+ }
4
+ RBS::Parser::SyntaxError = RBS::ParsingError
data/lib/rbs/types.rb CHANGED
@@ -433,7 +433,7 @@ module RBS
433
433
  return "{ }" if self.fields.empty?
434
434
 
435
435
  fields = self.fields.map do |key, type|
436
- if key.is_a?(Symbol) && key.match?(/\A[A-Za-z_][A-Za-z_]*\z/) && !Parser::KEYWORDS.key?(key)
436
+ if key.is_a?(Symbol) && key.match?(/\A[A-Za-z_][A-Za-z_]*\z/) && !Parser::KEYWORDS.include?(key)
437
437
  "#{key}: #{type}"
438
438
  else
439
439
  "#{key.inspect} => #{type}"
@@ -690,7 +690,7 @@ module RBS
690
690
 
691
691
  def to_s
692
692
  if name
693
- if Parser::KEYWORDS.key?(name)
693
+ if Parser::KEYWORDS.include?(name)
694
694
  "#{type} `#{name}`"
695
695
  else
696
696
  "#{type} #{name}"
data/lib/rbs/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module RBS
2
- VERSION = "1.7.0.beta.2"
2
+ VERSION = "1.7.0.beta.3"
3
3
  end
data/lib/rbs.rb CHANGED
@@ -68,5 +68,16 @@ module RBS
68
68
  @logger_level = level
69
69
  @logger = nil
70
70
  end
71
+
72
+ def print_warning()
73
+ @warnings ||= Set[]
74
+
75
+ message = yield()
76
+
77
+ unless @warnings.include?(message)
78
+ @warnings << message
79
+ logger.warn { message }
80
+ end
81
+ end
71
82
  end
72
83
  end