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: BlockNode | BlockArgumentNode | nil.
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: BlockNode | BlockArgumentNode | nil) -> 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: BlockNode | BlockArgumentNode | nil }.
-
#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?.
-
#save_keyword_loc(repository) ⇒ Object
Save the keyword_loc location using the given saved source so that it can be retrieved later.
-
#save_lparen_loc(repository) ⇒ Object
Save the lparen_loc location using the given saved source so that it can be retrieved later.
-
#save_rparen_loc(repository) ⇒ Object
Save the rparen_loc location using the given saved source so that it can be retrieved later.
-
#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.
17047 17048 17049 17050 17051 17052 17053 17054 17055 17056 17057 |
# File 'lib/prism/node.rb', line 17047 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?
17128 17129 17130 |
# File 'lib/prism/node.rb', line 17128 def arguments @arguments end |
#block ⇒ Object (readonly)
attr_reader block: BlockNode | BlockArgumentNode | nil
17150 17151 17152 |
# File 'lib/prism/node.rb', line 17150 def block @block end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See ‘Node::type`.
17178 17179 17180 |
# File 'lib/prism/node.rb', line 17178 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.
17184 17185 17186 17187 17188 17189 17190 17191 |
# File 'lib/prism/node.rb', line 17184 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
17060 17061 17062 |
# File 'lib/prism/node.rb', line 17060 def accept(visitor) visitor.visit_super_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
17065 17066 17067 |
# File 'lib/prism/node.rb', line 17065 def child_nodes [arguments, block] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
17078 17079 17080 |
# File 'lib/prism/node.rb', line 17078 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
17070 17071 17072 17073 17074 17075 |
# File 'lib/prism/node.rb', line 17070 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: BlockNode | BlockArgumentNode | nil) -> SuperNode
17083 17084 17085 |
# File 'lib/prism/node.rb', line 17083 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: BlockNode | BlockArgumentNode | nil }
17091 17092 17093 |
# File 'lib/prism/node.rb', line 17091 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
17168 17169 17170 |
# File 'lib/prism/node.rb', line 17168 def inspect InspectVisitor.compose(self) end |
#keyword ⇒ Object
def keyword: () -> String
17153 17154 17155 |
# File 'lib/prism/node.rb', line 17153 def keyword keyword_loc.slice end |
#keyword_loc ⇒ Object
attr_reader keyword_loc: Location
17096 17097 17098 17099 17100 |
# File 'lib/prism/node.rb', line 17096 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?
17158 17159 17160 |
# File 'lib/prism/node.rb', line 17158 def lparen lparen_loc&.slice end |
#lparen_loc ⇒ Object
attr_reader lparen_loc: Location?
17109 17110 17111 17112 17113 17114 17115 17116 17117 17118 17119 |
# File 'lib/prism/node.rb', line 17109 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?
17163 17164 17165 |
# File 'lib/prism/node.rb', line 17163 def rparen rparen_loc&.slice end |
#rparen_loc ⇒ Object
attr_reader rparen_loc: Location?
17131 17132 17133 17134 17135 17136 17137 17138 17139 17140 17141 |
# File 'lib/prism/node.rb', line 17131 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 |
#save_keyword_loc(repository) ⇒ Object
Save the keyword_loc location using the given saved source so that it can be retrieved later.
17104 17105 17106 |
# File 'lib/prism/node.rb', line 17104 def save_keyword_loc(repository) repository.enter(node_id, :keyword_loc) end |
#save_lparen_loc(repository) ⇒ Object
Save the lparen_loc location using the given saved source so that it can be retrieved later.
17123 17124 17125 |
# File 'lib/prism/node.rb', line 17123 def save_lparen_loc(repository) repository.enter(node_id, :lparen_loc) unless @lparen_loc.nil? end |
#save_rparen_loc(repository) ⇒ Object
Save the rparen_loc location using the given saved source so that it can be retrieved later.
17145 17146 17147 |
# File 'lib/prism/node.rb', line 17145 def save_rparen_loc(repository) repository.enter(node_id, :rparen_loc) unless @rparen_loc.nil? end |
#type ⇒ Object
Return a symbol representation of this node type. See ‘Node#type`.
17173 17174 17175 |
# File 'lib/prism/node.rb', line 17173 def type :super_node end |