class Rufo::Formatter
def visit_exps(exps, with_indent: false, with_lines: true, want_trailing_multiline: false)
def visit_exps(exps, with_indent: false, with_lines: true, want_trailing_multiline: false) consume_end_of_line(at_prefix: true) line_before_endline = nil exps.each_with_index do |exp, i| next if exp == :string_content exp_kind = exp[0] # Skip voids to avoid extra indentation if exp_kind == :void_stmt next end if with_indent # Don't indent if this exp is in the same line as the previous # one (this happens when there's a semicolon between the exps) unless line_before_endline && line_before_endline == @line write_indent end end line_before_exp = @line original_line = current_token_line push_node(exp) do visit exp end if declaration?(exp) && @line == line_before_exp @inline_declarations << [@line, original_line] end is_last = last?(i, exps) line_before_endline = @line if with_lines exp_needs_two_lines = needs_two_lines?(exp) consume_end_of_line(want_semicolon: !is_last, want_multiline: !is_last || want_trailing_multiline, needs_two_lines_on_comment: exp_needs_two_lines) # Make sure to put two lines before defs, class and others if !is_last && (exp_needs_two_lines || needs_two_lines?(exps[i + 1])) && @line <= line_before_endline + 1 write_line end elsif !is_last skip_space has_semicolon = semicolon? skip_semicolons if newline? write_line write_indent(next_indent) elsif has_semicolon write "; " end skip_space_or_newline end end end