Class: SyntaxTree::ConstPathRef
- Inherits:
-
Node
- Object
- Node
- SyntaxTree::ConstPathRef
show all
- Defined in:
- lib/syntax_tree/node.rb
Overview
ConstPathRef represents referencing a constant by a path.
object::Const
Instance Attribute Summary collapse
Attributes inherited from Node
#location
Instance Method Summary
collapse
Methods inherited from Node
#construct_keys, #end_char, #pretty_print, #start_char, #to_json, #to_mermaid
Constructor Details
#initialize(parent:, constant:, location:) ⇒ ConstPathRef
3892
3893
3894
3895
3896
3897
|
# File 'lib/syntax_tree/node.rb', line 3892
def initialize(parent:, constant:, location:)
@parent = parent
@constant = constant
@location = location
= []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
3890
3891
3892
|
# File 'lib/syntax_tree/node.rb', line 3890
def
end
|
#constant ⇒ Object
- Const
-
the constant itself
3887
3888
3889
|
# File 'lib/syntax_tree/node.rb', line 3887
def constant
@constant
end
|
#parent ⇒ Object
- Node
-
the source of the constant
3884
3885
3886
|
# File 'lib/syntax_tree/node.rb', line 3884
def parent
@parent
end
|
Instance Method Details
#===(other) ⇒ Object
3936
3937
3938
3939
|
# File 'lib/syntax_tree/node.rb', line 3936
def ===(other)
other.is_a?(ConstPathRef) && parent === other.parent &&
constant === other.constant
end
|
#accept(visitor) ⇒ Object
3899
3900
3901
|
# File 'lib/syntax_tree/node.rb', line 3899
def accept(visitor)
visitor.visit_const_path_ref(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
3903
3904
3905
|
# File 'lib/syntax_tree/node.rb', line 3903
def child_nodes
[parent, constant]
end
|
#copy(parent: nil, constant: nil, location: nil) ⇒ Object
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
|
# File 'lib/syntax_tree/node.rb', line 3907
def copy(parent: nil, constant: nil, location: nil)
node =
ConstPathRef.new(
parent: parent || self.parent,
constant: constant || self.constant,
location: location || self.location
)
node..concat(.map(&:copy))
node
end
|
#deconstruct_keys(_keys) ⇒ Object
3921
3922
3923
3924
3925
3926
3927
3928
|
# File 'lib/syntax_tree/node.rb', line 3921
def deconstruct_keys(_keys)
{
parent: parent,
constant: constant,
location: location,
comments:
}
end
|
3930
3931
3932
3933
3934
|
# File 'lib/syntax_tree/node.rb', line 3930
def format(q)
q.format(parent)
q.text("::")
q.format(constant)
end
|