class Rufo::Formatter

def visit_params(node)

def visit_params(node)
  # (def params)
  #
  # [:params, pre_rest_params, args_with_default, rest_param, post_rest_params, label_params, double_star_param, blockarg]
  _, pre_rest_params, args_with_default, rest_param, post_rest_params, label_params, double_star_param, blockarg = node
  needs_comma = false
  if pre_rest_params
    visit_comma_separated_list pre_rest_params
    needs_comma = true
  end
  if args_with_default
    write_params_comma if needs_comma
    visit_comma_separated_list(args_with_default) do |arg, default|
      visit arg
      consume_space
      consume_op "="
      consume_space
      visit default
    end
    needs_comma = true
  end
  if rest_param
    # check for trailing , |x, | (may be [:excessed_comma] in 2.6.0)
    case rest_param
    when 0, [:excessed_comma]
      write_params_comma
    when [:args_forward]
      consume_op "..."
    else
      # [:rest_param, [:@ident, "x", [1, 15]]]
      _, rest = rest_param
      write_params_comma if needs_comma
      consume_op "*"
      skip_space_or_newline
      visit rest if rest
      needs_comma = true
    end
  end
  if post_rest_params
    write_params_comma if needs_comma
    visit_comma_separated_list post_rest_params
    needs_comma = true
  end
  if label_params
    # [[label, value], ...]
    write_params_comma if needs_comma
    visit_comma_separated_list(label_params) do |label, value|
      # [:@label, "b:", [1, 20]]
      write label[1]
      next_token
      skip_space_or_newline
      if value
        consume_space
        visit value
      end
    end
    needs_comma = true
  end
  if double_star_param
    write_params_comma if needs_comma
    consume_op "**"
    skip_space_or_newline
    # A nameless double star comes as an... Integer? :-S
    visit double_star_param if double_star_param.is_a?(Array)
    skip_space_or_newline
    needs_comma = true
  end
  if blockarg
    # [:blockarg, [:@ident, "block", [1, 16]]]
    write_params_comma if needs_comma
    skip_space_or_newline
    consume_op "&"
    skip_space_or_newline
    visit blockarg[1]
  end
end