class Rufo::Formatter

def visit_literal_elements(elements)

def visit_literal_elements(elements)
  base_column = @column
  skip_space
  # If there's a newline right at the beginning,
  # write it, and we'll indent element and always
  # add a trailing comma to the last element
  needs_trailing_comma = newline? || comment?
  if needs_trailing_comma
    needed_indent = next_indent
    indent { consume_end_of_line }
    write_indent(needed_indent)
  else
    needed_indent = base_column
  end
  elements.each_with_index do |elem, i|
    if needs_trailing_comma
      indent(needed_indent) { visit elem }
    else
      visit elem
    end
    skip_space
    if comma?
      is_last = last?(i, elements)
      write "," unless is_last
      next_token
      skip_space
      if newline? || comment?
        if is_last
          # Nothing
        else
          consume_end_of_line
          write_indent(needed_indent)
        end
      else
        write_space " " unless is_last
      end
    end
  end
  if needs_trailing_comma
    write ","
    consume_end_of_line
    write_indent
  elsif comment?
    consume_end_of_line
  else
    skip_space_or_newline
  end
end