Class: Prism::CallTargetNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::CallTargetNode
- Defined in:
- lib/prism/node.rb,
sig/generated/prism/node.rbs,
ext/prism/api_node.c
Overview
Represents assigning to a method call.
foo.bar, = 1
^^^^^^^
begin
rescue => foo.bar
^^^^^^^
end
for foo.bar in baz do end
^^^^^^^
Class Method Summary collapse
-
.type ⇒ :call_target_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.
-
#call_operator ⇒ String
:call-seq: call_operator -> String.
-
#call_operator_loc ⇒ Location
:category: Locations :call-seq: call_operator_loc -> Location.
-
#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, name: self.name, message_loc: self.message_loc) ⇒ CallTargetNode
:call-seq: copy(**fields) -> CallTargetNode.
-
#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, name, message_loc) ⇒ CallTargetNode
constructor
Initialize a new CallTargetNode node.
-
#inspect ⇒ String
: () -> String.
-
#message ⇒ String
:call-seq: message -> String.
-
#message_loc ⇒ Location
:category: Locations :call-seq: message_loc -> Location.
-
#name ⇒ Symbol
:call-seq: name -> Symbol.
-
#receiver ⇒ Prism::node
:call-seq: receiver -> Node.
-
#safe_navigation? ⇒ Boolean
:category: Flags &.
-
#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_target_node
See
Node#type. -
#variable_call? ⇒ Boolean
:category: Flags a call that could have been a local variable.
Constructor Details
#initialize(source, node_id, location, flags, receiver, call_operator_loc, name, message_loc) ⇒ CallTargetNode
Initialize a new CallTargetNode node.
: (Source source, Integer node_id, Location location, Integer flags, Prism::node receiver, Location call_operator_loc, Symbol name, Location message_loc) -> void
5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 |
# File 'lib/prism/node.rb', line 5841 def initialize(source, node_id, location, flags, receiver, call_operator_loc, name, ) @source = source @node_id = node_id @location = location @flags = flags @receiver = receiver @call_operator_loc = call_operator_loc @name = name @message_loc = end |
Class Method Details
.type ⇒ :call_target_node
See Node.type.
: () -> :call_target_node
5934 5935 5936 |
# File 'lib/prism/node.rb', line 5934 def self.type :call_target_node end |
Instance Method Details
#===(other) ⇒ boolish
: (untyped other) -> boolish
6094 6095 6096 6097 6098 6099 6100 6101 |
# File 'lib/prism/node.rb', line 6094 def ===(other) # :nodoc: other.is_a?(CallTargetNode) && (flags === other.flags) && (receiver === other.receiver) && (call_operator_loc.nil? == other.call_operator_loc.nil?) && (name === other.name) && (.nil? == other..nil?) end |
#accept(visitor) ⇒ Object
See Node.accept.
: (_Visitor visitor) -> untyped
5866 5867 5868 |
# File 'lib/prism/node.rb', line 5866 def accept(visitor) visitor.visit_call_target_node(self) end |
#attribute_write? ⇒ Boolean
:category: Flags a call that is an attribute write, so the value being written should be returned
: () -> bool
5965 5966 5967 |
# File 'lib/prism/node.rb', line 5965 def attribute_write? flags.anybits?(CallNodeFlags::ATTRIBUTE_WRITE) end |
#call_operator ⇒ String
:call-seq:
call_operator -> String
Slice the location of call_operator_loc from the source.
: () -> String
6077 6078 6079 |
# File 'lib/prism/node.rb', line 6077 def call_operator call_operator_loc.slice end |
#call_operator_loc ⇒ Location
:category: Locations :call-seq:
call_operator_loc -> Location
Represents the Location of the call operator.
foo.bar = 1
^
: () -> Location
6008 6009 6010 6011 6012 |
# File 'lib/prism/node.rb', line 6008 def call_operator_loc location = @call_operator_loc return location if location.is_a?(Location) @call_operator_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#child_nodes ⇒ Array[node?] Also known as: deconstruct
See Node.child_nodes.
: () -> Array
5873 5874 5875 |
# File 'lib/prism/node.rb', line 5873 def child_nodes [receiver] end |
#compact_child_nodes ⇒ Array[node]
See Node.compact_child_nodes.
: () -> Array
5890 5891 5892 |
# File 'lib/prism/node.rb', line 5890 def compact_child_nodes [receiver] end |
#copy(node_id: self.node_id, location: self.location, flags: self.flags, receiver: self.receiver, call_operator_loc: self.call_operator_loc, name: self.name, message_loc: self.message_loc) ⇒ CallTargetNode
:call-seq:
copy(**fields) -> CallTargetNode
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, ?name: Symbol, ?message_loc: Location) -> CallTargetNode
5900 5901 5902 |
# File 'lib/prism/node.rb', line 5900 def copy(node_id: self.node_id, location: self.location, flags: self.flags, receiver: self.receiver, call_operator_loc: self.call_operator_loc, name: self.name, message_loc: self.) CallTargetNode.new(source, node_id, location, flags, receiver, call_operator_loc, name, ) end |
#deconstruct_keys(keys) ⇒ Hash[Symbol, untyped]
: (Array? keys) -> Hash[Symbol, untyped]
5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 |
# File 'lib/prism/node.rb', line 5907 def deconstruct_keys(keys) # :nodoc: (keys || %i[node_id location receiver call_operator_loc name message_loc 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 :name then deconstructed[:name] = self.name when :message_loc then deconstructed[:message_loc] = self. 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
5881 5882 5883 5884 5885 |
# File 'lib/prism/node.rb', line 5881 def each_child_node(&blk) return to_enum(:each_child_node) unless block_given? yield receiver end |
#ignore_visibility? ⇒ Boolean
:category: Flags a call that ignores method visibility
: () -> bool
5973 5974 5975 |
# File 'lib/prism/node.rb', line 5973 def ignore_visibility? flags.anybits?(CallNodeFlags::IGNORE_VISIBILITY) end |
#inspect ⇒ String
: () -> String
5939 5940 5941 |
# File 'lib/prism/node.rb', line 5939 def inspect # :nodoc: InspectVisitor.compose(self) end |
#message ⇒ String
:call-seq:
message -> String
Slice the location of message_loc from the source.
: () -> String
6087 6088 6089 |
# File 'lib/prism/node.rb', line 6087 def .slice end |
#message_loc ⇒ Location
:category: Locations :call-seq:
message_loc -> Location
Represents the Location of the message.
foo.bar = 1
^^^
: () -> Location
6054 6055 6056 6057 6058 |
# File 'lib/prism/node.rb', line 6054 def location = @message_loc return location if location.is_a?(Location) @message_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#name ⇒ Symbol
:call-seq:
name -> Symbol
Represents the name of the method being called.
foo.bar = 1 # name `:foo`
^^^
: () -> Symbol
6036 6037 6038 |
# File 'lib/prism/node.rb', line 6036 def name @name end |
#receiver ⇒ Prism::node
:call-seq:
receiver -> Node
The object that the method is being called on. This can be any non-void expression.
foo.bar = 1
^^^
: () -> Prism::node
5990 5991 5992 |
# File 'lib/prism/node.rb', line 5990 def receiver @receiver end |
#safe_navigation? ⇒ Boolean
:category: Flags &. operator
: () -> bool
5949 5950 5951 |
# File 'lib/prism/node.rb', line 5949 def flags.anybits?(CallNodeFlags::SAFE_NAVIGATION) 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
6019 6020 6021 |
# File 'lib/prism/node.rb', line 6019 def save_call_operator_loc(repository) repository.enter(node_id, :call_operator_loc) 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
6065 6066 6067 |
# File 'lib/prism/node.rb', line 6065 def (repository) repository.enter(node_id, :message_loc) end |
#type ⇒ :call_target_node
See Node#type.
: () -> :call_target_node
5927 5928 5929 |
# File 'lib/prism/node.rb', line 5927 def type :call_target_node end |
#variable_call? ⇒ Boolean
:category: Flags a call that could have been a local variable
: () -> bool
5957 5958 5959 |
# File 'lib/prism/node.rb', line 5957 def variable_call? flags.anybits?(CallNodeFlags::VARIABLE_CALL) end |