class SyntaxTree::When


end
when predicate
case value
When represents a when clause in a case chain.

def ===(other)

def ===(other)
  other.is_a?(When) && arguments === other.arguments &&
    statements === other.statements && consequent === other.consequent
end

def accept(visitor)

def accept(visitor)
  visitor.visit_when(self)
end

def child_nodes

def child_nodes
  [arguments, statements, consequent]
end

def copy(arguments: nil, statements: nil, consequent: nil, location: nil)

def copy(arguments: nil, statements: nil, consequent: nil, location: nil)
  node =
    When.new(
      arguments: arguments || self.arguments,
      statements: statements || self.statements,
      consequent: consequent || self.consequent,
      location: location || self.location
    )
  node.comments.concat(comments.map(&:copy))
  node
end

def deconstruct_keys(_keys)

def deconstruct_keys(_keys)
  {
    arguments: arguments,
    statements: statements,
    consequent: consequent,
    location: location,
    comments: comments
  }
end

def format(q)

def format(q)
  keyword = "when "
  q.group do
    q.group do
      q.text(keyword)
      q.nest(keyword.length) do
        if arguments.comments.any?
          q.format(arguments)
        else
          q.seplist(arguments.parts, SEPARATOR) { |part| q.format(part) }
        end
        # Very special case here. If you're inside of a when clause and the
        # last argument to the predicate is and endless range, then you are
        # forced to use the "then" keyword to make it parse properly.
        last = arguments.parts.last
        q.text(" then") if last.is_a?(RangeNode) && !last.right
      end
    end
    unless statements.empty?
      q.indent do
        q.breakable_force
        q.format(statements)
      end
    end
    if consequent
      q.breakable_force
      q.format(consequent)
    end
  end
end

def initialize(arguments:, statements:, consequent:, location:)

def initialize(arguments:, statements:, consequent:, location:)
  @arguments = arguments
  @statements = statements
  @consequent = consequent
  @location = location
  @comments = []
end