Class: Prism::IndexOperatorWriteNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::IndexOperatorWriteNode
- Defined in:
- lib/prism/node.rb,
lib/prism/node_ext.rb,
ext/prism/api_node.c
Overview
Represents the use of an assignment operator on a call to ‘[]`.
foo.bar[baz] += value
^^^^^^^^^^^^^^^^^^^^^
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
attr_reader arguments: ArgumentsNode?.
-
#binary_operator ⇒ Object
readonly
attr_reader binary_operator: Symbol.
-
#block ⇒ Object
readonly
attr_reader block: BlockArgumentNode?.
-
#receiver ⇒ Object
readonly
attr_reader receiver: Prism::node?.
-
#value ⇒ Object
readonly
attr_reader value: 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.
-
#binary_operator_loc ⇒ Object
attr_reader binary_operator_loc: Location.
-
#call_operator ⇒ Object
def call_operator: () -> String?.
-
#call_operator_loc ⇒ Object
attr_reader call_operator_loc: Location?.
-
#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, call_operator_loc: self.call_operator_loc, opening_loc: self.opening_loc, arguments: self.arguments, closing_loc: self.closing_loc, block: self.block, binary_operator: self.binary_operator, binary_operator_loc: self.binary_operator_loc, value: self.value) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node?, ?call_operator_loc: Location?, ?opening_loc: Location, ?arguments: ArgumentsNode?, ?closing_loc: Location, ?block: BlockArgumentNode?, ?binary_operator: Symbol, ?binary_operator_loc: Location, ?value: Prism::node) -> IndexOperatorWriteNode.
-
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, receiver: Prism::node?, call_operator_loc: Location?, opening_loc: Location, arguments: ArgumentsNode?, closing_loc: Location, block: BlockArgumentNode?, binary_operator: Symbol, binary_operator_loc: Location, value: Prism::node }.
-
#ignore_visibility? ⇒ Boolean
def ignore_visibility?: () -> bool.
-
#initialize(source, node_id, location, flags, receiver, call_operator_loc, opening_loc, arguments, closing_loc, block, binary_operator, binary_operator_loc, value) ⇒ IndexOperatorWriteNode
constructor
Initialize a new IndexOperatorWriteNode node.
-
#inspect ⇒ Object
def inspect -> String.
-
#opening ⇒ Object
def opening: () -> String.
-
#opening_loc ⇒ Object
attr_reader opening_loc: Location.
-
#operator ⇒ Object
Returns the binary operator used to modify the receiver.
-
#operator_loc ⇒ Object
Returns the location of the binary operator used to modify the receiver.
-
#safe_navigation? ⇒ Boolean
def safe_navigation?: () -> bool.
-
#save_binary_operator_loc(repository) ⇒ Object
Save the binary_operator_loc location using the given saved source so that it can be retrieved later.
-
#save_call_operator_loc(repository) ⇒ Object
Save the call_operator_loc location using the given saved source so that it can be retrieved later.
-
#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, call_operator_loc, opening_loc, arguments, closing_loc, block, binary_operator, binary_operator_loc, value) ⇒ IndexOperatorWriteNode
Initialize a new IndexOperatorWriteNode node.
9353 9354 9355 9356 9357 9358 9359 9360 9361 9362 9363 9364 9365 9366 9367 |
# File 'lib/prism/node.rb', line 9353 def initialize(source, node_id, location, flags, receiver, call_operator_loc, opening_loc, arguments, closing_loc, block, binary_operator, binary_operator_loc, value) @source = source @node_id = node_id @location = location @flags = flags @receiver = receiver @call_operator_loc = call_operator_loc @opening_loc = opening_loc @arguments = arguments @closing_loc = closing_loc @block = block @binary_operator = binary_operator @binary_operator_loc = binary_operator_loc @value = value end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
attr_reader arguments: ArgumentsNode?
9463 9464 9465 |
# File 'lib/prism/node.rb', line 9463 def arguments @arguments end |
#binary_operator ⇒ Object (readonly)
attr_reader binary_operator: Symbol
9482 9483 9484 |
# File 'lib/prism/node.rb', line 9482 def binary_operator @binary_operator end |
#block ⇒ Object (readonly)
attr_reader block: BlockArgumentNode?
9479 9480 9481 |
# File 'lib/prism/node.rb', line 9479 def block @block end |
#receiver ⇒ Object (readonly)
attr_reader receiver: Prism::node?
9428 9429 9430 |
# File 'lib/prism/node.rb', line 9428 def receiver @receiver end |
#value ⇒ Object (readonly)
attr_reader value: Prism::node
9498 9499 9500 |
# File 'lib/prism/node.rb', line 9498 def value @value end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See ‘Node::type`.
9526 9527 9528 |
# File 'lib/prism/node.rb', line 9526 def self.type :index_operator_write_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.
9532 9533 9534 9535 9536 9537 9538 9539 9540 9541 9542 9543 9544 |
# File 'lib/prism/node.rb', line 9532 def ===(other) other.is_a?(IndexOperatorWriteNode) && (flags === other.flags) && (receiver === other.receiver) && (call_operator_loc.nil? == other.call_operator_loc.nil?) && (opening_loc.nil? == other.opening_loc.nil?) && (arguments === other.arguments) && (closing_loc.nil? == other.closing_loc.nil?) && (block === other.block) && (binary_operator === other.binary_operator) && (binary_operator_loc.nil? == other.binary_operator_loc.nil?) && (value === other.value) end |
#accept(visitor) ⇒ Object
def accept: (Visitor visitor) -> void
9370 9371 9372 |
# File 'lib/prism/node.rb', line 9370 def accept(visitor) visitor.visit_index_operator_write_node(self) end |
#attribute_write? ⇒ Boolean
def attribute_write?: () -> bool
9418 9419 9420 |
# File 'lib/prism/node.rb', line 9418 def attribute_write? flags.anybits?(CallNodeFlags::ATTRIBUTE_WRITE) end |
#binary_operator_loc ⇒ Object
attr_reader binary_operator_loc: Location
9485 9486 9487 9488 9489 |
# File 'lib/prism/node.rb', line 9485 def binary_operator_loc location = @binary_operator_loc return location if location.is_a?(Location) @binary_operator_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#call_operator ⇒ Object
def call_operator: () -> String?
9501 9502 9503 |
# File 'lib/prism/node.rb', line 9501 def call_operator call_operator_loc&.slice end |
#call_operator_loc ⇒ Object
attr_reader call_operator_loc: Location?
9431 9432 9433 9434 9435 9436 9437 9438 9439 9440 9441 |
# File 'lib/prism/node.rb', line 9431 def call_operator_loc location = @call_operator_loc case location when nil nil when Location location else @call_operator_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array
9375 9376 9377 |
# File 'lib/prism/node.rb', line 9375 def child_nodes [receiver, arguments, block, value] end |
#closing ⇒ Object
def closing: () -> String
9511 9512 9513 |
# File 'lib/prism/node.rb', line 9511 def closing closing_loc.slice end |
#closing_loc ⇒ Object
attr_reader closing_loc: Location
9466 9467 9468 9469 9470 |
# File 'lib/prism/node.rb', line 9466 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]
9390 9391 9392 |
# File 'lib/prism/node.rb', line 9390 def comment_targets [*receiver, *call_operator_loc, opening_loc, *arguments, closing_loc, *block, binary_operator_loc, value] #: Array[Prism::node | Location] end |
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array
9380 9381 9382 9383 9384 9385 9386 9387 |
# File 'lib/prism/node.rb', line 9380 def compact_child_nodes compact = [] #: Array[Prism::node] compact << receiver if receiver compact << arguments if arguments compact << block if block compact << value compact end |
#copy(node_id: self.node_id, location: self.location, flags: self.flags, receiver: self.receiver, call_operator_loc: self.call_operator_loc, opening_loc: self.opening_loc, arguments: self.arguments, closing_loc: self.closing_loc, block: self.block, binary_operator: self.binary_operator, binary_operator_loc: self.binary_operator_loc, value: self.value) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node?, ?call_operator_loc: Location?, ?opening_loc: Location, ?arguments: ArgumentsNode?, ?closing_loc: Location, ?block: BlockArgumentNode?, ?binary_operator: Symbol, ?binary_operator_loc: Location, ?value: Prism::node) -> IndexOperatorWriteNode
9395 9396 9397 |
# File 'lib/prism/node.rb', line 9395 def copy(node_id: self.node_id, location: self.location, flags: self.flags, receiver: self.receiver, call_operator_loc: self.call_operator_loc, opening_loc: self.opening_loc, arguments: self.arguments, closing_loc: self.closing_loc, block: self.block, binary_operator: self.binary_operator, binary_operator_loc: self.binary_operator_loc, value: self.value) IndexOperatorWriteNode.new(source, node_id, location, flags, receiver, call_operator_loc, opening_loc, arguments, closing_loc, block, binary_operator, binary_operator_loc, value) end |
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, receiver: Prism::node?, call_operator_loc: Location?, opening_loc: Location, arguments: ArgumentsNode?, closing_loc: Location, block: BlockArgumentNode?, binary_operator: Symbol, binary_operator_loc: Location, value: Prism::node }
9403 9404 9405 |
# File 'lib/prism/node.rb', line 9403 def deconstruct_keys(keys) { node_id: node_id, location: location, receiver: receiver, call_operator_loc: call_operator_loc, opening_loc: opening_loc, arguments: arguments, closing_loc: closing_loc, block: block, binary_operator: binary_operator, binary_operator_loc: binary_operator_loc, value: value } end |
#ignore_visibility? ⇒ Boolean
def ignore_visibility?: () -> bool
9423 9424 9425 |
# File 'lib/prism/node.rb', line 9423 def ignore_visibility? flags.anybits?(CallNodeFlags::IGNORE_VISIBILITY) end |
#inspect ⇒ Object
def inspect -> String
9516 9517 9518 |
# File 'lib/prism/node.rb', line 9516 def inspect InspectVisitor.compose(self) end |
#opening ⇒ Object
def opening: () -> String
9506 9507 9508 |
# File 'lib/prism/node.rb', line 9506 def opening opening_loc.slice end |
#opening_loc ⇒ Object
attr_reader opening_loc: Location
9450 9451 9452 9453 9454 |
# File 'lib/prism/node.rb', line 9450 def opening_loc location = @opening_loc return location if location.is_a?(Location) @opening_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#operator ⇒ Object
Returns the binary operator used to modify the receiver. This method is deprecated in favor of #binary_operator.
422 423 424 425 |
# File 'lib/prism/node_ext.rb', line 422 def operator deprecated("binary_operator") binary_operator end |
#operator_loc ⇒ Object
Returns the location of the binary operator used to modify the receiver. This method is deprecated in favor of #binary_operator_loc.
429 430 431 432 |
# File 'lib/prism/node_ext.rb', line 429 def operator_loc deprecated("binary_operator_loc") binary_operator_loc end |
#safe_navigation? ⇒ Boolean
def safe_navigation?: () -> bool
9408 9409 9410 |
# File 'lib/prism/node.rb', line 9408 def flags.anybits?(CallNodeFlags::SAFE_NAVIGATION) end |
#save_binary_operator_loc(repository) ⇒ Object
Save the binary_operator_loc location using the given saved source so that it can be retrieved later.
9493 9494 9495 |
# File 'lib/prism/node.rb', line 9493 def save_binary_operator_loc(repository) repository.enter(node_id, :binary_operator_loc) end |
#save_call_operator_loc(repository) ⇒ Object
Save the call_operator_loc location using the given saved source so that it can be retrieved later.
9445 9446 9447 |
# File 'lib/prism/node.rb', line 9445 def save_call_operator_loc(repository) repository.enter(node_id, :call_operator_loc) unless @call_operator_loc.nil? end |
#save_closing_loc(repository) ⇒ Object
Save the closing_loc location using the given saved source so that it can be retrieved later.
9474 9475 9476 |
# File 'lib/prism/node.rb', line 9474 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.
9458 9459 9460 |
# File 'lib/prism/node.rb', line 9458 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`.
9521 9522 9523 |
# File 'lib/prism/node.rb', line 9521 def type :index_operator_write_node end |
#variable_call? ⇒ Boolean
def variable_call?: () -> bool
9413 9414 9415 |
# File 'lib/prism/node.rb', line 9413 def variable_call? flags.anybits?(CallNodeFlags::VARIABLE_CALL) end |