class Rufo::Formatter
def visit_array_pattern(node)
def visit_array_pattern(node) # [:aryptn, const_ref, pre_rest, rest, post_rest] _, const_ref, pre_rest, rest, post_rest = node if const_ref return visit_constant_pattern(node) end # pattern is [*] if !pre_rest && !post_rest && rest == [:var_field, nil] consume_token :on_lbracket skip_space_or_newline consume_op "*" skip_space_or_newline consume_token :on_rbracket return end token_column = current_token_column has_bracket = current_token_kind == :on_lbracket if has_bracket consume_token :on_lbracket skip_space end write_comma = false if pre_rest visit_literal_elements pre_rest, inside_array: true, token_column: token_column, keep_final_newline: !has_bracket write_comma = true end # pattern like `[a,]` will make `rest` as `[:var_field, nil]` if rest && ((var_name_node = rest[1]) || current_token_value == "*") if write_comma write "," consume_space else skip_space_or_newline end consume_op "*" if var_name_node visit rest end end if post_rest skip_space check :on_comma write "," consume_space next_token visit_literal_elements post_rest, inside_array: true, token_column: token_column, keep_final_newline: !has_bracket end skip_space if has_bracket consume_token :on_rbracket end end