class RuboCop::AST::NodePattern::Node

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

# sig/rubocop/ast/node_pattern/node.rbs

class RuboCop::AST::NodePattern::Node < Parser::AST::Node
  def arity: () -> Integer
  def arity_range: () -> Range
  def child: () -> Symbol
  def in_sequence_head: () -> nil
end

Base class for AST Nodes of a ‘NodePattern`

def arity

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

def arity: () -> Integer

This signature was generated using 5 samples from 1 application.

Returns:
  • (Integer, Range) - An Integer for fixed length terms, otherwise a Range.
def arity
  1
end

def arity_range

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

def arity_range: () -> Range

This signature was generated using 8 samples from 1 application.

Returns:
  • (Range) - arity as a Range
def arity_range
  a = arity
  a.is_a?(Range) ? a : INT_TO_RANGE[a]
end

def capture?

def capture?
  false
end

def child

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

def child: () -> Symbol

This signature was generated using 1 sample from 1 application.

Returns:
  • (Node) - most nodes have only one child
def child
  children[0]
end

def children_nodes

Returns:
  • (Array) -
def children_nodes
  children.grep(Node)
end

def in_sequence_head

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

def in_sequence_head: () -> nil

This signature was generated using 2 samples from 1 application.

Returns:
  • (Array, nil) - replace node with result, or `nil` if no change requested.
def in_sequence_head
  nil
end

def matches_within_set?

Returns:
  • (Boolean) - returns true for nodes having a Ruby literal equivalent
def matches_within_set?
  MATCHES_WITHIN_SET.include?(type)
end

def nb_captures

Returns:
  • (Integer) - nb of captures of that node and its descendants
def nb_captures
  children_nodes.sum(&:nb_captures)
end

def rest?

def rest?
  false
end

def source_range

def source_range
  loc.expression
end

def variadic?

Returns:
  • (Boolean) - returns whether it matches a variable number of elements
def variadic?
  arity.is_a?(Range)
end

def with(type: @type, children: @children, location: @location)

def with(type: @type, children: @children, location: @location)
  self.class.new(type, children, { location: location })
end