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.
-
#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.
8019 8020 8021 8022 8023 8024 8025 8026 8027 8028 8029 8030 8031 8032 |
# File 'lib/prism/node.rb', line 8019 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?
8116 8117 8118 |
# File 'lib/prism/node.rb', line 8116 def arguments @arguments end |
#block ⇒ Object (readonly)
attr_reader block: BlockArgumentNode?
8126 8127 8128 |
# File 'lib/prism/node.rb', line 8126 def block @block end |
#receiver ⇒ Object (readonly)
attr_reader receiver: Prism::node?
8093 8094 8095 |
# File 'lib/prism/node.rb', line 8093 def receiver @receiver end |
#value ⇒ Object (readonly)
attr_reader value: Prism::node
8136 8137 8138 |
# File 'lib/prism/node.rb', line 8136 def value @value end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See ‘Node::type`.
8169 8170 8171 |
# File 'lib/prism/node.rb', line 8169 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.
8175 8176 8177 8178 8179 8180 8181 8182 8183 8184 8185 8186 |
# File 'lib/prism/node.rb', line 8175 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
8035 8036 8037 |
# File 'lib/prism/node.rb', line 8035 def accept(visitor) visitor.visit_index_and_write_node(self) end |
#attribute_write? ⇒ Boolean
def attribute_write?: () -> bool
8083 8084 8085 |
# File 'lib/prism/node.rb', line 8083 def attribute_write? flags.anybits?(CallNodeFlags::ATTRIBUTE_WRITE) end |
#call_operator ⇒ Object
def call_operator: () -> String?
8139 8140 8141 |
# File 'lib/prism/node.rb', line 8139 def call_operator call_operator_loc&.slice end |
#call_operator_loc ⇒ Object
attr_reader call_operator_loc: Location?
8096 8097 8098 8099 8100 8101 8102 8103 8104 8105 8106 |
# File 'lib/prism/node.rb', line 8096 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]
8040 8041 8042 |
# File 'lib/prism/node.rb', line 8040 def child_nodes [receiver, arguments, block, value] end |
#closing ⇒ Object
def closing: () -> String
8149 8150 8151 |
# File 'lib/prism/node.rb', line 8149 def closing closing_loc.slice end |
#closing_loc ⇒ Object
attr_reader closing_loc: Location
8119 8120 8121 8122 8123 |
# File 'lib/prism/node.rb', line 8119 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]
8055 8056 8057 |
# File 'lib/prism/node.rb', line 8055 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
8045 8046 8047 8048 8049 8050 8051 8052 |
# File 'lib/prism/node.rb', line 8045 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
8060 8061 8062 |
# File 'lib/prism/node.rb', line 8060 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 }
8068 8069 8070 |
# File 'lib/prism/node.rb', line 8068 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
8088 8089 8090 |
# File 'lib/prism/node.rb', line 8088 def ignore_visibility? flags.anybits?(CallNodeFlags::IGNORE_VISIBILITY) end |
#inspect ⇒ Object
def inspect -> String
8159 8160 8161 |
# File 'lib/prism/node.rb', line 8159 def inspect InspectVisitor.compose(self) end |
#opening ⇒ Object
def opening: () -> String
8144 8145 8146 |
# File 'lib/prism/node.rb', line 8144 def opening opening_loc.slice end |
#opening_loc ⇒ Object
attr_reader opening_loc: Location
8109 8110 8111 8112 8113 |
# File 'lib/prism/node.rb', line 8109 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
8154 8155 8156 |
# File 'lib/prism/node.rb', line 8154 def operator operator_loc.slice end |
#operator_loc ⇒ Object
attr_reader operator_loc: Location
8129 8130 8131 8132 8133 |
# File 'lib/prism/node.rb', line 8129 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
8073 8074 8075 |
# File 'lib/prism/node.rb', line 8073 def flags.anybits?(CallNodeFlags::SAFE_NAVIGATION) end |
#type ⇒ Object
Return a symbol representation of this node type. See ‘Node#type`.
8164 8165 8166 |
# File 'lib/prism/node.rb', line 8164 def type :index_and_write_node end |
#variable_call? ⇒ Boolean
def variable_call?: () -> bool
8078 8079 8080 |
# File 'lib/prism/node.rb', line 8078 def variable_call? flags.anybits?(CallNodeFlags::VARIABLE_CALL) end |