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: Prism::node?.
-
#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: Prism::node?) -> 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: Prism::node? }.
-
#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.
8518 8519 8520 8521 8522 8523 8524 8525 8526 8527 8528 |
# File 'lib/prism/node.rb', line 8518 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?
8598 8599 8600 |
# File 'lib/prism/node.rb', line 8598 def arguments @arguments end |
#block ⇒ Object (readonly)
attr_reader block: Prism::node?
8608 8609 8610 |
# File 'lib/prism/node.rb', line 8608 def block @block end |
#receiver ⇒ Object (readonly)
attr_reader receiver: Prism::node
8588 8589 8590 |
# File 'lib/prism/node.rb', line 8588 def receiver @receiver end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See ‘Node::type`.
8631 8632 8633 |
# File 'lib/prism/node.rb', line 8631 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.
8637 8638 8639 8640 8641 8642 8643 8644 8645 |
# File 'lib/prism/node.rb', line 8637 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
8531 8532 8533 |
# File 'lib/prism/node.rb', line 8531 def accept(visitor) visitor.visit_index_target_node(self) end |
#attribute_write? ⇒ Boolean
def attribute_write?: () -> bool
8578 8579 8580 |
# File 'lib/prism/node.rb', line 8578 def attribute_write? flags.anybits?(CallNodeFlags::ATTRIBUTE_WRITE) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
8536 8537 8538 |
# File 'lib/prism/node.rb', line 8536 def child_nodes [receiver, arguments, block] end |
#closing ⇒ Object
def closing: () -> String
8616 8617 8618 |
# File 'lib/prism/node.rb', line 8616 def closing closing_loc.slice end |
#closing_loc ⇒ Object
attr_reader closing_loc: Location
8601 8602 8603 8604 8605 |
# File 'lib/prism/node.rb', line 8601 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]
8550 8551 8552 |
# File 'lib/prism/node.rb', line 8550 def comment_targets [receiver, opening_loc, *arguments, closing_loc, *block] #: Array[Prism::node | Location] end |
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array
8541 8542 8543 8544 8545 8546 8547 |
# File 'lib/prism/node.rb', line 8541 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: Prism::node?) -> IndexTargetNode
8555 8556 8557 |
# File 'lib/prism/node.rb', line 8555 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: Prism::node? }
8563 8564 8565 |
# File 'lib/prism/node.rb', line 8563 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
8583 8584 8585 |
# File 'lib/prism/node.rb', line 8583 def ignore_visibility? flags.anybits?(CallNodeFlags::IGNORE_VISIBILITY) end |
#inspect ⇒ Object
def inspect -> String
8621 8622 8623 |
# File 'lib/prism/node.rb', line 8621 def inspect InspectVisitor.compose(self) end |
#opening ⇒ Object
def opening: () -> String
8611 8612 8613 |
# File 'lib/prism/node.rb', line 8611 def opening opening_loc.slice end |
#opening_loc ⇒ Object
attr_reader opening_loc: Location
8591 8592 8593 8594 8595 |
# File 'lib/prism/node.rb', line 8591 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
8568 8569 8570 |
# File 'lib/prism/node.rb', line 8568 def flags.anybits?(CallNodeFlags::SAFE_NAVIGATION) end |
#type ⇒ Object
Return a symbol representation of this node type. See ‘Node#type`.
8626 8627 8628 |
# File 'lib/prism/node.rb', line 8626 def type :index_target_node end |
#variable_call? ⇒ Boolean
def variable_call?: () -> bool
8573 8574 8575 |
# File 'lib/prism/node.rb', line 8573 def variable_call? flags.anybits?(CallNodeFlags::VARIABLE_CALL) end |