lib/rbs/environment_walker.rb in rbs-0.4.0 vs lib/rbs/environment_walker.rb in rbs-0.5.0
- old
+ new
@@ -21,17 +21,13 @@
end
include TSort
def tsort_each_node(&block)
- env.each_decl do |name|
- yield name.absolute!
- end
-
- env.each_alias do |name, _|
- yield name.absolute!
- end
+ env.class_decls.each_key(&block)
+ env.interface_decls.each_key(&block)
+ env.alias_decls.each_key(&block)
end
def tsort_each_child(name, &block)
unless name.namespace.empty?
yield name.namespace.to_type_name
@@ -44,34 +40,29 @@
case
when name.class?
definitions << builder.build_instance(name)
definitions << builder.build_singleton(name)
when name.interface?
- definitions << builder.build_interface(name, env.find_class(name))
+ definitions << builder.build_interface(name)
end
definitions.each do |definition|
- definition.ancestors.each do |ancestor|
- yield ancestor.name
+ if ancestors = definition.ancestors
+ ancestors.ancestors.each do |ancestor|
+ yield ancestor.name
- case ancestor
- when Definition::Ancestor::Instance, Definition::Ancestor::ExtensionInstance
- ancestor.args.each do |type|
- each_type_name type, &block
+ case ancestor
+ when Definition::Ancestor::Instance
+ ancestor.args.each do |type|
+ each_type_name type, &block
+ end
end
end
end
unless only_ancestors?
- definition.methods.each do |_, method|
- method.method_types.each do |method_type|
- method_type.type.each_type do |type|
- each_type_name type, &block
- end
- method_type.block&.type&.each_type do |type|
- each_type_name type, &block
- end
- end
+ definition.each_type do |type|
+ each_type_name type, &block
end
end
end
when name.alias?
each_type_name builder.expand_alias(name), &block