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.
-
#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.
9153 9154 9155 9156 9157 9158 9159 9160 9161 9162 9163 9164 9165 9166 |
# File 'lib/prism/node.rb', line 9153 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?
9262 9263 9264 |
# File 'lib/prism/node.rb', line 9262 def arguments @arguments end |
#block ⇒ Object (readonly)
attr_reader block: BlockArgumentNode?
9278 9279 9280 |
# File 'lib/prism/node.rb', line 9278 def block @block end |
#receiver ⇒ Object (readonly)
attr_reader receiver: Prism::node?
9227 9228 9229 |
# File 'lib/prism/node.rb', line 9227 def receiver @receiver end |
#value ⇒ Object (readonly)
attr_reader value: Prism::node
9294 9295 9296 |
# File 'lib/prism/node.rb', line 9294 def value @value end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See ‘Node::type`.
9327 9328 9329 |
# File 'lib/prism/node.rb', line 9327 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.
9333 9334 9335 9336 9337 9338 9339 9340 9341 9342 9343 9344 |
# File 'lib/prism/node.rb', line 9333 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
9169 9170 9171 |
# File 'lib/prism/node.rb', line 9169 def accept(visitor) visitor.visit_index_and_write_node(self) end |
#attribute_write? ⇒ Boolean
def attribute_write?: () -> bool
9217 9218 9219 |
# File 'lib/prism/node.rb', line 9217 def attribute_write? flags.anybits?(CallNodeFlags::ATTRIBUTE_WRITE) end |
#call_operator ⇒ Object
def call_operator: () -> String?
9297 9298 9299 |
# File 'lib/prism/node.rb', line 9297 def call_operator call_operator_loc&.slice end |
#call_operator_loc ⇒ Object
attr_reader call_operator_loc: Location?
9230 9231 9232 9233 9234 9235 9236 9237 9238 9239 9240 |
# File 'lib/prism/node.rb', line 9230 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
9174 9175 9176 |
# File 'lib/prism/node.rb', line 9174 def child_nodes [receiver, arguments, block, value] end |
#closing ⇒ Object
def closing: () -> String
9307 9308 9309 |
# File 'lib/prism/node.rb', line 9307 def closing closing_loc.slice end |
#closing_loc ⇒ Object
attr_reader closing_loc: Location
9265 9266 9267 9268 9269 |
# File 'lib/prism/node.rb', line 9265 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]
9189 9190 9191 |
# File 'lib/prism/node.rb', line 9189 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
9179 9180 9181 9182 9183 9184 9185 9186 |
# File 'lib/prism/node.rb', line 9179 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
9194 9195 9196 |
# File 'lib/prism/node.rb', line 9194 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 }
9202 9203 9204 |
# File 'lib/prism/node.rb', line 9202 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
9222 9223 9224 |
# File 'lib/prism/node.rb', line 9222 def ignore_visibility? flags.anybits?(CallNodeFlags::IGNORE_VISIBILITY) end |
#inspect ⇒ Object
def inspect -> String
9317 9318 9319 |
# File 'lib/prism/node.rb', line 9317 def inspect InspectVisitor.compose(self) end |
#opening ⇒ Object
def opening: () -> String
9302 9303 9304 |
# File 'lib/prism/node.rb', line 9302 def opening opening_loc.slice end |
#opening_loc ⇒ Object
attr_reader opening_loc: Location
9249 9250 9251 9252 9253 |
# File 'lib/prism/node.rb', line 9249 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
9312 9313 9314 |
# File 'lib/prism/node.rb', line 9312 def operator operator_loc.slice end |
#operator_loc ⇒ Object
attr_reader operator_loc: Location
9281 9282 9283 9284 9285 |
# File 'lib/prism/node.rb', line 9281 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
9207 9208 9209 |
# File 'lib/prism/node.rb', line 9207 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.
9244 9245 9246 |
# File 'lib/prism/node.rb', line 9244 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.
9273 9274 9275 |
# File 'lib/prism/node.rb', line 9273 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.
9257 9258 9259 |
# File 'lib/prism/node.rb', line 9257 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.
9289 9290 9291 |
# File 'lib/prism/node.rb', line 9289 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`.
9322 9323 9324 |
# File 'lib/prism/node.rb', line 9322 def type :index_and_write_node end |
#variable_call? ⇒ Boolean
def variable_call?: () -> bool
9212 9213 9214 |
# File 'lib/prism/node.rb', line 9212 def variable_call? flags.anybits?(CallNodeFlags::VARIABLE_CALL) end |