Class: Prism::IndexAndWriteNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::IndexAndWriteNode
- Defined in:
- lib/prism/node.rb,
ext/prism/api_node.c
Overview
Represents the use of the ‘&&=` operator on a call to the `[]` method.
foo.bar[baz] &&= value
^^^^^^^^^^^^^^^^^^^^^^
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?.
-
#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.
-
#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[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, call_operator_loc: self.call_operator_loc, opening_loc: self.opening_loc, arguments: self.arguments, closing_loc: self.closing_loc, block: self.block, operator_loc: self.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?, ?operator_loc: Location, ?value: Prism::node) -> IndexAndWriteNode.
-
#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?, 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, operator_loc, value) ⇒ IndexAndWriteNode
constructor
Initialize a new IndexAndWriteNode node.
-
#inspect ⇒ Object
def inspect -> String.
-
#opening ⇒ Object
def opening: () -> String.
-
#opening_loc ⇒ Object
attr_reader opening_loc: Location.
-
#operator ⇒ Object
def operator: () -> String.
-
#operator_loc ⇒ Object
attr_reader operator_loc: Location.
-
#safe_navigation? ⇒ Boolean
def safe_navigation?: () -> bool.
-
#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.
-
#save_operator_loc(repository) ⇒ Object
Save the operator_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, operator_loc, value) ⇒ IndexAndWriteNode
Initialize a new IndexAndWriteNode node.
9014 9015 9016 9017 9018 9019 9020 9021 9022 9023 9024 9025 9026 9027 |
# File 'lib/prism/node.rb', line 9014 def initialize(source, node_id, location, flags, receiver, call_operator_loc, opening_loc, arguments, closing_loc, block, 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 @operator_loc = operator_loc @value = value end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
attr_reader arguments: ArgumentsNode?
9123 9124 9125 |
# File 'lib/prism/node.rb', line 9123 def arguments @arguments end |
#block ⇒ Object (readonly)
attr_reader block: BlockArgumentNode?
9139 9140 9141 |
# File 'lib/prism/node.rb', line 9139 def block @block end |
#receiver ⇒ Object (readonly)
attr_reader receiver: Prism::node?
9088 9089 9090 |
# File 'lib/prism/node.rb', line 9088 def receiver @receiver end |
#value ⇒ Object (readonly)
attr_reader value: Prism::node
9155 9156 9157 |
# File 'lib/prism/node.rb', line 9155 def value @value end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See ‘Node::type`.
9188 9189 9190 |
# File 'lib/prism/node.rb', line 9188 def self.type :index_and_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.
9194 9195 9196 9197 9198 9199 9200 9201 9202 9203 9204 9205 |
# File 'lib/prism/node.rb', line 9194 def ===(other) other.is_a?(IndexAndWriteNode) && (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) && (operator_loc.nil? == other.operator_loc.nil?) && (value === other.value) end |
#accept(visitor) ⇒ Object
def accept: (Visitor visitor) -> void
9030 9031 9032 |
# File 'lib/prism/node.rb', line 9030 def accept(visitor) visitor.visit_index_and_write_node(self) end |
#attribute_write? ⇒ Boolean
def attribute_write?: () -> bool
9078 9079 9080 |
# File 'lib/prism/node.rb', line 9078 def attribute_write? flags.anybits?(CallNodeFlags::ATTRIBUTE_WRITE) end |
#call_operator ⇒ Object
def call_operator: () -> String?
9158 9159 9160 |
# File 'lib/prism/node.rb', line 9158 def call_operator call_operator_loc&.slice end |
#call_operator_loc ⇒ Object
attr_reader call_operator_loc: Location?
9091 9092 9093 9094 9095 9096 9097 9098 9099 9100 9101 |
# File 'lib/prism/node.rb', line 9091 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[nil | Node]
9035 9036 9037 |
# File 'lib/prism/node.rb', line 9035 def child_nodes [receiver, arguments, block, value] end |
#closing ⇒ Object
def closing: () -> String
9168 9169 9170 |
# File 'lib/prism/node.rb', line 9168 def closing closing_loc.slice end |
#closing_loc ⇒ Object
attr_reader closing_loc: Location
9126 9127 9128 9129 9130 |
# File 'lib/prism/node.rb', line 9126 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]
9050 9051 9052 |
# File 'lib/prism/node.rb', line 9050 def comment_targets [*receiver, *call_operator_loc, opening_loc, *arguments, closing_loc, *block, operator_loc, value] #: Array[Prism::node | Location] end |
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array
9040 9041 9042 9043 9044 9045 9046 9047 |
# File 'lib/prism/node.rb', line 9040 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, operator_loc: self.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?, ?operator_loc: Location, ?value: Prism::node) -> IndexAndWriteNode
9055 9056 9057 |
# File 'lib/prism/node.rb', line 9055 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, operator_loc: self.operator_loc, value: self.value) IndexAndWriteNode.new(source, node_id, location, flags, receiver, call_operator_loc, opening_loc, arguments, closing_loc, block, 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?, operator_loc: Location, value: Prism::node }
9063 9064 9065 |
# File 'lib/prism/node.rb', line 9063 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, operator_loc: operator_loc, value: value } end |
#ignore_visibility? ⇒ Boolean
def ignore_visibility?: () -> bool
9083 9084 9085 |
# File 'lib/prism/node.rb', line 9083 def ignore_visibility? flags.anybits?(CallNodeFlags::IGNORE_VISIBILITY) end |
#inspect ⇒ Object
def inspect -> String
9178 9179 9180 |
# File 'lib/prism/node.rb', line 9178 def inspect InspectVisitor.compose(self) end |
#opening ⇒ Object
def opening: () -> String
9163 9164 9165 |
# File 'lib/prism/node.rb', line 9163 def opening opening_loc.slice end |
#opening_loc ⇒ Object
attr_reader opening_loc: Location
9110 9111 9112 9113 9114 |
# File 'lib/prism/node.rb', line 9110 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
def operator: () -> String
9173 9174 9175 |
# File 'lib/prism/node.rb', line 9173 def operator operator_loc.slice end |
#operator_loc ⇒ Object
attr_reader operator_loc: Location
9142 9143 9144 9145 9146 |
# File 'lib/prism/node.rb', line 9142 def operator_loc location = @operator_loc return location if location.is_a?(Location) @operator_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#safe_navigation? ⇒ Boolean
def safe_navigation?: () -> bool
9068 9069 9070 |
# File 'lib/prism/node.rb', line 9068 def flags.anybits?(CallNodeFlags::SAFE_NAVIGATION) 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.
9105 9106 9107 |
# File 'lib/prism/node.rb', line 9105 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.
9134 9135 9136 |
# File 'lib/prism/node.rb', line 9134 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.
9118 9119 9120 |
# File 'lib/prism/node.rb', line 9118 def save_opening_loc(repository) repository.enter(node_id, :opening_loc) end |
#save_operator_loc(repository) ⇒ Object
Save the operator_loc location using the given saved source so that it can be retrieved later.
9150 9151 9152 |
# File 'lib/prism/node.rb', line 9150 def save_operator_loc(repository) repository.enter(node_id, :operator_loc) end |
#type ⇒ Object
Return a symbol representation of this node type. See ‘Node#type`.
9183 9184 9185 |
# File 'lib/prism/node.rb', line 9183 def type :index_and_write_node end |
#variable_call? ⇒ Boolean
def variable_call?: () -> bool
9073 9074 9075 |
# File 'lib/prism/node.rb', line 9073 def variable_call? flags.anybits?(CallNodeFlags::VARIABLE_CALL) end |