Class: SyntaxTree::Ident
- Inherits:
-
Node
- Object
- Node
- SyntaxTree::Ident
show all
- Defined in:
- lib/syntax_tree/node.rb
Overview
Ident represents an identifier anywhere in code. It can represent a very large number of things, depending on where it is in the syntax tree.
value
Instance Attribute Summary collapse
Attributes inherited from Node
#location
Instance Method Summary
collapse
Methods inherited from Node
#construct_keys, #pretty_print, #to_json
Constructor Details
#initialize(value:, location:) ⇒ Ident
Returns a new instance of Ident.
6087
6088
6089
6090
6091
|
# File 'lib/syntax_tree/node.rb', line 6087
def initialize(value:, location:)
@value = value
@location = location
= []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
6085
6086
6087
|
# File 'lib/syntax_tree/node.rb', line 6085
def
end
|
#value ⇒ Object
- String
-
the value of the identifier
6082
6083
6084
|
# File 'lib/syntax_tree/node.rb', line 6082
def value
@value
end
|
Instance Method Details
#===(other) ⇒ Object
6122
6123
6124
|
# File 'lib/syntax_tree/node.rb', line 6122
def ===(other)
other.is_a?(Ident) && value === other.value
end
|
#accept(visitor) ⇒ Object
6093
6094
6095
|
# File 'lib/syntax_tree/node.rb', line 6093
def accept(visitor)
visitor.visit_ident(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
6097
6098
6099
|
# File 'lib/syntax_tree/node.rb', line 6097
def child_nodes
[]
end
|
#copy(value: nil, location: nil) ⇒ Object
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
|
# File 'lib/syntax_tree/node.rb', line 6101
def copy(value: nil, location: nil)
node =
Ident.new(
value: value || self.value,
location: location || self.location
)
node..concat(.map(&:copy))
node
end
|
#deconstruct_keys(_keys) ⇒ Object
6114
6115
6116
|
# File 'lib/syntax_tree/node.rb', line 6114
def deconstruct_keys(_keys)
{ value: value, location: location, comments: }
end
|
6118
6119
6120
|
# File 'lib/syntax_tree/node.rb', line 6118
def format(q)
q.text(value)
end
|