class RBS::Environment::UseMap
Attributes
Public Class Methods
Source
# File bundled-src/rbs-3.10.0/lib/rbs/environment/use_map.rb, line 30 def initialize(table:) @use_dirs = [] @map = {} @table = table end
Public Instance Methods
Source
# File bundled-src/rbs-3.10.0/lib/rbs/environment/use_map.rb, line 36 def build_map(clause) case clause when AST::Directives::Use::SingleClause if clause.new_name @map[clause.new_name] = clause.type_name.absolute! else @map[clause.type_name.name] = clause.type_name.absolute! end when AST::Directives::Use::WildcardClause @table.children.fetch(clause.namespace.absolute!).each do |child| @map[child.name] = child end end self end
Source
# File bundled-src/rbs-3.10.0/lib/rbs/environment/use_map.rb, line 72 def resolve(type_name) resolve?(type_name) || type_name end
Source
# File bundled-src/rbs-3.10.0/lib/rbs/environment/use_map.rb, line 53 def resolve?(type_name) return if type_name.absolute? hd, *tl = type_name.namespace.path if hd # namespace is not empty if tn = @map[hd] path = [*tn.namespace.path, tn.name, *tl] TypeName.new( namespace: Namespace.new(absolute: true, path: path), name: type_name.name ) end else @map[type_name.name] end end