Class: SyntaxTree::TopConstRef
- Inherits:
-
Node
- Object
- Node
- SyntaxTree::TopConstRef
show all
- Defined in:
- lib/syntax_tree/node.rb
Overview
TopConstRef is very similar to TopConstField except that it is not involved in an assignment.
::Constant
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:) ⇒ TopConstRef
Returns a new instance of TopConstRef.
10883
10884
10885
10886
10887
|
# File 'lib/syntax_tree/node.rb', line 10883
def initialize(constant:, location:)
@constant = constant
@location = location
@comments = []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
10881
10882
10883
|
# File 'lib/syntax_tree/node.rb', line 10881
def
@comments
end
|
#constant ⇒ Object
- Const
-
the constant being referenced
10878
10879
10880
|
# File 'lib/syntax_tree/node.rb', line 10878
def constant
@constant
end
|
Instance Method Details
#===(other) ⇒ Object
10919
10920
10921
|
# File 'lib/syntax_tree/node.rb', line 10919
def ===(other)
other.is_a?(TopConstRef) && constant === other.constant
end
|
#accept(visitor) ⇒ Object
10889
10890
10891
|
# File 'lib/syntax_tree/node.rb', line 10889
def accept(visitor)
visitor.visit_top_const_ref(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
10893
10894
10895
|
# File 'lib/syntax_tree/node.rb', line 10893
def child_nodes
[constant]
end
|
#copy(constant: nil, location: nil) ⇒ Object
10897
10898
10899
10900
10901
10902
10903
10904
10905
10906
|
# File 'lib/syntax_tree/node.rb', line 10897
def copy(constant: nil, location: nil)
node =
TopConstRef.new(
constant: constant || self.constant,
location: location || self.location
)
node..concat(.map(&:copy))
node
end
|
#deconstruct_keys(_keys) ⇒ Object
10910
10911
10912
|
# File 'lib/syntax_tree/node.rb', line 10910
def deconstruct_keys(_keys)
{ constant: constant, location: location, comments: }
end
|
10914
10915
10916
10917
|
# File 'lib/syntax_tree/node.rb', line 10914
def format(q)
q.text("::")
q.format(constant)
end
|