Class: Prism::YieldNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::YieldNode
- Defined in:
- lib/prism/node.rb,
ext/prism/api_node.c
Overview
Represents the use of the ‘yield` keyword.
yield 1
^^^^^^^
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
attr_reader arguments: ArgumentsNode?.
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.
-
#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) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?keyword_loc: Location, ?lparen_loc: Location?, ?arguments: ArgumentsNode?, ?rparen_loc: Location?) -> YieldNode.
-
#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? }.
-
#initialize(source, node_id, location, flags, keyword_loc, lparen_loc, arguments, rparen_loc) ⇒ YieldNode
constructor
Initialize a new YieldNode 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) ⇒ YieldNode
Initialize a new YieldNode node.
18488 18489 18490 18491 18492 18493 18494 18495 18496 18497 |
# File 'lib/prism/node.rb', line 18488 def initialize(source, node_id, location, flags, keyword_loc, lparen_loc, arguments, rparen_loc) @source = source @node_id = node_id @location = location @flags = flags @keyword_loc = keyword_loc @lparen_loc = lparen_loc @arguments = arguments @rparen_loc = rparen_loc end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
attr_reader arguments: ArgumentsNode?
18567 18568 18569 |
# File 'lib/prism/node.rb', line 18567 def arguments @arguments end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See ‘Node::type`.
18614 18615 18616 |
# File 'lib/prism/node.rb', line 18614 def self.type :yield_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.
18620 18621 18622 18623 18624 18625 18626 |
# File 'lib/prism/node.rb', line 18620 def ===(other) other.is_a?(YieldNode) && (keyword_loc.nil? == other.keyword_loc.nil?) && (lparen_loc.nil? == other.lparen_loc.nil?) && (arguments === other.arguments) && (rparen_loc.nil? == other.rparen_loc.nil?) end |
#accept(visitor) ⇒ Object
def accept: (Visitor visitor) -> void
18500 18501 18502 |
# File 'lib/prism/node.rb', line 18500 def accept(visitor) visitor.visit_yield_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array
18505 18506 18507 |
# File 'lib/prism/node.rb', line 18505 def child_nodes [arguments] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
18517 18518 18519 |
# File 'lib/prism/node.rb', line 18517 def comment_targets [keyword_loc, *lparen_loc, *arguments, *rparen_loc] #: Array[Prism::node | Location] end |
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array
18510 18511 18512 18513 18514 |
# File 'lib/prism/node.rb', line 18510 def compact_child_nodes compact = [] #: Array[Prism::node] compact << arguments if arguments 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) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?keyword_loc: Location, ?lparen_loc: Location?, ?arguments: ArgumentsNode?, ?rparen_loc: Location?) -> YieldNode
18522 18523 18524 |
# File 'lib/prism/node.rb', line 18522 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) YieldNode.new(source, node_id, location, flags, keyword_loc, lparen_loc, arguments, rparen_loc) 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? }
18530 18531 18532 |
# File 'lib/prism/node.rb', line 18530 def deconstruct_keys(keys) { node_id: node_id, location: location, keyword_loc: keyword_loc, lparen_loc: lparen_loc, arguments: arguments, rparen_loc: rparen_loc } end |
#inspect ⇒ Object
def inspect -> String
18604 18605 18606 |
# File 'lib/prism/node.rb', line 18604 def inspect InspectVisitor.compose(self) end |
#keyword ⇒ Object
def keyword: () -> String
18589 18590 18591 |
# File 'lib/prism/node.rb', line 18589 def keyword keyword_loc.slice end |
#keyword_loc ⇒ Object
attr_reader keyword_loc: Location
18535 18536 18537 18538 18539 |
# File 'lib/prism/node.rb', line 18535 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?
18594 18595 18596 |
# File 'lib/prism/node.rb', line 18594 def lparen lparen_loc&.slice end |
#lparen_loc ⇒ Object
attr_reader lparen_loc: Location?
18548 18549 18550 18551 18552 18553 18554 18555 18556 18557 18558 |
# File 'lib/prism/node.rb', line 18548 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?
18599 18600 18601 |
# File 'lib/prism/node.rb', line 18599 def rparen rparen_loc&.slice end |
#rparen_loc ⇒ Object
attr_reader rparen_loc: Location?
18570 18571 18572 18573 18574 18575 18576 18577 18578 18579 18580 |
# File 'lib/prism/node.rb', line 18570 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.
18543 18544 18545 |
# File 'lib/prism/node.rb', line 18543 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.
18562 18563 18564 |
# File 'lib/prism/node.rb', line 18562 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.
18584 18585 18586 |
# File 'lib/prism/node.rb', line 18584 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`.
18609 18610 18611 |
# File 'lib/prism/node.rb', line 18609 def type :yield_node end |