class SyntaxTree::VarRef

variable.
keyword (like self, nil, true, or false), or a numbered block
constant, a class variable, a global variable, an instance variable, a
This can be a plain local variable like the example above. It can also be a
true
VarRef represents a variable reference.

def ===(other)

def ===(other)
  other.is_a?(VarRef) && value === other.value
end

def accept(visitor)

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

def child_nodes

def child_nodes
  [value]
end

def copy(value: nil, location: nil)

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

def deconstruct_keys(_keys)

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

def format(q)

def format(q)
  q.format(value)
end

def initialize(value:, location:)

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

def pin(parent, pin)

place of shame. But it's necessary for now, so I'm keeping it.
To be clear, this method should just not exist. It's not good. It's a

we have to replace this node by a pinned node when necessary.
have to walk the tree ourselves and insert more information. In doing so,
functionality to actually know where pins are within an expression. So we
Oh man I hate this so much. Basically, ripper doesn't provide enough
def pin(parent, pin)
  replace =
    PinnedVarRef.new(value: value, location: pin.location.to(location))
  parent
    .deconstruct_keys([])
    .each do |key, value|
      if value == self
        parent.instance_variable_set(:"@#{key}", replace)
        break
      elsif value.is_a?(Array) && (index = value.index(self))
        parent.public_send(key)[index] = replace
        break
      elsif value.is_a?(Array) &&
            (index = value.index { |(_k, v)| v == self })
        parent.public_send(key)[index][1] = replace
        break
      end
    end
end