Class: RBS::Resolver::TypeNameResolver
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/rbs/resolver/type_name_resolver.rb |
Class Method Summary
- .new(env) ⇒ TypeNameResolver constructor
Instance Attribute Summary
- #all_names readonly
- #cache readonly
Instance Method Summary
Constructor Details
.new(env) ⇒ TypeNameResolver
Instance Attribute Details
#all_names (readonly)
[ GitHub ]# File 'lib/rbs/resolver/type_name_resolver.rb', line 6
attr_reader :all_names
#cache (readonly)
[ GitHub ]# File 'lib/rbs/resolver/type_name_resolver.rb', line 7
attr_reader :cache
Instance Method Details
#has_name?(full_name) ⇒ Boolean
# File 'lib/rbs/resolver/type_name_resolver.rb', line 50
def has_name?(full_name) if all_names.include?(full_name) full_name end end
#resolve(type_name, context:)
[ GitHub ]# File 'lib/rbs/resolver/type_name_resolver.rb', line 25
def resolve(type_name, context:) if type_name.absolute? return type_name end try_cache([type_name, context]) do resolve_in(type_name, context) end end
#resolve_in(type_name, context)
[ GitHub ]# File 'lib/rbs/resolver/type_name_resolver.rb', line 35
def resolve_in(type_name, context) if context parent, child = context case child when false resolve_in(type_name, parent) when TypeName name = type_name.with_prefix(child.to_namespace) has_name?(name) || resolve_in(type_name, parent) end else has_name?(type_name.absolute!) end end