class Pry::InputCompleter
def ignored_modules
def ignored_modules # We could cache the result, but IRB is not loaded by default. # And this is very fast anyway. # By using this approach, we avoid Module#name calls, which are # relatively slow when there are a lot of anonymous modules defined. s = Set.new scanner = lambda do |m| next if s.include?(m) # IRB::ExtendCommandBundle::EXCB recurses. s << m m.constants(false).each do |c| value = m.const_get(c) scanner.call(value) if value.is_a?(Module) end end # FIXME: Add Pry here as well? %i[IRB SLex RubyLex RubyToken].each do |module_name| next unless Object.const_defined?(module_name) scanner.call(Object.const_get(module_name)) end s.delete(IRB::Context) if defined?(IRB::Context) s end