module Dry::Schema::Extensions::Hints::MessageCompilerMethods

def exclude?(messages, opts)

Other tags:
    Api: - private
def exclude?(messages, opts)
  Array(messages).all? do |msg|
    hints = opts
      .hints
      .reject { |hint| msg == hint }
      .reject { |hint| hint.predicate == :filled? }
    key_failure = opts.key_failure?(msg.path)
    predicate = msg.predicate
    (HINT_TYPE_EXCLUSION.include?(predicate) && !key_failure) ||
      (msg.predicate == :filled? && key_failure) ||
      (!key_failure && HINT_TYPE_EXCLUSION.include?(predicate) &&
        !hints.empty? && hints.any? { |hint| hint.path == msg.path }) ||
      HINT_OTHER_EXCLUSION.include?(predicate)
  end
end

def filter(messages, opts)

Other tags:
    Api: - private
def filter(messages, opts)
  Array(messages).flatten.map { |msg| msg unless exclude?(msg, opts) }.compact.uniq
end

def hints?

Other tags:
    Api: - private
def hints?
  hints.equal?(true)
end

def initialize(*args)

Other tags:
    Api: - private
def initialize(*args)
  super
  @hints = @options.fetch(:hints, true)
end

def message_type(options)

Other tags:
    Api: - private
def message_type(options)
  options[:message_type].equal?(:hint) ? Hint : Message
end

def visit_each(node, opts)

Other tags:
    Api: - private
def visit_each(node, opts)
  # TODO: we can still generate a hint for elements here!
  []
end

def visit_hint(node, opts)

Other tags:
    Api: - private
def visit_hint(node, opts)
  if hints?
    filter(visit(node, opts.(message_type: :hint)), opts)
  end
end

def visit_predicate(node, opts)

Other tags:
    Api: - private
def visit_predicate(node, opts)
  message = super
  opts.current_messages << message
  message
end