lib/steep/ast/signature/env.rb in steep-0.4.0 vs lib/steep/ast/signature/env.rb in steep-0.5.0

- old
+ new

@@ -6,18 +6,20 @@ attr_reader :classes attr_reader :extensions attr_reader :interfaces attr_reader :constants attr_reader :globals + attr_reader :aliases def initialize() @modules = {} @classes = {} @extensions = {} @interfaces = {} @constants = {} @globals = {} + @aliases = {} end def add(sig) case sig when Signature::Class @@ -38,10 +40,13 @@ when Signature::Const constants[sig.name.absolute!] = sig when Signature::Gvar raise "Duplicated global: #{sig.name}" if globals.key?(sig.name) globals[sig.name] = sig + when Signature::Alias + raise "Duplicated alias: #{sig.name}" if aliases.key?(sig.name) + aliases[sig.name] = sig else raise "Unknown signature:: #{sig}" end end @@ -69,9 +74,13 @@ find_name(constants, name, current_module: current_module) end def find_gvar(name) globals[name] + end + + def find_alias(name) + aliases[name] end def find_name(hash, name, current_module:) if current_module hash[current_module + name] || find_name(hash, name, current_module: current_module.parent)