Class: Prism::IndexTargetNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::IndexTargetNode
- Defined in:
- lib/prism/node.rb,
ext/prism/api_node.c
Overview
Represents assigning to an index.
foo[bar], = 1
^^^^^^^^
begin
rescue => foo[bar]
^^^^^^^^
end
for foo[bar] in baz do end
^^^^^^^^
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
attr_reader arguments: ArgumentsNode?.
-
#block ⇒ Object
readonly
attr_reader block: BlockArgumentNode?.
-
#receiver ⇒ Object
readonly
attr_reader receiver: 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.
-
#attribute_write? ⇒ Boolean
def attribute_write?: () -> bool.
-
#child_nodes ⇒ Object
(also: #deconstruct)
def child_nodes: () -> Array.
-
#closing ⇒ Object
def closing: () -> String.
-
#closing_loc ⇒ Object
attr_reader closing_loc: Location.
-
#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, receiver: self.receiver, opening_loc: self.opening_loc, arguments: self.arguments, closing_loc: self.closing_loc, block: self.block) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node, ?opening_loc: Location, ?arguments: ArgumentsNode?, ?closing_loc: Location, ?block: BlockArgumentNode?) -> IndexTargetNode.
-
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, receiver: Prism::node, opening_loc: Location, arguments: ArgumentsNode?, closing_loc: Location, block: BlockArgumentNode? }.
-
#ignore_visibility? ⇒ Boolean
def ignore_visibility?: () -> bool.
-
#initialize(source, node_id, location, flags, receiver, opening_loc, arguments, closing_loc, block) ⇒ IndexTargetNode
constructor
Initialize a new IndexTargetNode node.
-
#inspect ⇒ Object
def inspect -> String.
-
#opening ⇒ Object
def opening: () -> String.
-
#opening_loc ⇒ Object
attr_reader opening_loc: Location.
-
#safe_navigation? ⇒ Boolean
def safe_navigation?: () -> bool.
-
#save_closing_loc(repository) ⇒ Object
Save the closing_loc location using the given saved source so that it can be retrieved later.
-
#save_opening_loc(repository) ⇒ Object
Save the opening_loc location using the given saved source so that it can be retrieved later.
-
#type ⇒ Object
Return a symbol representation of this node type.
-
#variable_call? ⇒ Boolean
def variable_call?: () -> bool.
Constructor Details
#initialize(source, node_id, location, flags, receiver, opening_loc, arguments, closing_loc, block) ⇒ IndexTargetNode
Initialize a new IndexTargetNode node.
9724 9725 9726 9727 9728 9729 9730 9731 9732 9733 9734 |
# File 'lib/prism/node.rb', line 9724 def initialize(source, node_id, location, flags, receiver, opening_loc, arguments, closing_loc, block) @source = source @node_id = node_id @location = location @flags = flags @receiver = receiver @opening_loc = opening_loc @arguments = arguments @closing_loc = closing_loc @block = block end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
attr_reader arguments: ArgumentsNode?
9810 9811 9812 |
# File 'lib/prism/node.rb', line 9810 def arguments @arguments end |
#block ⇒ Object (readonly)
attr_reader block: BlockArgumentNode?
9826 9827 9828 |
# File 'lib/prism/node.rb', line 9826 def block @block end |
#receiver ⇒ Object (readonly)
attr_reader receiver: Prism::node
9794 9795 9796 |
# File 'lib/prism/node.rb', line 9794 def receiver @receiver end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See ‘Node::type`.
9849 9850 9851 |
# File 'lib/prism/node.rb', line 9849 def self.type :index_target_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.
9855 9856 9857 9858 9859 9860 9861 9862 9863 |
# File 'lib/prism/node.rb', line 9855 def ===(other) other.is_a?(IndexTargetNode) && (flags === other.flags) && (receiver === other.receiver) && (opening_loc.nil? == other.opening_loc.nil?) && (arguments === other.arguments) && (closing_loc.nil? == other.closing_loc.nil?) && (block === other.block) end |
#accept(visitor) ⇒ Object
def accept: (Visitor visitor) -> void
9737 9738 9739 |
# File 'lib/prism/node.rb', line 9737 def accept(visitor) visitor.visit_index_target_node(self) end |
#attribute_write? ⇒ Boolean
def attribute_write?: () -> bool
9784 9785 9786 |
# File 'lib/prism/node.rb', line 9784 def attribute_write? flags.anybits?(CallNodeFlags::ATTRIBUTE_WRITE) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array
9742 9743 9744 |
# File 'lib/prism/node.rb', line 9742 def child_nodes [receiver, arguments, block] end |
#closing ⇒ Object
def closing: () -> String
9834 9835 9836 |
# File 'lib/prism/node.rb', line 9834 def closing closing_loc.slice end |
#closing_loc ⇒ Object
attr_reader closing_loc: Location
9813 9814 9815 9816 9817 |
# File 'lib/prism/node.rb', line 9813 def closing_loc location = @closing_loc return location if location.is_a?(Location) @closing_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
9756 9757 9758 |
# File 'lib/prism/node.rb', line 9756 def comment_targets [receiver, opening_loc, *arguments, closing_loc, *block] #: Array[Prism::node | Location] end |
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array
9747 9748 9749 9750 9751 9752 9753 |
# File 'lib/prism/node.rb', line 9747 def compact_child_nodes compact = [] #: Array[Prism::node] compact << receiver compact << arguments if arguments compact << block if block compact end |
#copy(node_id: self.node_id, location: self.location, flags: self.flags, receiver: self.receiver, opening_loc: self.opening_loc, arguments: self.arguments, closing_loc: self.closing_loc, block: self.block) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node, ?opening_loc: Location, ?arguments: ArgumentsNode?, ?closing_loc: Location, ?block: BlockArgumentNode?) -> IndexTargetNode
9761 9762 9763 |
# File 'lib/prism/node.rb', line 9761 def copy(node_id: self.node_id, location: self.location, flags: self.flags, receiver: self.receiver, opening_loc: self.opening_loc, arguments: self.arguments, closing_loc: self.closing_loc, block: self.block) IndexTargetNode.new(source, node_id, location, flags, receiver, opening_loc, arguments, closing_loc, block) end |
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, receiver: Prism::node, opening_loc: Location, arguments: ArgumentsNode?, closing_loc: Location, block: BlockArgumentNode? }
9769 9770 9771 |
# File 'lib/prism/node.rb', line 9769 def deconstruct_keys(keys) { node_id: node_id, location: location, receiver: receiver, opening_loc: opening_loc, arguments: arguments, closing_loc: closing_loc, block: block } end |
#ignore_visibility? ⇒ Boolean
def ignore_visibility?: () -> bool
9789 9790 9791 |
# File 'lib/prism/node.rb', line 9789 def ignore_visibility? flags.anybits?(CallNodeFlags::IGNORE_VISIBILITY) end |
#inspect ⇒ Object
def inspect -> String
9839 9840 9841 |
# File 'lib/prism/node.rb', line 9839 def inspect InspectVisitor.compose(self) end |
#opening ⇒ Object
def opening: () -> String
9829 9830 9831 |
# File 'lib/prism/node.rb', line 9829 def opening opening_loc.slice end |
#opening_loc ⇒ Object
attr_reader opening_loc: Location
9797 9798 9799 9800 9801 |
# File 'lib/prism/node.rb', line 9797 def opening_loc location = @opening_loc return location if location.is_a?(Location) @opening_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#safe_navigation? ⇒ Boolean
def safe_navigation?: () -> bool
9774 9775 9776 |
# File 'lib/prism/node.rb', line 9774 def flags.anybits?(CallNodeFlags::SAFE_NAVIGATION) end |
#save_closing_loc(repository) ⇒ Object
Save the closing_loc location using the given saved source so that it can be retrieved later.
9821 9822 9823 |
# File 'lib/prism/node.rb', line 9821 def save_closing_loc(repository) repository.enter(node_id, :closing_loc) end |
#save_opening_loc(repository) ⇒ Object
Save the opening_loc location using the given saved source so that it can be retrieved later.
9805 9806 9807 |
# File 'lib/prism/node.rb', line 9805 def save_opening_loc(repository) repository.enter(node_id, :opening_loc) end |
#type ⇒ Object
Return a symbol representation of this node type. See ‘Node#type`.
9844 9845 9846 |
# File 'lib/prism/node.rb', line 9844 def type :index_target_node end |
#variable_call? ⇒ Boolean
def variable_call?: () -> bool
9779 9780 9781 |
# File 'lib/prism/node.rb', line 9779 def variable_call? flags.anybits?(CallNodeFlags::VARIABLE_CALL) end |