module RBS
  class TypeNameResolver
    type context = Array[Namespace]

    class Query
      attr_reader type_name: TypeName
      attr_reader context: Array[Namespace]

      def initialize: (type_name: TypeName, context: context) -> void
    end

    attr_reader all_names: Set[TypeName]

    attr_reader cache: Hash[Query, TypeName?]

    def self.from_env: (Environment) -> TypeNameResolver

    def add_names: (Array[TypeName]) -> self

    def resolve: (TypeName, context: context) -> TypeName?

    def has_name?: (TypeName) -> TypeName?

    def try_cache: (Query) { () -> TypeName? } -> TypeName?
  end
end
