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[nil | Node].
-
#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.
-
#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.
8555 8556 8557 8558 8559 8560 8561 8562 8563 8564 8565 |
# File 'lib/prism/node.rb', line 8555 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?
8635 8636 8637 |
# File 'lib/prism/node.rb', line 8635 def arguments @arguments end |
#block ⇒ Object (readonly)
attr_reader block: BlockArgumentNode?
8645 8646 8647 |
# File 'lib/prism/node.rb', line 8645 def block @block end |
#receiver ⇒ Object (readonly)
attr_reader receiver: Prism::node
8625 8626 8627 |
# File 'lib/prism/node.rb', line 8625 def receiver @receiver end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See ‘Node::type`.
8668 8669 8670 |
# File 'lib/prism/node.rb', line 8668 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.
8674 8675 8676 8677 8678 8679 8680 8681 8682 |
# File 'lib/prism/node.rb', line 8674 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
8568 8569 8570 |
# File 'lib/prism/node.rb', line 8568 def accept(visitor) visitor.visit_index_target_node(self) end |
#attribute_write? ⇒ Boolean
def attribute_write?: () -> bool
8615 8616 8617 |
# File 'lib/prism/node.rb', line 8615 def attribute_write? flags.anybits?(CallNodeFlags::ATTRIBUTE_WRITE) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
8573 8574 8575 |
# File 'lib/prism/node.rb', line 8573 def child_nodes [receiver, arguments, block] end |
#closing ⇒ Object
def closing: () -> String
8653 8654 8655 |
# File 'lib/prism/node.rb', line 8653 def closing closing_loc.slice end |
#closing_loc ⇒ Object
attr_reader closing_loc: Location
8638 8639 8640 8641 8642 |
# File 'lib/prism/node.rb', line 8638 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]
8587 8588 8589 |
# File 'lib/prism/node.rb', line 8587 def comment_targets [receiver, opening_loc, *arguments, closing_loc, *block] #: Array[Prism::node | Location] end |
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array
8578 8579 8580 8581 8582 8583 8584 |
# File 'lib/prism/node.rb', line 8578 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
8592 8593 8594 |
# File 'lib/prism/node.rb', line 8592 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? }
8600 8601 8602 |
# File 'lib/prism/node.rb', line 8600 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
8620 8621 8622 |
# File 'lib/prism/node.rb', line 8620 def ignore_visibility? flags.anybits?(CallNodeFlags::IGNORE_VISIBILITY) end |
#inspect ⇒ Object
def inspect -> String
8658 8659 8660 |
# File 'lib/prism/node.rb', line 8658 def inspect InspectVisitor.compose(self) end |
#opening ⇒ Object
def opening: () -> String
8648 8649 8650 |
# File 'lib/prism/node.rb', line 8648 def opening opening_loc.slice end |
#opening_loc ⇒ Object
attr_reader opening_loc: Location
8628 8629 8630 8631 8632 |
# File 'lib/prism/node.rb', line 8628 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
8605 8606 8607 |
# File 'lib/prism/node.rb', line 8605 def flags.anybits?(CallNodeFlags::SAFE_NAVIGATION) end |
#type ⇒ Object
Return a symbol representation of this node type. See ‘Node#type`.
8663 8664 8665 |
# File 'lib/prism/node.rb', line 8663 def type :index_target_node end |
#variable_call? ⇒ Boolean
def variable_call?: () -> bool
8610 8611 8612 |
# File 'lib/prism/node.rb', line 8610 def variable_call? flags.anybits?(CallNodeFlags::VARIABLE_CALL) end |