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? }.
-
#each_child_node {|arguments| ... } ⇒ Object
def each_child_node: () { (Prism::node) -> void } -> void | () -> Enumerator.
-
#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.
19631 19632 19633 19634 19635 19636 19637 19638 19639 19640 |
# File 'lib/prism/node.rb', line 19631 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?
19717 19718 19719 |
# File 'lib/prism/node.rb', line 19717 def arguments @arguments end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See Node::type.
19764 19765 19766 |
# File 'lib/prism/node.rb', line 19764 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.
19770 19771 19772 19773 19774 19775 19776 |
# File 'lib/prism/node.rb', line 19770 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
19643 19644 19645 |
# File 'lib/prism/node.rb', line 19643 def accept(visitor) visitor.visit_yield_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array
19648 19649 19650 |
# File 'lib/prism/node.rb', line 19648 def child_nodes [arguments] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
19667 19668 19669 |
# File 'lib/prism/node.rb', line 19667 def comment_targets [keyword_loc, *lparen_loc, *arguments, *rparen_loc] #: Array[Prism::node | Location] end |
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array
19660 19661 19662 19663 19664 |
# File 'lib/prism/node.rb', line 19660 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
19672 19673 19674 |
# File 'lib/prism/node.rb', line 19672 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? }
19680 19681 19682 |
# File 'lib/prism/node.rb', line 19680 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 |
#each_child_node {|arguments| ... } ⇒ Object
def each_child_node: () { (Prism::node) -> void } -> void | () -> Enumerator
19653 19654 19655 19656 19657 |
# File 'lib/prism/node.rb', line 19653 def each_child_node return to_enum(:each_child_node) unless block_given? yield arguments if arguments end |
#inspect ⇒ Object
def inspect -> String
19754 19755 19756 |
# File 'lib/prism/node.rb', line 19754 def inspect InspectVisitor.compose(self) end |
#keyword ⇒ Object
def keyword: () -> String
19739 19740 19741 |
# File 'lib/prism/node.rb', line 19739 def keyword keyword_loc.slice end |
#keyword_loc ⇒ Object
attr_reader keyword_loc: Location
19685 19686 19687 19688 19689 |
# File 'lib/prism/node.rb', line 19685 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?
19744 19745 19746 |
# File 'lib/prism/node.rb', line 19744 def lparen lparen_loc&.slice end |
#lparen_loc ⇒ Object
attr_reader lparen_loc: Location?
19698 19699 19700 19701 19702 19703 19704 19705 19706 19707 19708 |
# File 'lib/prism/node.rb', line 19698 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?
19749 19750 19751 |
# File 'lib/prism/node.rb', line 19749 def rparen rparen_loc&.slice end |
#rparen_loc ⇒ Object
attr_reader rparen_loc: Location?
19720 19721 19722 19723 19724 19725 19726 19727 19728 19729 19730 |
# File 'lib/prism/node.rb', line 19720 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.
19693 19694 19695 |
# File 'lib/prism/node.rb', line 19693 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.
19712 19713 19714 |
# File 'lib/prism/node.rb', line 19712 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.
19734 19735 19736 |
# File 'lib/prism/node.rb', line 19734 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`.
19759 19760 19761 |
# File 'lib/prism/node.rb', line 19759 def type :yield_node end |