class SyntaxTree::HashKeyFormatter::Labels

Formats the keys of a hash literal using labels.

def format_key(q, key)

def format_key(q, key)
  case key
  when Label
    q.format(key)
  when SymbolLiteral
    q.format(key.value)
    q.text(":")
  when DynaSymbol
    parts = key.parts
    if parts.length == 1 && (part = parts.first) &&
         part.is_a?(TStringContent) && part.value.match?(LABEL)
      q.format(part)
      q.text(":")
    else
      q.format(key)
      q.text(":")
    end
  end
end