class Rufo::Formatter
def visit_lambda(node)
def visit_lambda(node) # [:lambda, [:params, nil, nil, nil, nil, nil, nil, nil], [[:void_stmt]]] _, params, body = node check :on_tlambda write "->" next_token if space? && @spaces_after_lambda_arrow == :dynamic consume_space(want_preserve_whitespace: true) elsif @spaces_after_lambda_arrow == :one skip_space write_space else skip_space_or_newline end if empty_params?(params) if current_token_kind == :on_lparen next_token skip_space_or_newline check :on_rparen next_token skip_space_or_newline end else visit params consume_space end if void_exps?(body) consume_token :on_tlambeg consume_space consume_token :on_rbrace return end brace = current_token_value == "{" if brace closing_brace_token, index = find_closing_brace_token # Check if the whole block fits into a single line if current_token_line == closing_brace_token[0][0] consume_token :on_tlambeg consume_space unless !space? && @spaces_around_block_brace == :dynamic visit_exps body, with_lines: false consume_space unless !space? && @spaces_around_block_brace == :dynamic consume_token :on_rbrace return end consume_token :on_tlambeg else consume_keyword "do" end indent_body body, force_multiline: true write_indent if brace consume_token :on_rbrace else consume_keyword "end" end end