class SyntaxTree::CommandCall

Experimental RBS support (using type sampling data from the type_fusion project).

# sig/syntax_tree/node.rbs

class SyntaxTree::CommandCall < SyntaxTree::Node
  def accept: (Visitor visitor) -> untyped
end


object.method argument
parentheses.
CommandCall represents a method call on an object with arguments and no

def ===(other)

def ===(other)
  other.is_a?(CommandCall) && receiver === other.receiver &&
    operator === other.operator && message === other.message &&
    arguments === other.arguments && block === other.block
end

def accept(visitor)

Experimental RBS support (using type sampling data from the type_fusion project).

def accept: (Visitor visitor) -> untyped

This signature was generated using 1 sample from 1 application.

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

def argument_alignment(q, doc)

def argument_alignment(q, doc)
  # Very special handling case for rspec matchers. In general with rspec
  # matchers you expect to see something like:
  #
  #     expect(foo).to receive(:bar).with(
  #       'one',
  #       'two',
  #       'three',
  #       'four',
  #       'five'
  #     )
  #
  # In this case the arguments are aligned to the left side as opposed to
  # being aligned with the `receive` call.
  if %w[to not_to to_not].include?(message.value)
    0
  else
    width = q.last_position(doc) + 1
    width > (q.maxwidth / 2) ? 0 : width
  end
end

def arity

def arity
  arguments&.arity || 0
end

def child_nodes

def child_nodes
  [receiver, message, arguments, block]
end

def copy(

def copy(
  receiver: nil,
  operator: nil,
  message: nil,
  arguments: nil,
  block: nil,
  location: nil
)
  node =
    CommandCall.new(
      receiver: receiver || self.receiver,
      operator: operator || self.operator,
      message: message || self.message,
      arguments: arguments || self.arguments,
      block: block || self.block,
      location: location || self.location
    )
  node.comments.concat(comments.map(&:copy))
  node
end

def deconstruct_keys(_keys)

def deconstruct_keys(_keys)
  {
    receiver: receiver,
    operator: operator,
    message: message,
    arguments: arguments,
    block: block,
    location: location,
    comments: comments
  }
end

def format(q)

def format(q)
  message = self.message
  arguments = self.arguments
  block = self.block
  q.group do
    doc =
      q.nest(0) do
        q.format(receiver)
        # If there are leading comments on the message then we know we have
        # a newline in the source that is forcing these things apart. In
        # this case we will have to use a trailing operator.
        if message != :call && message.comments.any?(&:leading?)
          q.format(CallOperatorFormatter.new(operator), stackable: false)
          q.indent do
            q.breakable_empty
            q.format(message)
          end
        else
          q.format(CallOperatorFormatter.new(operator), stackable: false)
          q.format(message)
        end
      end
    # Format the arguments for this command call here. If there are no
    # arguments, then print nothing.
    if arguments
      parts = arguments.parts
      if parts.length == 1 && parts.first.is_a?(IfOp)
        q.if_flat { q.text(" ") }
        q.format(arguments)
      else
        q.text(" ")
        q.nest(argument_alignment(q, doc)) { q.format(arguments) }
      end
    end
  end
  q.format(block) if block
end

def initialize(

def initialize(
  receiver:,
  operator:,
  message:,
  arguments:,
  block:,
  location:
)
  @receiver = receiver
  @operator = operator
  @message = message
  @arguments = arguments
  @block = block
  @location = location
  @comments = []
end