Class: SyntaxTree::ConstRef
- Inherits:
-
Node
- Object
- Node
- SyntaxTree::ConstRef
show all
- Defined in:
- lib/syntax_tree/node.rb
Overview
ConstRef represents the name of the constant being used in a class or module declaration.
class Container
end
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(constant:, location:) ⇒ ConstRef
Returns a new instance of ConstRef.
3986
3987
3988
3989
3990
|
# File 'lib/syntax_tree/node.rb', line 3986
def initialize(constant:, location:)
@constant = constant
@location = location
= []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
3984
3985
3986
|
# File 'lib/syntax_tree/node.rb', line 3984
def
end
|
#constant ⇒ Object
- Const
-
the constant itself
3981
3982
3983
|
# File 'lib/syntax_tree/node.rb', line 3981
def constant
@constant
end
|
Instance Method Details
#===(other) ⇒ Object
4021
4022
4023
|
# File 'lib/syntax_tree/node.rb', line 4021
def ===(other)
other.is_a?(ConstRef) && constant === other.constant
end
|
#accept(visitor) ⇒ Object
3992
3993
3994
|
# File 'lib/syntax_tree/node.rb', line 3992
def accept(visitor)
visitor.visit_const_ref(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
3996
3997
3998
|
# File 'lib/syntax_tree/node.rb', line 3996
def child_nodes
[constant]
end
|
#copy(constant: nil, location: nil) ⇒ Object
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
|
# File 'lib/syntax_tree/node.rb', line 4000
def copy(constant: nil, location: nil)
node =
ConstRef.new(
constant: constant || self.constant,
location: location || self.location
)
node..concat(.map(&:copy))
node
end
|
#deconstruct_keys(_keys) ⇒ Object
4013
4014
4015
|
# File 'lib/syntax_tree/node.rb', line 4013
def deconstruct_keys(_keys)
{ constant: constant, location: location, comments: }
end
|
4017
4018
4019
|
# File 'lib/syntax_tree/node.rb', line 4017
def format(q)
q.format(constant)
end
|