Class: Prism::SuperNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::SuperNode
- Defined in:
- lib/prism/node.rb,
ext/prism/api_node.c
Overview
Represents the use of the ‘super` keyword with parentheses or arguments.
super()
^^^^^^^
super foo, bar
^^^^^^^^^^^^^^
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
attr_reader arguments: ArgumentsNode?.
-
#block ⇒ Object
readonly
attr_reader block: Prism::node?.
Class Method Summary collapse
-
.type ⇒ Object
Return a symbol representation of this node type.
Instance Method Summary collapse
-
#===(other) ⇒ Object
Implements case-equality for the node.
-
#accept(visitor) ⇒ Object
def accept: (Visitor visitor) -> void.
-
#child_nodes ⇒ Object
(also: #deconstruct)
def child_nodes: () -> Array[nil | Node].
-
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location].
-
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array.
-
#copy(node_id: self.node_id, location: self.location, flags: self.flags, keyword_loc: self.keyword_loc, lparen_loc: self.lparen_loc, arguments: self.arguments, rparen_loc: self.rparen_loc, block: self.block) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?keyword_loc: Location, ?lparen_loc: Location?, ?arguments: ArgumentsNode?, ?rparen_loc: Location?, ?block: Prism::node?) -> SuperNode.
-
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, keyword_loc: Location, lparen_loc: Location?, arguments: ArgumentsNode?, rparen_loc: Location?, block: Prism::node? }.
-
#initialize(source, node_id, location, flags, keyword_loc, lparen_loc, arguments, rparen_loc, block) ⇒ SuperNode
constructor
Initialize a new SuperNode node.
-
#inspect ⇒ Object
def inspect -> String.
-
#keyword ⇒ Object
def keyword: () -> String.
-
#keyword_loc ⇒ Object
attr_reader keyword_loc: Location.
-
#lparen ⇒ Object
def lparen: () -> String?.
-
#lparen_loc ⇒ Object
attr_reader lparen_loc: Location?.
-
#rparen ⇒ Object
def rparen: () -> String?.
-
#rparen_loc ⇒ Object
attr_reader rparen_loc: Location?.
-
#type ⇒ Object
Return a symbol representation of this node type.
Constructor Details
#initialize(source, node_id, location, flags, keyword_loc, lparen_loc, arguments, rparen_loc, block) ⇒ SuperNode
Initialize a new SuperNode node.
15419 15420 15421 15422 15423 15424 15425 15426 15427 15428 15429 |
# File 'lib/prism/node.rb', line 15419 def initialize(source, node_id, location, flags, keyword_loc, lparen_loc, arguments, rparen_loc, block) @source = source @node_id = node_id @location = location @flags = flags @keyword_loc = keyword_loc @lparen_loc = lparen_loc @arguments = arguments @rparen_loc = rparen_loc @block = block end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
attr_reader arguments: ArgumentsNode?
15488 15489 15490 |
# File 'lib/prism/node.rb', line 15488 def arguments @arguments end |
#block ⇒ Object (readonly)
attr_reader block: Prism::node?
15504 15505 15506 |
# File 'lib/prism/node.rb', line 15504 def block @block end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See ‘Node::type`.
15532 15533 15534 |
# File 'lib/prism/node.rb', line 15532 def self.type :super_node end |
Instance Method Details
#===(other) ⇒ Object
Implements case-equality for the node. This is effectively == but without comparing the value of locations. Locations are checked only for presence.
15538 15539 15540 15541 15542 15543 15544 15545 |
# File 'lib/prism/node.rb', line 15538 def ===(other) other.is_a?(SuperNode) && (keyword_loc.nil? == other.keyword_loc.nil?) && (lparen_loc.nil? == other.lparen_loc.nil?) && (arguments === other.arguments) && (rparen_loc.nil? == other.rparen_loc.nil?) && (block === other.block) end |
#accept(visitor) ⇒ Object
def accept: (Visitor visitor) -> void
15432 15433 15434 |
# File 'lib/prism/node.rb', line 15432 def accept(visitor) visitor.visit_super_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
15437 15438 15439 |
# File 'lib/prism/node.rb', line 15437 def child_nodes [arguments, block] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
15450 15451 15452 |
# File 'lib/prism/node.rb', line 15450 def comment_targets [keyword_loc, *lparen_loc, *arguments, *rparen_loc, *block] #: Array[Prism::node | Location] end |
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array
15442 15443 15444 15445 15446 15447 |
# File 'lib/prism/node.rb', line 15442 def compact_child_nodes compact = [] #: Array[Prism::node] compact << arguments if arguments compact << block if block compact end |
#copy(node_id: self.node_id, location: self.location, flags: self.flags, keyword_loc: self.keyword_loc, lparen_loc: self.lparen_loc, arguments: self.arguments, rparen_loc: self.rparen_loc, block: self.block) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?keyword_loc: Location, ?lparen_loc: Location?, ?arguments: ArgumentsNode?, ?rparen_loc: Location?, ?block: Prism::node?) -> SuperNode
15455 15456 15457 |
# File 'lib/prism/node.rb', line 15455 def copy(node_id: self.node_id, location: self.location, flags: self.flags, keyword_loc: self.keyword_loc, lparen_loc: self.lparen_loc, arguments: self.arguments, rparen_loc: self.rparen_loc, block: self.block) SuperNode.new(source, node_id, location, flags, keyword_loc, lparen_loc, arguments, rparen_loc, block) end |
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, keyword_loc: Location, lparen_loc: Location?, arguments: ArgumentsNode?, rparen_loc: Location?, block: Prism::node? }
15463 15464 15465 |
# File 'lib/prism/node.rb', line 15463 def deconstruct_keys(keys) { node_id: node_id, location: location, keyword_loc: keyword_loc, lparen_loc: lparen_loc, arguments: arguments, rparen_loc: rparen_loc, block: block } end |
#inspect ⇒ Object
def inspect -> String
15522 15523 15524 |
# File 'lib/prism/node.rb', line 15522 def inspect InspectVisitor.compose(self) end |
#keyword ⇒ Object
def keyword: () -> String
15507 15508 15509 |
# File 'lib/prism/node.rb', line 15507 def keyword keyword_loc.slice end |
#keyword_loc ⇒ Object
attr_reader keyword_loc: Location
15468 15469 15470 15471 15472 |
# File 'lib/prism/node.rb', line 15468 def keyword_loc location = @keyword_loc return location if location.is_a?(Location) @keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#lparen ⇒ Object
def lparen: () -> String?
15512 15513 15514 |
# File 'lib/prism/node.rb', line 15512 def lparen lparen_loc&.slice end |
#lparen_loc ⇒ Object
attr_reader lparen_loc: Location?
15475 15476 15477 15478 15479 15480 15481 15482 15483 15484 15485 |
# File 'lib/prism/node.rb', line 15475 def lparen_loc location = @lparen_loc case location when nil nil when Location location else @lparen_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end end |
#rparen ⇒ Object
def rparen: () -> String?
15517 15518 15519 |
# File 'lib/prism/node.rb', line 15517 def rparen rparen_loc&.slice end |
#rparen_loc ⇒ Object
attr_reader rparen_loc: Location?
15491 15492 15493 15494 15495 15496 15497 15498 15499 15500 15501 |
# File 'lib/prism/node.rb', line 15491 def rparen_loc location = @rparen_loc case location when nil nil when Location location else @rparen_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end end |
#type ⇒ Object
Return a symbol representation of this node type. See ‘Node#type`.
15527 15528 15529 |
# File 'lib/prism/node.rb', line 15527 def type :super_node end |