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: Prism::node?.
-
#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: Prism::node?, ?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: Prism::node?, 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.
7982 7983 7984 7985 7986 7987 7988 7989 7990 7991 7992 7993 7994 7995 |
# File 'lib/prism/node.rb', line 7982 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?
8079 8080 8081 |
# File 'lib/prism/node.rb', line 8079 def arguments @arguments end |
#block ⇒ Object (readonly)
attr_reader block: Prism::node?
8089 8090 8091 |
# File 'lib/prism/node.rb', line 8089 def block @block end |
#receiver ⇒ Object (readonly)
attr_reader receiver: Prism::node?
8056 8057 8058 |
# File 'lib/prism/node.rb', line 8056 def receiver @receiver end |
#value ⇒ Object (readonly)
attr_reader value: Prism::node
8099 8100 8101 |
# File 'lib/prism/node.rb', line 8099 def value @value end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See ‘Node::type`.
8132 8133 8134 |
# File 'lib/prism/node.rb', line 8132 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.
8138 8139 8140 8141 8142 8143 8144 8145 8146 8147 8148 8149 |
# File 'lib/prism/node.rb', line 8138 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
7998 7999 8000 |
# File 'lib/prism/node.rb', line 7998 def accept(visitor) visitor.visit_index_and_write_node(self) end |
#attribute_write? ⇒ Boolean
def attribute_write?: () -> bool
8046 8047 8048 |
# File 'lib/prism/node.rb', line 8046 def attribute_write? flags.anybits?(CallNodeFlags::ATTRIBUTE_WRITE) end |
#call_operator ⇒ Object
def call_operator: () -> String?
8102 8103 8104 |
# File 'lib/prism/node.rb', line 8102 def call_operator call_operator_loc&.slice end |
#call_operator_loc ⇒ Object
attr_reader call_operator_loc: Location?
8059 8060 8061 8062 8063 8064 8065 8066 8067 8068 8069 |
# File 'lib/prism/node.rb', line 8059 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]
8003 8004 8005 |
# File 'lib/prism/node.rb', line 8003 def child_nodes [receiver, arguments, block, value] end |
#closing ⇒ Object
def closing: () -> String
8112 8113 8114 |
# File 'lib/prism/node.rb', line 8112 def closing closing_loc.slice end |
#closing_loc ⇒ Object
attr_reader closing_loc: Location
8082 8083 8084 8085 8086 |
# File 'lib/prism/node.rb', line 8082 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]
8018 8019 8020 |
# File 'lib/prism/node.rb', line 8018 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
8008 8009 8010 8011 8012 8013 8014 8015 |
# File 'lib/prism/node.rb', line 8008 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: Prism::node?, ?operator_loc: Location, ?value: Prism::node) -> IndexAndWriteNode
8023 8024 8025 |
# File 'lib/prism/node.rb', line 8023 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: Prism::node?, operator_loc: Location, value: Prism::node }
8031 8032 8033 |
# File 'lib/prism/node.rb', line 8031 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
8051 8052 8053 |
# File 'lib/prism/node.rb', line 8051 def ignore_visibility? flags.anybits?(CallNodeFlags::IGNORE_VISIBILITY) end |
#inspect ⇒ Object
def inspect -> String
8122 8123 8124 |
# File 'lib/prism/node.rb', line 8122 def inspect InspectVisitor.compose(self) end |
#opening ⇒ Object
def opening: () -> String
8107 8108 8109 |
# File 'lib/prism/node.rb', line 8107 def opening opening_loc.slice end |
#opening_loc ⇒ Object
attr_reader opening_loc: Location
8072 8073 8074 8075 8076 |
# File 'lib/prism/node.rb', line 8072 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
8117 8118 8119 |
# File 'lib/prism/node.rb', line 8117 def operator operator_loc.slice end |
#operator_loc ⇒ Object
attr_reader operator_loc: Location
8092 8093 8094 8095 8096 |
# File 'lib/prism/node.rb', line 8092 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
8036 8037 8038 |
# File 'lib/prism/node.rb', line 8036 def flags.anybits?(CallNodeFlags::SAFE_NAVIGATION) end |
#type ⇒ Object
Return a symbol representation of this node type. See ‘Node#type`.
8127 8128 8129 |
# File 'lib/prism/node.rb', line 8127 def type :index_and_write_node end |
#variable_call? ⇒ Boolean
def variable_call?: () -> bool
8041 8042 8043 |
# File 'lib/prism/node.rb', line 8041 def variable_call? flags.anybits?(CallNodeFlags::VARIABLE_CALL) end |