Class: Prism::RescueModifierNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::RescueModifierNode
- Defined in:
- lib/prism/node.rb,
lib/prism/parse_result/newlines.rb,
ext/prism/api_node.c
Overview
Represents an expression modified with a rescue.
foo rescue nil
^^^^^^^^^^^^^^
Instance Attribute Summary collapse
-
#expression ⇒ Object
readonly
attr_reader expression: Prism::node.
-
#rescue_expression ⇒ Object
readonly
attr_reader rescue_expression: 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.
-
#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, expression: self.expression, keyword_loc: self.keyword_loc, rescue_expression: self.rescue_expression) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?expression: Prism::node, ?keyword_loc: Location, ?rescue_expression: Prism::node) -> RescueModifierNode.
-
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, expression: Prism::node, keyword_loc: Location, rescue_expression: Prism::node }.
-
#each_child_node {|expression| ... } ⇒ Object
def each_child_node: () { (Prism::node) -> void } -> void | () -> Enumerator.
-
#initialize(source, node_id, location, flags, expression, keyword_loc, rescue_expression) ⇒ RescueModifierNode
constructor
Initialize a new RescueModifierNode node.
-
#inspect ⇒ Object
def inspect -> String.
-
#keyword ⇒ Object
def keyword: () -> String.
-
#keyword_loc ⇒ Object
attr_reader keyword_loc: Location.
-
#newline_flag!(lines) ⇒ Object
:nodoc:.
-
#save_keyword_loc(repository) ⇒ Object
Save the keyword_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, expression, keyword_loc, rescue_expression) ⇒ RescueModifierNode
Initialize a new RescueModifierNode node.
16757 16758 16759 16760 16761 16762 16763 16764 16765 |
# File 'lib/prism/node.rb', line 16757 def initialize(source, node_id, location, flags, expression, keyword_loc, rescue_expression) @source = source @node_id = node_id @location = location @flags = flags @expression = expression @keyword_loc = keyword_loc @rescue_expression = rescue_expression end |
Instance Attribute Details
#expression ⇒ Object (readonly)
attr_reader expression: Prism::node
16809 16810 16811 |
# File 'lib/prism/node.rb', line 16809 def expression @expression end |
#rescue_expression ⇒ Object (readonly)
attr_reader rescue_expression: Prism::node
16825 16826 16827 |
# File 'lib/prism/node.rb', line 16825 def rescue_expression @rescue_expression end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See Node::type.
16843 16844 16845 |
# File 'lib/prism/node.rb', line 16843 def self.type :rescue_modifier_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.
16849 16850 16851 16852 16853 16854 |
# File 'lib/prism/node.rb', line 16849 def ===(other) other.is_a?(RescueModifierNode) && (expression === other.expression) && (keyword_loc.nil? == other.keyword_loc.nil?) && (rescue_expression === other.rescue_expression) end |
#accept(visitor) ⇒ Object
def accept: (Visitor visitor) -> void
16768 16769 16770 |
# File 'lib/prism/node.rb', line 16768 def accept(visitor) visitor.visit_rescue_modifier_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array
16773 16774 16775 |
# File 'lib/prism/node.rb', line 16773 def child_nodes [expression, rescue_expression] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
16791 16792 16793 |
# File 'lib/prism/node.rb', line 16791 def comment_targets [expression, keyword_loc, rescue_expression] #: Array[Prism::node | Location] end |
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array
16786 16787 16788 |
# File 'lib/prism/node.rb', line 16786 def compact_child_nodes [expression, rescue_expression] end |
#copy(node_id: self.node_id, location: self.location, flags: self.flags, expression: self.expression, keyword_loc: self.keyword_loc, rescue_expression: self.rescue_expression) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?expression: Prism::node, ?keyword_loc: Location, ?rescue_expression: Prism::node) -> RescueModifierNode
16796 16797 16798 |
# File 'lib/prism/node.rb', line 16796 def copy(node_id: self.node_id, location: self.location, flags: self.flags, expression: self.expression, keyword_loc: self.keyword_loc, rescue_expression: self.rescue_expression) RescueModifierNode.new(source, node_id, location, flags, expression, keyword_loc, rescue_expression) end |
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, expression: Prism::node, keyword_loc: Location, rescue_expression: Prism::node }
16804 16805 16806 |
# File 'lib/prism/node.rb', line 16804 def deconstruct_keys(keys) { node_id: node_id, location: location, expression: expression, keyword_loc: keyword_loc, rescue_expression: rescue_expression } end |
#each_child_node {|expression| ... } ⇒ Object
def each_child_node: () { (Prism::node) -> void } -> void | () -> Enumerator
16778 16779 16780 16781 16782 16783 |
# File 'lib/prism/node.rb', line 16778 def each_child_node return to_enum(:each_child_node) unless block_given? yield expression yield rescue_expression end |
#inspect ⇒ Object
def inspect -> String
16833 16834 16835 |
# File 'lib/prism/node.rb', line 16833 def inspect InspectVisitor.compose(self) end |
#keyword ⇒ Object
def keyword: () -> String
16828 16829 16830 |
# File 'lib/prism/node.rb', line 16828 def keyword keyword_loc.slice end |
#keyword_loc ⇒ Object
attr_reader keyword_loc: Location
16812 16813 16814 16815 16816 |
# File 'lib/prism/node.rb', line 16812 def keyword_loc location = @keyword_loc return location if location.is_a?(Location) @keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#newline_flag!(lines) ⇒ Object
:nodoc:
116 117 118 |
# File 'lib/prism/parse_result/newlines.rb', line 116 def newline_flag!(lines) # :nodoc: expression.newline_flag!(lines) end |
#save_keyword_loc(repository) ⇒ Object
Save the keyword_loc location using the given saved source so that it can be retrieved later.
16820 16821 16822 |
# File 'lib/prism/node.rb', line 16820 def save_keyword_loc(repository) repository.enter(node_id, :keyword_loc) end |
#type ⇒ Object
Return a symbol representation of this node type. See ‘Node#type`.
16838 16839 16840 |
# File 'lib/prism/node.rb', line 16838 def type :rescue_modifier_node end |