class SyntaxTree::Assoc

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

# sig/syntax_tree/node.rbs

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

In the above example, the would be two Assoc nodes.
{ key1: value1, key2: value2 }
either an AssocListFromArgs or a BareAssocHash.
Assoc represents a key-value pair within a hash. It is a child node of

def ===(other)

def ===(other)
  other.is_a?(Assoc) && key === other.key && value === other.value
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 2 samples from 1 application.

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

def child_nodes

def child_nodes
  [key, value]
end

def copy(key: nil, value: nil, location: nil)

def copy(key: nil, value: nil, location: nil)
  node =
    Assoc.new(
      key: key || self.key,
      value: value || self.value,
      location: location || self.location
    )
  node.comments.concat(comments.map(&:copy))
  node
end

def deconstruct_keys(_keys)

def deconstruct_keys(_keys)
  { key: key, value: value, location: location, comments: comments }
end

def format(q)

def format(q)
  if value.is_a?(HashLiteral)
    format_contents(q)
  else
    q.group { format_contents(q) }
  end
end

def format_contents(q)

def format_contents(q)
  (q.parent || HashKeyFormatter::Identity.new).format_key(q, key)
  return unless value
  if key.comments.empty? && AssignFormatting.skip_indent?(value)
    q.text(" ")
    q.format(value)
  else
    q.indent do
      q.breakable_space
      q.format(value)
    end
  end
end

def initialize(key:, value:, location:)

def initialize(key:, value:, location:)
  @key = key
  @value = value
  @location = location
  @comments = []
end