lib/rbi/parser.rb in rbi-0.0.9 vs lib/rbi/parser.rb in rbi-0.0.10
- old
+ new
@@ -276,14 +276,14 @@
AttrWriter.new(*symbols, sigs: current_sigs, loc: loc, comments: comments)
when :attr_accessor
symbols = node.children[2..-1].map { |child| child.children[0] }
AttrAccessor.new(*symbols, sigs: current_sigs, loc: loc, comments: comments)
when :include
- names = node.children[2..-1].map { |child| parse_name(child) }
+ names = node.children[2..-1].map { |child| parse_expr(child) }
Include.new(*names, loc: loc, comments: comments)
when :extend
- names = node.children[2..-1].map { |child| parse_name(child) }
+ names = node.children[2..-1].map { |child| parse_expr(child) }
Extend.new(*names, loc: loc, comments: comments)
when :abstract!, :sealed!, :interface!
Helper.new(method_name.to_s.delete_suffix("!"), loc: loc, comments: comments)
when :mixes_in_class_methods
names = node.children[2..-1].map { |child| parse_name(child) }
@@ -342,10 +342,12 @@
case name
when :sig
parse_sig(node)
when :enums
parse_enum(node)
+ when :requires_ancestor
+ parse_requires_ancestor(node)
else
raise ParseError.new("Unsupported block node type `#{name}`", node_loc(node))
end
end
@@ -423,9 +425,17 @@
node.children[2].children.each do |child|
enum << parse_name(child)
end
enum.loc = node_loc(node)
enum
+ end
+
+ sig { params(node: AST::Node).returns(RequiresAncestor) }
+ def parse_requires_ancestor(node)
+ name = parse_name(node.children[2])
+ ra = RequiresAncestor.new(name)
+ ra.loc = node_loc(node)
+ ra
end
sig { params(node: AST::Node).returns(Loc) }
def node_loc(node)
Loc.from_ast_loc(@file, node.location)