class RubyIndexer::Collector

def add_constant(node, name, value = nil)

def add_constant(node, name, value = nil)
  value = node.value unless node.is_a?(Prism::ConstantTargetNode) || node.is_a?(Prism::ConstantPathTargetNode)
  comments = collect_comments(node)
  @index << case value
  when Prism::ConstantReadNode, Prism::ConstantPathNode
    Entry::UnresolvedAlias.new(value.slice, @stack.dup, name, @file_path, node.location, comments)
  when Prism::ConstantWriteNode, Prism::ConstantAndWriteNode, Prism::ConstantOrWriteNode,
    Prism::ConstantOperatorWriteNode
    # If the right hand side is another constant assignment, we need to visit it because that constant has to be
    # indexed too
    @queue.prepend(value)
    Entry::UnresolvedAlias.new(value.name.to_s, @stack.dup, name, @file_path, node.location, comments)
  when Prism::ConstantPathWriteNode, Prism::ConstantPathOrWriteNode, Prism::ConstantPathOperatorWriteNode,
    Prism::ConstantPathAndWriteNode
    @queue.prepend(value)
    Entry::UnresolvedAlias.new(value.target.slice, @stack.dup, name, @file_path, node.location, comments)
  else
    Entry::Constant.new(name, @file_path, node.location, comments)
  end
end