Class: SyntaxTree::Super
- Inherits:
-
Node
- Object
- Node
- SyntaxTree::Super
show all
- Defined in:
- lib/syntax_tree/node.rb
Overview
Super represents using the super keyword with arguments. It can optionally use parentheses.
super(value)
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(arguments:, location:) ⇒ Super
Returns a new instance of Super.
10373
10374
10375
10376
10377
|
# File 'lib/syntax_tree/node.rb', line 10373
def initialize(arguments:, location:)
@arguments = arguments
@location = location
@comments = []
end
|
Instance Attribute Details
#arguments ⇒ Object
- ArgParen | Args
-
the arguments to the keyword
10368
10369
10370
|
# File 'lib/syntax_tree/node.rb', line 10368
def arguments
@arguments
end
|
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
10371
10372
10373
|
# File 'lib/syntax_tree/node.rb', line 10371
def
@comments
end
|
Instance Method Details
#===(other) ⇒ Object
10417
10418
10419
|
# File 'lib/syntax_tree/node.rb', line 10417
def ===(other)
other.is_a?(Super) && arguments === other.arguments
end
|
#accept(visitor) ⇒ Object
10379
10380
10381
|
# File 'lib/syntax_tree/node.rb', line 10379
def accept(visitor)
visitor.visit_super(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
10383
10384
10385
|
# File 'lib/syntax_tree/node.rb', line 10383
def child_nodes
[arguments]
end
|
#copy(arguments: nil, location: nil) ⇒ Object
10387
10388
10389
10390
10391
10392
10393
10394
10395
10396
|
# File 'lib/syntax_tree/node.rb', line 10387
def copy(arguments: nil, location: nil)
node =
Super.new(
arguments: arguments || self.arguments,
location: location || self.location
)
node..concat(.map(&:copy))
node
end
|
#deconstruct_keys(_keys) ⇒ Object
10400
10401
10402
|
# File 'lib/syntax_tree/node.rb', line 10400
def deconstruct_keys(_keys)
{ arguments: arguments, location: location, comments: }
end
|
10404
10405
10406
10407
10408
10409
10410
10411
10412
10413
10414
10415
|
# File 'lib/syntax_tree/node.rb', line 10404
def format(q)
q.group do
q.text("super")
if arguments.is_a?(ArgParen)
q.format(arguments)
else
q.text(" ")
q.nest("super ".length) { q.format(arguments) }
end
end
end
|