Class: Prism::CallOperatorWriteNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::CallOperatorWriteNode
- Defined in:
- lib/prism/node.rb,
sig/generated/prism/node.rbs,
ext/prism/api_node.c
Overview
Represents the use of an assignment operator on a call.
foo.bar += baz
^^^^^^^^^^^^^^
Class Method Summary collapse
-
.type ⇒ :call_operator_write_node
See
Node.type.
Instance Method Summary collapse
-
#===(other) ⇒ boolish
: (untyped other) -> boolish.
-
#accept(visitor) ⇒ Object
See Node.accept.
-
#attribute_write? ⇒ Boolean
:category: Flags a call that is an attribute write, so the value being written should be returned.
-
#binary_operator ⇒ Symbol
:call-seq: binary_operator -> Symbol.
-
#binary_operator_loc ⇒ Location
:category: Locations :call-seq: binary_operator_loc -> Location.
-
#call_operator ⇒ String?
:call-seq: call_operator -> String | nil.
-
#call_operator_loc ⇒ Location?
:category: Locations :call-seq: call_operator_loc -> Location | nil.
-
#child_nodes ⇒ Array[node?]
(also: #deconstruct)
See Node.child_nodes.
-
#compact_child_nodes ⇒ Array[node]
See Node.compact_child_nodes.
-
#copy(node_id: self.node_id, location: self.location, flags: self.flags, receiver: self.receiver, call_operator_loc: self.call_operator_loc, message_loc: self.message_loc, read_name: self.read_name, write_name: self.write_name, binary_operator: self.binary_operator, binary_operator_loc: self.binary_operator_loc, value: self.value) ⇒ CallOperatorWriteNode
:call-seq: copy(**fields) -> CallOperatorWriteNode.
-
#deconstruct_keys(keys) ⇒ Hash[Symbol, untyped]
: (Array? keys) -> Hash[Symbol, untyped].
-
#each_child_node {|arg0| ... } ⇒ Object
See Node.each_child_node.
-
#ignore_visibility? ⇒ Boolean
:category: Flags a call that ignores method visibility.
-
#initialize(source, node_id, location, flags, receiver, call_operator_loc, message_loc, read_name, write_name, binary_operator, binary_operator_loc, value) ⇒ CallOperatorWriteNode
constructor
Initialize a new CallOperatorWriteNode node.
-
#inspect ⇒ String
: () -> String.
-
#message ⇒ String?
:call-seq: message -> String | nil.
-
#message_loc ⇒ Location?
:category: Locations :call-seq: message_loc -> Location | nil.
-
#read_name ⇒ Symbol
:call-seq: read_name -> Symbol.
-
#receiver ⇒ Prism::node?
:call-seq: receiver -> Node | nil.
-
#safe_navigation? ⇒ Boolean
:category: Flags &.
-
#save_binary_operator_loc(repository) ⇒ Relocation::Entry
:category: Repository Save the binary_operator_loc location using the given saved source so that it can be retrieved later.
-
#save_call_operator_loc(repository) ⇒ Relocation::Entry?
:category: Repository Save the call_operator_loc location using the given saved source so that it can be retrieved later.
-
#save_message_loc(repository) ⇒ Relocation::Entry?
:category: Repository Save the message_loc location using the given saved source so that it can be retrieved later.
-
#type ⇒ :call_operator_write_node
See
Node#type. -
#value ⇒ Prism::node
:call-seq: value -> Node.
-
#variable_call? ⇒ Boolean
:category: Flags a call that could have been a local variable.
-
#write_name ⇒ Symbol
:call-seq: write_name -> Symbol.
Constructor Details
#initialize(source, node_id, location, flags, receiver, call_operator_loc, message_loc, read_name, write_name, binary_operator, binary_operator_loc, value) ⇒ CallOperatorWriteNode
Initialize a new CallOperatorWriteNode node.
: (Source source, Integer node_id, Location location, Integer flags, Prism::node? receiver, Location? call_operator_loc, Location? message_loc, Symbol read_name, Symbol write_name, Symbol binary_operator, Location binary_operator_loc, Prism::node value) -> void
5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 |
# File 'lib/prism/node.rb', line 5067 def initialize(source, node_id, location, flags, receiver, call_operator_loc, , read_name, write_name, binary_operator, binary_operator_loc, value) @source = source @node_id = node_id @location = location @flags = flags @receiver = receiver @call_operator_loc = call_operator_loc @message_loc = @read_name = read_name @write_name = write_name @binary_operator = binary_operator @binary_operator_loc = binary_operator_loc @value = value end |
Class Method Details
.type ⇒ :call_operator_write_node
See Node.type.
: () -> :call_operator_write_node
5172 5173 5174 |
# File 'lib/prism/node.rb', line 5172 def self.type :call_operator_write_node end |
Instance Method Details
#===(other) ⇒ boolish
: (untyped other) -> boolish
5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 |
# File 'lib/prism/node.rb', line 5422 def ===(other) # :nodoc: other.is_a?(CallOperatorWriteNode) && (flags === other.flags) && (receiver === other.receiver) && (call_operator_loc.nil? == other.call_operator_loc.nil?) && (.nil? == other..nil?) && (read_name === other.read_name) && (write_name === other.write_name) && (binary_operator === other.binary_operator) && (binary_operator_loc.nil? == other.binary_operator_loc.nil?) && (value === other.value) end |
#accept(visitor) ⇒ Object
See Node.accept.
: (_Visitor visitor) -> untyped
5096 5097 5098 |
# File 'lib/prism/node.rb', line 5096 def accept(visitor) visitor.visit_call_operator_write_node(self) end |
#attribute_write? ⇒ Boolean
:category: Flags a call that is an attribute write, so the value being written should be returned
: () -> bool
5203 5204 5205 |
# File 'lib/prism/node.rb', line 5203 def attribute_write? flags.anybits?(CallNodeFlags::ATTRIBUTE_WRITE) end |
#binary_operator ⇒ Symbol
:call-seq:
binary_operator -> Symbol
Represents the binary operator being used.
foo.bar += value # binary_operator `:+`
^
: () -> Symbol
5347 5348 5349 |
# File 'lib/prism/node.rb', line 5347 def binary_operator @binary_operator end |
#binary_operator_loc ⇒ Location
:category: Locations :call-seq:
binary_operator_loc -> Location
Represents the Location of the binary operator.
foo.bar += value
^^
: () -> Location
5365 5366 5367 5368 5369 |
# File 'lib/prism/node.rb', line 5365 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 ⇒ String?
:call-seq:
call_operator -> String | nil
Slice the location of call_operator_loc from the source.
: () -> String?
5405 5406 5407 |
# File 'lib/prism/node.rb', line 5405 def call_operator call_operator_loc&.slice end |
#call_operator_loc ⇒ Location?
:category: Locations :call-seq:
call_operator_loc -> Location | nil
Represents the Location of the call operator.
foo.bar += value
^
: () -> Location?
5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 |
# File 'lib/prism/node.rb', line 5246 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 ⇒ Array[node?] Also known as: deconstruct
See Node.child_nodes.
: () -> Array
5103 5104 5105 |
# File 'lib/prism/node.rb', line 5103 def child_nodes [receiver, value] end |
#compact_child_nodes ⇒ Array[node]
See Node.compact_child_nodes.
: () -> Array
5121 5122 5123 5124 5125 5126 |
# File 'lib/prism/node.rb', line 5121 def compact_child_nodes compact = [] #: Array[Prism::node] if (receiver = self.receiver); compact << receiver; end 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, message_loc: self.message_loc, read_name: self.read_name, write_name: self.write_name, binary_operator: self.binary_operator, binary_operator_loc: self.binary_operator_loc, value: self.value) ⇒ CallOperatorWriteNode
:call-seq:
copy(**fields) -> CallOperatorWriteNode
Creates a copy of self with the given fields, using self as the template.
: (?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node?, ?call_operator_loc: Location?, ?message_loc: Location?, ?read_name: Symbol, ?write_name: Symbol, ?binary_operator: Symbol, ?binary_operator_loc: Location, ?value: Prism::node) -> CallOperatorWriteNode
5134 5135 5136 |
# File 'lib/prism/node.rb', line 5134 def copy(node_id: self.node_id, location: self.location, flags: self.flags, receiver: self.receiver, call_operator_loc: self.call_operator_loc, message_loc: self., read_name: self.read_name, write_name: self.write_name, binary_operator: self.binary_operator, binary_operator_loc: self.binary_operator_loc, value: self.value) CallOperatorWriteNode.new(source, node_id, location, flags, receiver, call_operator_loc, , read_name, write_name, binary_operator, binary_operator_loc, value) end |
#deconstruct_keys(keys) ⇒ Hash[Symbol, untyped]
: (Array? keys) -> Hash[Symbol, untyped]
5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 |
# File 'lib/prism/node.rb', line 5141 def deconstruct_keys(keys) # :nodoc: (keys || %i[node_id location receiver call_operator_loc message_loc read_name write_name binary_operator binary_operator_loc value call_operator message]).each_with_object( {} #: Hash[Symbol, untyped] ) do |key, deconstructed| case key when :node_id then deconstructed[:node_id] = self.node_id when :location then deconstructed[:location] = self.location when :receiver then deconstructed[:receiver] = self.receiver when :call_operator_loc then deconstructed[:call_operator_loc] = self.call_operator_loc when :message_loc then deconstructed[:message_loc] = self. when :read_name then deconstructed[:read_name] = self.read_name when :write_name then deconstructed[:write_name] = self.write_name when :binary_operator then deconstructed[:binary_operator] = self.binary_operator when :binary_operator_loc then deconstructed[:binary_operator_loc] = self.binary_operator_loc when :value then deconstructed[:value] = self.value when :call_operator then deconstructed[:call_operator] = self.call_operator when :message then deconstructed[:message] = self. end end end |
#each_child_node ⇒ Enumerator[node, void] #each_child_node ⇒ void
See Node.each_child_node.
: () -> Enumerator[node, void] : () { (node) -> void } -> void
5111 5112 5113 5114 5115 5116 |
# File 'lib/prism/node.rb', line 5111 def each_child_node(&blk) return to_enum(:each_child_node) unless block_given? if (receiver = self.receiver); yield receiver; end yield value end |
#ignore_visibility? ⇒ Boolean
:category: Flags a call that ignores method visibility
: () -> bool
5211 5212 5213 |
# File 'lib/prism/node.rb', line 5211 def ignore_visibility? flags.anybits?(CallNodeFlags::IGNORE_VISIBILITY) end |
#inspect ⇒ String
: () -> String
5177 5178 5179 |
# File 'lib/prism/node.rb', line 5177 def inspect # :nodoc: InspectVisitor.compose(self) end |
#message ⇒ String?
:call-seq:
message -> String | nil
Slice the location of message_loc from the source.
: () -> String?
5415 5416 5417 |
# File 'lib/prism/node.rb', line 5415 def &.slice end |
#message_loc ⇒ Location?
:category: Locations :call-seq:
message_loc -> Location | nil
Represents the Location of the message.
foo.bar += value
^^^
: () -> Location?
5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 |
# File 'lib/prism/node.rb', line 5280 def location = @message_loc case location when nil nil when Location location else @message_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end end |
#read_name ⇒ Symbol
:call-seq:
read_name -> Symbol
Represents the name of the method being called.
foo.bar += value # read_name `:bar`
^^^
: () -> Symbol
5313 5314 5315 |
# File 'lib/prism/node.rb', line 5313 def read_name @read_name end |
#receiver ⇒ Prism::node?
:call-seq:
receiver -> Node | nil
The object that the method is being called on. This can be either nil or any non-void expressions.
foo.bar += value
^^^
: () -> Prism::node?
5228 5229 5230 |
# File 'lib/prism/node.rb', line 5228 def receiver @receiver end |
#safe_navigation? ⇒ Boolean
:category: Flags &. operator
: () -> bool
5187 5188 5189 |
# File 'lib/prism/node.rb', line 5187 def flags.anybits?(CallNodeFlags::SAFE_NAVIGATION) end |
#save_binary_operator_loc(repository) ⇒ Relocation::Entry
:category: Repository Save the binary_operator_loc location using the given saved source so that it can be retrieved later.
: (_Repository repository) -> Relocation::Entry
5376 5377 5378 |
# File 'lib/prism/node.rb', line 5376 def save_binary_operator_loc(repository) repository.enter(node_id, :binary_operator_loc) end |
#save_call_operator_loc(repository) ⇒ Relocation::Entry?
:category: Repository Save the call_operator_loc location using the given saved source so that it can be retrieved later.
: (_Repository repository) -> Relocation::Entry?
5263 5264 5265 |
# File 'lib/prism/node.rb', line 5263 def save_call_operator_loc(repository) repository.enter(node_id, :call_operator_loc) unless @call_operator_loc.nil? end |
#save_message_loc(repository) ⇒ Relocation::Entry?
:category: Repository Save the message_loc location using the given saved source so that it can be retrieved later.
: (_Repository repository) -> Relocation::Entry?
5297 5298 5299 |
# File 'lib/prism/node.rb', line 5297 def (repository) repository.enter(node_id, :message_loc) unless @message_loc.nil? end |
#type ⇒ :call_operator_write_node
See Node#type.
: () -> :call_operator_write_node
5165 5166 5167 |
# File 'lib/prism/node.rb', line 5165 def type :call_operator_write_node end |
#value ⇒ Prism::node
:call-seq:
value -> Node
Represents the value being assigned.
foo.bar += value
^^^^^
: () -> Prism::node
5393 5394 5395 |
# File 'lib/prism/node.rb', line 5393 def value @value end |
#variable_call? ⇒ Boolean
:category: Flags a call that could have been a local variable
: () -> bool
5195 5196 5197 |
# File 'lib/prism/node.rb', line 5195 def variable_call? flags.anybits?(CallNodeFlags::VARIABLE_CALL) end |
#write_name ⇒ Symbol
:call-seq:
write_name -> Symbol
Represents the name of the method being written to.
foo.bar += value # write_name `:bar=`
^^^
: () -> Symbol
5330 5331 5332 |
# File 'lib/prism/node.rb', line 5330 def write_name @write_name end |