class SyntaxTree::HashLiteral


{ key => value }
HashLiteral represents a hash literal.

def ===(other)

def ===(other)
  other.is_a?(HashLiteral) && lbrace === other.lbrace &&
    ArrayMatch.call(assocs, other.assocs)
end

def accept(visitor)

def accept(visitor)
  visitor.visit_hash(self)
end

def child_nodes

def child_nodes
  [lbrace].concat(assocs)
end

def copy(lbrace: nil, assocs: nil, location: nil)

def copy(lbrace: nil, assocs: nil, location: nil)
  node =
    HashLiteral.new(
      lbrace: lbrace || self.lbrace,
      assocs: assocs || self.assocs,
      location: location || self.location
    )
  node.comments.concat(comments.map(&:copy))
  node
end

def deconstruct_keys(_keys)

def deconstruct_keys(_keys)
  { lbrace: lbrace, assocs: assocs, location: location, comments: comments }
end

def empty_with_comments?

to do some special printing to ensure they get indented correctly.
If we have an empty hash that contains only comments, then we're going
def empty_with_comments?
  assocs.empty? && lbrace.comments.any? && lbrace.comments.none?(&:inline?)
end

def format(q)

def format(q)
  if q.parent.is_a?(Assoc)
    format_contents(q)
  else
    q.group { format_contents(q) }
  end
end

def format_contents(q)

def format_contents(q)
  if empty_with_comments?
    EmptyWithCommentsFormatter.new(lbrace).format(q)
    return
  end
  q.format(lbrace)
  if assocs.empty?
    q.breakable_empty
  else
    q.indent do
      q.breakable_space
      q.seplist(assocs) { |assoc| q.format(assoc) }
      q.if_break { q.text(",") } if q.trailing_comma?
    end
    q.breakable_space
  end
  q.text("}")
end

def format_key(q, key)

def format_key(q, key)
  (@key_formatter ||= HashKeyFormatter.for(self)).format_key(q, key)
end

def initialize(lbrace:, assocs:, location:)

def initialize(lbrace:, assocs:, location:)
  @lbrace = lbrace
  @assocs = assocs
  @location = location
  @comments = []
end