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, #pretty_print, #to_json
Constructor Details
#initialize(arguments:, location:) ⇒ Super
Returns a new instance of Super.
10255
10256
10257
10258
10259
|
# File 'lib/syntax_tree/node.rb', line 10255
def initialize(arguments:, location:)
@arguments = arguments
@location = location
@comments = []
end
|
Instance Attribute Details
#arguments ⇒ Object
- ArgParen | Args
-
the arguments to the keyword
10250
10251
10252
|
# File 'lib/syntax_tree/node.rb', line 10250
def arguments
@arguments
end
|
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
10253
10254
10255
|
# File 'lib/syntax_tree/node.rb', line 10253
def
@comments
end
|
Instance Method Details
#===(other) ⇒ Object
10299
10300
10301
|
# File 'lib/syntax_tree/node.rb', line 10299
def ===(other)
other.is_a?(Super) && arguments === other.arguments
end
|
#accept(visitor) ⇒ Object
10261
10262
10263
|
# File 'lib/syntax_tree/node.rb', line 10261
def accept(visitor)
visitor.visit_super(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
10265
10266
10267
|
# File 'lib/syntax_tree/node.rb', line 10265
def child_nodes
[arguments]
end
|
#copy(arguments: nil, location: nil) ⇒ Object
10269
10270
10271
10272
10273
10274
10275
10276
10277
10278
|
# File 'lib/syntax_tree/node.rb', line 10269
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
10282
10283
10284
|
# File 'lib/syntax_tree/node.rb', line 10282
def deconstruct_keys(_keys)
{ arguments: arguments, location: location, comments: }
end
|
10286
10287
10288
10289
10290
10291
10292
10293
10294
10295
10296
10297
|
# File 'lib/syntax_tree/node.rb', line 10286
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
|