class Rufo::Formatter
def visit_brace_block(node)
def visit_brace_block(node) # [:brace_block, args, body] _, args, body = node # This is for the empty `{ }` block if void_exps?(body) consume_token :on_lbrace consume_block_args args consume_space consume_token :on_rbrace return end closing_brace_token, index = find_closing_brace_token # If the whole block fits into a single line, use braces if current_token_line == closing_brace_token[0][0] consume_token :on_lbrace consume_block_args args consume_space visit_exps body, with_lines: false while semicolon? next_token end consume_space consume_token :on_rbrace return end # Otherwise it's multiline consume_token :on_lbrace consume_block_args args if call_info = @line_to_call_info[@line] call_info << true end indent_body body, force_multiline: true write_indent # If the closing bracket matches the indent of the first parameter, # keep it like that. Otherwise dedent. if call_info && call_info[1] != current_token_column call_info << @line end consume_token :on_rbrace end