lib/rbs/environment_walker.rb in rbs-0.18.0 vs lib/rbs/environment_walker.rb in rbs-0.18.1
- old
+ new
@@ -51,15 +51,15 @@
case
when name.interface?
definition = builder.build_interface(name)
unless only_ancestors?
definition.each_type do |type|
- each_type_name type, &block
+ each_type_node type, &block
end
end
when name.alias?
- each_type_name builder.expand_alias(name), &block
+ each_type_node builder.expand_alias(name), &block
else
raise "Unexpected TypeNameNode with type_name=#{name}"
end
when InstanceNode, SingletonNode
@@ -75,28 +75,34 @@
when Definition::Ancestor::Instance
yield InstanceNode.new(type_name: ancestor.name)
unless only_ancestors?
ancestor.args.each do |type|
- each_type_name type, &block
+ each_type_node type, &block
end
end
when Definition::Ancestor::Singleton
yield SingletonNode.new(type_name: ancestor.name)
end
end
end
unless only_ancestors?
definition.each_type do |type|
- each_type_name type, &block
+ each_type_node type, &block
end
end
end
end
def each_type_name(type, &block)
+ each_type_node(type) do |node|
+ yield node.type_name
+ end
+ end
+
+ def each_type_node(type, &block)
case type
when RBS::Types::Bases::Any
when RBS::Types::Bases::Class
when RBS::Types::Bases::Instance
when RBS::Types::Bases::Self
@@ -109,33 +115,33 @@
when RBS::Types::ClassSingleton
yield SingletonNode.new(type_name: type.name)
when RBS::Types::ClassInstance
yield InstanceNode.new(type_name: type.name)
type.args.each do |ty|
- each_type_name(ty, &block)
+ each_type_node(ty, &block)
end
when RBS::Types::Interface
yield TypeNameNode.new(type_name: type.name)
type.args.each do |ty|
- each_type_name(ty, &block)
+ each_type_node(ty, &block)
end
when RBS::Types::Alias
yield TypeNameNode.new(type_name: type.name)
when RBS::Types::Union, RBS::Types::Intersection, RBS::Types::Tuple
type.types.each do |ty|
- each_type_name ty, &block
+ each_type_node ty, &block
end
when RBS::Types::Optional
- each_type_name type.type, &block
+ each_type_node type.type, &block
when RBS::Types::Literal
# nop
when RBS::Types::Record
type.fields.each_value do |ty|
- each_type_name ty, &block
+ each_type_node ty, &block
end
when RBS::Types::Proc
type.each_type do |ty|
- each_type_name ty, &block
+ each_type_node ty, &block
end
else
raise "Unexpected type given: #{type}"
end
end