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.
10421
10422
10423
10424
10425
|
# File 'lib/syntax_tree/node.rb', line 10421
def initialize(arguments:, location:)
@arguments = arguments
@location = location
@comments = []
end
|
Instance Attribute Details
#arguments ⇒ Object
- ArgParen | Args
-
the arguments to the keyword
10416
10417
10418
|
# File 'lib/syntax_tree/node.rb', line 10416
def arguments
@arguments
end
|
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
10419
10420
10421
|
# File 'lib/syntax_tree/node.rb', line 10419
def
@comments
end
|
Instance Method Details
#===(other) ⇒ Object
10465
10466
10467
|
# File 'lib/syntax_tree/node.rb', line 10465
def ===(other)
other.is_a?(Super) && arguments === other.arguments
end
|
#accept(visitor) ⇒ Object
10427
10428
10429
|
# File 'lib/syntax_tree/node.rb', line 10427
def accept(visitor)
visitor.visit_super(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
10431
10432
10433
|
# File 'lib/syntax_tree/node.rb', line 10431
def child_nodes
[arguments]
end
|
#copy(arguments: nil, location: nil) ⇒ Object
10435
10436
10437
10438
10439
10440
10441
10442
10443
10444
|
# File 'lib/syntax_tree/node.rb', line 10435
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
10448
10449
10450
|
# File 'lib/syntax_tree/node.rb', line 10448
def deconstruct_keys(_keys)
{ arguments: arguments, location: location, comments: }
end
|
10452
10453
10454
10455
10456
10457
10458
10459
10460
10461
10462
10463
|
# File 'lib/syntax_tree/node.rb', line 10452
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
|