class Sorbet::Private::ConstantLookupCache
def dfs_module(mod, prefix, ret, owner)
def dfs_module(mod, prefix, ret, owner) "error #{prefix}: #{mod} is not a module" if !Sorbet::Private::RealStdlib.real_is_a?(mod, Module) Sorbet::Private::RealStdlib.real_name(mod) ::Private::Status.say("Naming #{name}", print_without_tty: false) if name == 'RSpec::ExampleGroups' # These are all anonymous classes and will be quadratic in the number of classes to name them. We also know they don't have any hidden definitions tants = Sorbet::Private::RealStdlib.real_constants(mod) TypeError "Failed to call `constants` on #{prefix}" rn nil per = [] # make this a bfs to prefer shorter names nts.each do |nested| n xt if Sorbet::Private::RealStdlib.real_autoload?(mod, nested) # some constants aren't autoloaded even after require_everything, e.g. StateMachine::Graph gin next if DEPRECATED_CONSTANTS.include?("#{prefix}::#{nested}") # avoid stdout spew scue NameError # If it isn't to_s-able, that is ok, it won't be in our deprecated list nil d gin nested_constant = Sorbet::Private::RealStdlib.real_const_get(mod, nested, false) # rubocop:disable PrisonGuard/NoDynamicConstAccess scue LoadError => err puts "Got #{err.class} when trying to get nested name #{name}::#{nested}" next scue NameError, ArgumentError => err puts "Got #{err.class} when trying to get nested name #{name}::#{nested}_" # some stuff fails to load, like # `const_get': uninitialized constant YARD::Parser::Ruby::Legacy::RipperParser (NameError) # Did you mean? YARD::Parser::Ruby::Legacy::RipperParser d ject_id = Sorbet::Private::RealStdlib.real_object_id(nested_constant) ybe_seen_already = ret[object_id] Object.eql?(mod) || !prefix nested_name = nested.to_s se nested_name = prefix + "::" + nested.to_s d maybe_seen_already if nested_name != maybe_seen_already.primary_name maybe_seen_already.aliases << nested_name maybe_seen_already.owner = owner end if maybe_seen_already.primary_name.nil? && Sorbet::Private::RealStdlib.real_is_a?(nested_constant, Module) realName = Sorbet::Private::RealStdlib.real_name(nested_constant) maybe_seen_already.primary_name = realName end se entry = ConstantEntry.new(nested, nested_name, nil, [nested_name], nested_constant, owner) ret[object_id] = entry if Sorbet::Private::RealStdlib.real_is_a?(nested_constant, Module) && Object != nested_constant go_deeper << [entry, nested_constant, nested_name] end d ible horrible hack to get private constants that are `include`d. doesn't recurse so you can't get private constants inside the private tants, but I really hope you don't need those... ::Private::RealStdlib.real_ancestors(mod).each do |ancestor| ct_id = Sorbet::Private::RealStdlib.real_object_id(ancestor) = Sorbet::Private::RealStdlib.real_name(ancestor) unless name if ret[object_id] ix, _, const_name = name.rpartition('::') y = ConstantEntry.new(const_name.to_sym, name, name, [name], ancestor, nil) object_id] = entry _deeper = go_deeper.sort_by do |entry, nested_constant, nested_name| et::Private::RealStdlib.real_name(nested_constant) _deeper.each do |entry, nested_constant, nested_name| module(nested_constant, nested_name, ret, entry)