class Rufo::Formatter
def visit_when(node)
def visit_when(node) # [:when, conds, body, next_exp] _, conds, body, next_exp = node preserve_whitespace = @preserve_whitespace && !@align_case_when consume_keyword "when" consume_space(want_preserve_whitespace: preserve_whitespace) space_after_when = nil indent(@column) do visit_comma_separated_list conds space_after_when = current_token if space? && preserve_whitespace skip_space end then_keyword = keyword?("then") inline = then_keyword || semicolon? if then_keyword next_token space_after_then = current_token if space? && preserve_whitespace skip_space track_case_when skip_semicolons if newline? || comment? inline = false # Cancel tracking of `case when ... then` on a nelwine. @case_when_positions.pop else if space_after_when write_space space_after_when[2] else write_space end write "then" if space_after_then write_space space_after_then[2] else write_space end end elsif semicolon? skip_semicolons if newline? || comment? inline = false else write ";" track_case_when write " " end end if inline indent do visit_exps body end else indent_body body end if next_exp write_indent if next_exp[0] == :else # [:else, body] consume_keyword "else" skip_space if newline? || semicolon? || comment? indent_body next_exp[1] else write_space visit_exps next_exp[1] end else visit next_exp end end end