class IRB::BaseCompletor

:nodoc:

def completion_candidates(preposing, target, postposing, bind:)

:nodoc:
def completion_candidates(preposing, target, postposing, bind:)
  raise NotImplementedError
end

def doc_namespace(preposing, matched, postposing, bind:)

def doc_namespace(preposing, matched, postposing, bind:)
  raise NotImplementedError
end

def retrieve_files_to_require_from_load_path

def retrieve_files_to_require_from_load_path
  @files_from_load_path ||=
    (
      shortest = []
      rest = retrieve_gem_and_system_load_path.each_with_object([]) { |path, result|
        begin
          names = Dir.glob("**/*.{rb,#{RbConfig::CONFIG['DLEXT']}}", base: path)
        rescue Errno::ENOENT
          nil
        end
        next if names.empty?
        names.map! { |n| n.sub(/\.(rb|#{RbConfig::CONFIG['DLEXT']})\z/, '') }.sort!
        shortest << names.shift
        result.concat(names)
      }
      shortest.sort! | rest
    )
end

def retrieve_files_to_require_relative_from_current_dir

def retrieve_files_to_require_relative_from_current_dir
  @files_from_current_dir ||= Dir.glob("**/*.{rb,#{RbConfig::CONFIG['DLEXT']}}", base: '.').map { |path|
    path.sub(/\.(rb|#{RbConfig::CONFIG['DLEXT']})\z/, '')
  }
end

def retrieve_gem_and_system_load_path

def retrieve_gem_and_system_load_path
  candidates = (GEM_PATHS | $LOAD_PATH)
  candidates.map do |p|
    if p.respond_to?(:to_path)
      p.to_path
    else
      String(p) rescue nil
    end
  end.compact.sort
end