class Rufo::Formatter
def visit_exps(exps, with_indent = false, with_lines = true)
def visit_exps(exps, with_indent = false, with_lines = true) consume_end_of_line(true) line_before_endline = nil exps.each_with_index do |exp, i| 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 push_node(exp) do visit exp end skip_space line_before_endline = @line is_last = last?(i, exps) if with_lines exp_needs_two_lines = needs_two_lines?(exp) consume_end_of_line(false, !is_last, !is_last, 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 else skip_space_or_newline unless is_last end end end