Skip to content

Commit fe32f21

Browse files
committed
Add ParamTypeAnnotation
1 parent f032275 commit fe32f21

2 files changed

Lines changed: 45 additions & 0 deletions

File tree

lib/rbs/ast/ruby/annotations.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,29 @@ def map_type_name(&block)
113113
) #: self
114114
end
115115
end
116+
117+
class ParamTypeAnnotation < Base
118+
attr_reader :name_location, :colon_location, :param_type, :comment_location
119+
120+
def initialize(location:, prefix_location:, name_location:, colon_location:, param_type:, comment_location:)
121+
super(location, prefix_location)
122+
@name_location = name_location
123+
@colon_location = colon_location
124+
@param_type = param_type
125+
@comment_location = comment_location
126+
end
127+
128+
def map_type_name(&block)
129+
self.class.new(
130+
location:,
131+
prefix_location:,
132+
name_location: name_location,
133+
colon_location: colon_location,
134+
param_type: param_type.map_type_name { yield _1 },
135+
comment_location: comment_location
136+
) #: self
137+
end
138+
end
116139
end
117140
end
118141
end

sig/ast/ruby/annotations.rbs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ module RBS
66
| MethodTypesAnnotation
77
| SkipAnnotation
88
| ReturnTypeAnnotation
9+
| ParamTypeAnnotation
910

1011
type trailing_annotation = NodeTypeAssertion
1112

@@ -104,6 +105,27 @@ module RBS
104105

105106
def map_type_name: () { (TypeName) -> TypeName } -> self
106107
end
108+
109+
class ParamTypeAnnotation < Base
110+
attr_reader name_location: Location
111+
112+
attr_reader colon_location: Location
113+
114+
attr_reader param_type: Types::t
115+
116+
attr_reader comment_location: Location?
117+
118+
def initialize: (
119+
location: Location,
120+
prefix_location: Location,
121+
name_location: Location,
122+
colon_location: Location,
123+
param_type: Types::t,
124+
comment_location: Location?,
125+
) -> void
126+
127+
def map_type_name: () { (TypeName) -> TypeName } -> self
128+
end
107129
end
108130
end
109131
end

0 commit comments

Comments
 (0)