Skip to content

Commit c8b7fce

Browse files
committed
Add SkipAnnotation AST
1 parent de06b01 commit c8b7fce

File tree

7 files changed

+44
-0
lines changed

7 files changed

+44
-0
lines changed

config.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,3 +332,9 @@ nodes:
332332
- name: prefix_location
333333
- name: overloads
334334
- name: vertical_bar_locations
335+
- name: RBS::AST::Ruby::Annotations::SkipAnnotation
336+
fields:
337+
- name: location
338+
- name: prefix_location
339+
- name: skip_location
340+
- name: comment_location

include/rbs/constants.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ extern VALUE RBS_AST_Members_Public;
5252
extern VALUE RBS_AST_Ruby_Annotations_ColonMethodTypeAnnotation;
5353
extern VALUE RBS_AST_Ruby_Annotations_MethodTypesAnnotation;
5454
extern VALUE RBS_AST_Ruby_Annotations_NodeTypeAssertion;
55+
extern VALUE RBS_AST_Ruby_Annotations_SkipAnnotation;
5556
extern VALUE RBS_AST_TypeParam;
5657
extern VALUE RBS_MethodType;
5758
extern VALUE RBS_Namespace;

include/rbs/ruby_objs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ VALUE rbs_ast_members_public(VALUE location);
4242
VALUE rbs_ast_ruby_annotations_colon_method_type_annotation(VALUE location, VALUE prefix_location, VALUE annotations, VALUE method_type);
4343
VALUE rbs_ast_ruby_annotations_method_types_annotation(VALUE location, VALUE prefix_location, VALUE overloads, VALUE vertical_bar_locations);
4444
VALUE rbs_ast_ruby_annotations_node_type_assertion(VALUE location, VALUE prefix_location, VALUE type);
45+
VALUE rbs_ast_ruby_annotations_skip_annotation(VALUE location, VALUE prefix_location, VALUE skip_location, VALUE comment_location);
4546
VALUE rbs_ast_type_param(VALUE name, VALUE variance, VALUE upper_bound, VALUE default_type, VALUE unchecked, VALUE location);
4647
VALUE rbs_method_type(VALUE type_params, VALUE type, VALUE block, VALUE location);
4748
VALUE rbs_namespace(VALUE path, VALUE absolute);

lib/rbs/ast/ruby/annotations.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,16 @@ def map_type_name(&block)
7474
self.class.new(location:, prefix_location:, overloads: ovs, vertical_bar_locations:) #: self
7575
end
7676
end
77+
78+
class SkipAnnotation < Base
79+
attr_reader :skip_location, :comment_location
80+
81+
def initialize(location:, prefix_location:, skip_location:, comment_location:)
82+
super(location, prefix_location)
83+
@skip_location = skip_location
84+
@comment_location = comment_location
85+
end
86+
end
7787
end
7888
end
7989
end

sig/ast/ruby/annotations.rbs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ module RBS
44
module Annotations
55
type leading_annotation = ColonMethodTypeAnnotation
66
| MethodTypesAnnotation
7+
| SkipAnnotation
78

89
type trailing_annotation = NodeTypeAssertion
910

@@ -63,6 +64,15 @@ module RBS
6364

6465
def map_type_name: () { (TypeName) -> TypeName } -> self
6566
end
67+
68+
# `@rbs skip -- comment` annotation in leading comments
69+
#
70+
class SkipAnnotation < Base
71+
attr_reader skip_location: Location
72+
attr_reader comment_location: Location?
73+
74+
def initialize: (location: Location, prefix_location: Location, skip_location: Location, comment_location: Location?) -> void
75+
end
6676
end
6777
end
6878
end

src/constants.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ VALUE RBS_AST_Members_Public;
5252
VALUE RBS_AST_Ruby_Annotations_ColonMethodTypeAnnotation;
5353
VALUE RBS_AST_Ruby_Annotations_MethodTypesAnnotation;
5454
VALUE RBS_AST_Ruby_Annotations_NodeTypeAssertion;
55+
VALUE RBS_AST_Ruby_Annotations_SkipAnnotation;
5556
VALUE RBS_AST_TypeParam;
5657
VALUE RBS_MethodType;
5758
VALUE RBS_Namespace;
@@ -131,6 +132,7 @@ void rbs__init_constants(void) {
131132
IMPORT_CONSTANT(RBS_AST_Ruby_Annotations_ColonMethodTypeAnnotation, RBS_AST_Ruby_Annotations, "ColonMethodTypeAnnotation");
132133
IMPORT_CONSTANT(RBS_AST_Ruby_Annotations_MethodTypesAnnotation, RBS_AST_Ruby_Annotations, "MethodTypesAnnotation");
133134
IMPORT_CONSTANT(RBS_AST_Ruby_Annotations_NodeTypeAssertion, RBS_AST_Ruby_Annotations, "NodeTypeAssertion");
135+
IMPORT_CONSTANT(RBS_AST_Ruby_Annotations_SkipAnnotation, RBS_AST_Ruby_Annotations, "SkipAnnotation");
134136
IMPORT_CONSTANT(RBS_AST_TypeParam, RBS_AST, "TypeParam");
135137
IMPORT_CONSTANT(RBS_MethodType, RBS, "MethodType");
136138
IMPORT_CONSTANT(RBS_Namespace, RBS, "Namespace");

src/ruby_objs.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,20 @@ VALUE rbs_ast_ruby_annotations_node_type_assertion(VALUE location, VALUE prefix_
480480
);
481481
}
482482

483+
VALUE rbs_ast_ruby_annotations_skip_annotation(VALUE location, VALUE prefix_location, VALUE skip_location, VALUE comment_location) {
484+
VALUE _init_kwargs = rb_hash_new();
485+
rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location);
486+
rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("prefix_location")), prefix_location);
487+
rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("skip_location")), skip_location);
488+
rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("comment_location")), comment_location);
489+
490+
return CLASS_NEW_INSTANCE(
491+
RBS_AST_Ruby_Annotations_SkipAnnotation,
492+
1,
493+
&_init_kwargs
494+
);
495+
}
496+
483497
VALUE rbs_ast_type_param(VALUE name, VALUE variance, VALUE upper_bound, VALUE default_type, VALUE unchecked, VALUE location) {
484498
VALUE _init_kwargs = rb_hash_new();
485499
rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("name")), name);

0 commit comments

Comments
 (0)