class SyntaxTree::VarRef
Experimental RBS support (using type sampling data from the type_fusion project).
# sig/syntax_tree/node.rbs class SyntaxTree::VarRef < SyntaxTree::Node def accept: (Visitor visitor) -> untyped def child_nodes: () -> untyped type SyntaxTree__VarRef_initialize_value = SyntaxTree::Kw | SyntaxTree::Ident | SyntaxTree::Const | SyntaxTree::IVar def initialize: (value: SyntaxTree__VarRef_initialize_value, location: SyntaxTree::Location) -> void end
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)
Experimental RBS support (using type sampling data from the type_fusion project).
def accept: (Visitor visitor) -> untyped
This signature was generated using 53 samples from 1 application.
def accept(visitor) visitor.visit_var_ref(self) end
def child_nodes
Experimental RBS support (using type sampling data from the type_fusion project).
def child_nodes: () -> untyped
This signature was generated using 42 samples from 1 application.
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:)
Experimental RBS support (using type sampling data from the type_fusion project).
type SyntaxTree__VarRef_initialize_value = SyntaxTree::Kw | SyntaxTree::Ident | SyntaxTree::Const | SyntaxTree::IVar def initialize: (value: SyntaxTree__VarRef_initialize_value, location: SyntaxTree::Location) -> void
This signature was generated using 45 samples from 1 application.
def initialize(value:, location:) @value = value @location = location @comments = [] end
def pin(parent, pin)
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 end end end