class SyntaxTree::AliasNode
:“left-#{middle}-right”).
symbols (note that this includes dynamic symbols like
can either provide bare words (like the example above) or you can provide
and it will execute the name method. When you’re aliasing two methods, you
For the example above, in the current context you can now call aliased_name
alias aliased_name name
another name as well as the current one.
global variables). The alias
keyword is used to make a method respond to
Alias represents the use of the alias
keyword with regular arguments (not
def ===(other)
def ===(other) other.is_a?(AliasNode) && left === other.left && right === other.right end
def accept(visitor)
def accept(visitor) visitor.visit_alias(self) end
def child_nodes
def child_nodes [left, right] end
def copy(left: nil, right: nil, location: nil)
def copy(left: nil, right: nil, location: nil) node = AliasNode.new( left: left || self.left, right: right || self.right, location: location || self.location ) node.comments.concat(comments.map(&:copy)) node end
def deconstruct_keys(_keys)
def deconstruct_keys(_keys) { left: left, right: right, location: location, comments: comments } end
def format(q)
def format(q) keyword = "alias " left_argument = AliasArgumentFormatter.new(left) q.group do q.text(keyword) q.format(left_argument, stackable: false) q.group do q.nest(keyword.length) do left_argument.comments.any? ? q.breakable_force : q.breakable_space q.format(AliasArgumentFormatter.new(right), stackable: false) end end end end
def initialize(left:, right:, location:)
def initialize(left:, right:, location:) @left = left @right = right @location = location @comments = [] end
def var_alias?
def var_alias? left.is_a?(GVar) end