class Rufo::Formatter
def visit_literal_elements(elements, inside_hash = false)
def visit_literal_elements(elements, inside_hash = false) base_column = @column needs_final_space = inside_hash && space? skip_space if newline? || comment? needs_final_space = false elsif needs_final_space consume_space base_column = @column end # 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 if needs_final_space consume_space else skip_space_or_newline end end end