Class: Prism::CallNode
| Relationships & Source Files | |
| Super Chains via Extension / Inclusion / Inheritance | |
|
Class Chain:
self,
PrismNode
|
|
|
Instance Chain:
self,
PrismNode
|
|
| Inherits: |
PrismNode
|
| Defined in: | lib/prism/node.rb, ext/prism/api_node.c, lib/prism/node_ext.rb |
Overview
Represents a method call, in all of the various forms that can take.
foo
^^^
foo()
^^^^^
+foo
^^^^
foo +
^^^^^^^^^
foo.
^^^^^^^
foo&.
^^^^^^^^
Class Method Summary
-
.new(source, node_id, location, flags, receiver, call_operator_loc, name, message_loc, opening_loc, arguments, closing_loc, block) ⇒ CallNode
constructor
Initialize a new
CallNodenode. -
.type
Return a symbol representation of this node type.
Instance Attribute Summary
-
#arguments
readonly
attr_reader arguments: ArgumentsNode?
-
#attribute_write? ⇒ Boolean
readonly
def attribute_write?: () -> bool.
-
#block
readonly
attr_reader block:
Prism.node? -
#ignore_visibility? ⇒ Boolean
readonly
def ignore_visibility?: () -> bool.
-
#name
readonly
attr_reader name: Symbol.
-
#receiver
readonly
The object that the method is being called on.
-
#safe_navigation? ⇒ Boolean
readonly
def safe_navigation?: () -> bool.
-
#variable_call? ⇒ Boolean
readonly
def variable_call?: () -> bool.
Instance Method Summary
-
#===(other)
Implements case-equality for the node.
-
#accept(visitor)
def accept: (Visitor visitor) -> void.
-
#call_operator
def call_operator: () -> String?
-
#call_operator_loc
attr_reader call_operator_loc: Location?
-
#child_nodes
(also: #deconstruct)
def child_nodes: () -> Array[nil | Node].
-
#closing
def closing: () -> String?
-
#closing_loc
attr_reader closing_loc: Location?
-
#comment_targets
def comment_targets: () -> Array[Node | Location].
-
#compact_child_nodes
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, name: self.name, message_loc: self.message_loc, opening_loc: self.opening_loc, arguments: self.arguments, closing_loc: self.closing_loc, block: self.block)
def copy: (?node_id: Integer, ?location:
Location, ?flags: Integer, ?receiver:Prism.node?, ?call_operator_loc: Location?, ?name: Symbol, ?message_loc: Location?, ?opening_loc: Location?, ?arguments: ArgumentsNode?, ?closing_loc: Location?, ?block:Prism.node?) ->CallNode. -
#deconstruct
Alias for #child_nodes.
- #deconstruct_keys(keys)
-
#full_message_loc
When a call node has the attribute_write flag set, it means that the call is using the attribute write syntax.
-
#inspect
def inspect -> String.
-
#message
def message: () -> String?
-
#message_loc
attr_reader message_loc: Location?
-
#opening
def opening: () -> String?
-
#opening_loc
attr_reader opening_loc: Location?
-
#type
Return a symbol representation of this node type.
Constructor Details
.new(source, node_id, location, flags, receiver, call_operator_loc, name, message_loc, opening_loc, arguments, closing_loc, block) ⇒ CallNode
Initialize a new CallNode node.
# File 'lib/prism/node.rb', line 2165
def initialize(source, node_id, location, flags, receiver, call_operator_loc, name, , opening_loc, arguments, closing_loc, block) @source = source @node_id = node_id @location = location @flags = flags @receiver = receiver @call_operator_loc = call_operator_loc @name = name @message_loc = @opening_loc = opening_loc @arguments = arguments @closing_loc = closing_loc @block = block end
Class Method Details
.type
Return a symbol representation of this node type. See Node::type.
# File 'lib/prism/node.rb', line 2337
def self.type :call_node end
Instance Attribute Details
#arguments (readonly)
attr_reader arguments: ArgumentsNode?
# File 'lib/prism/node.rb', line 2290
attr_reader :arguments
#attribute_write? ⇒ Boolean (readonly)
def attribute_write?: () -> bool
# File 'lib/prism/node.rb', line 2228
def attribute_write? flags.anybits?(CallNodeFlags::ATTRIBUTE_WRITE) end
#block (readonly)
attr_reader block: Prism.node?
# File 'lib/prism/node.rb', line 2305
attr_reader :block
#ignore_visibility? ⇒ Boolean (readonly)
def ignore_visibility?: () -> bool
# File 'lib/prism/node.rb', line 2233
def ignore_visibility? flags.anybits?(CallNodeFlags::IGNORE_VISIBILITY) end
#name (readonly)
attr_reader name: Symbol
# File 'lib/prism/node.rb', line 2262
attr_reader :name
#receiver (readonly)
The object that the method is being called on. This can be either nil or anynon-void expression.
foo.
^^^
+foo
^^^
foo +
^^^
# File 'lib/prism/node.rb', line 2247
attr_reader :receiver
#variable_call? ⇒ Boolean (readonly)
def variable_call?: () -> bool
# File 'lib/prism/node.rb', line 2223
def variable_call? flags.anybits?(CallNodeFlags::VARIABLE_CALL) end
Instance Method Details
#===(other)
Implements case-equality for the node. This is effectively == but without comparing the value of locations. Locations are checked only for presence.
# File 'lib/prism/node.rb', line 2343
def ===(other) other.is_a?(CallNode) && (flags === other.flags) && (receiver === other.receiver) && (call_operator_loc.nil? == other.call_operator_loc.nil?) && (name === other.name) && (.nil? == other..nil?) && (opening_loc.nil? == other.opening_loc.nil?) && (arguments === other.arguments) && (closing_loc.nil? == other.closing_loc.nil?) && (block === other.block) end
#accept(visitor)
def accept: (Visitor visitor) -> void
# File 'lib/prism/node.rb', line 2181
def accept(visitor) visitor.visit_call_node(self) end
#call_operator
def call_operator: () -> String?
# File 'lib/prism/node.rb', line 2307
def call_operator call_operator_loc&.slice end
#call_operator_loc
attr_reader call_operator_loc: Location?
#child_nodes Also known as: #deconstruct
def child_nodes: () -> Array[nil | Node]
#closing
def closing: () -> String?
# File 'lib/prism/node.rb', line 2322
def closing closing_loc&.slice end
#closing_loc
attr_reader closing_loc: Location?
#comment_targets
def comment_targets: () -> Array[Node | Location]
# File 'lib/prism/node.rb', line 2200
def comment_targets [*receiver, *call_operator_loc, *, *opening_loc, *arguments, *closing_loc, *block] #: Array[Prism::node | Location] end
#compact_child_nodes
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, name: self.name, message_loc: self.message_loc, opening_loc: self.opening_loc, arguments: self.arguments, closing_loc: self.closing_loc, block: self.block)
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism.node?, ?call_operator_loc: Location?, ?name: Symbol, ?message_loc: Location?, ?opening_loc: Location?, ?arguments: ArgumentsNode?, ?closing_loc: Location?, ?block: Prism.node?) -> CallNode
# File 'lib/prism/node.rb', line 2205
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., opening_loc: self.opening_loc, arguments: self.arguments, closing_loc: self.closing_loc, block: self.block) CallNode.new(source, node_id, location, flags, receiver, call_operator_loc, name, , opening_loc, arguments, closing_loc, block) end
#deconstruct
Alias for #child_nodes.
# File 'lib/prism/node.rb', line 2210
alias deconstruct child_nodes
#deconstruct_keys(keys)
# File 'lib/prism/node.rb', line 2213
def deconstruct_keys(keys) { node_id: node_id, location: location, receiver: receiver, call_operator_loc: call_operator_loc, name: name, message_loc: , opening_loc: opening_loc, arguments: arguments, closing_loc: closing_loc, block: block } end
#full_message_loc
When a call node has the attribute_write flag set, it means that the call is using the attribute write syntax. This is either a method call to []= or a method call to a method that ends with =. Either way, the = sign is present in the source.
::Prism returns the message_loc without the = sign attached, because there
can be any amount of space between the message and the = sign. However,
sometimes you want the location of the full message including the inner
space and the = sign. This method provides that.
# File 'lib/prism/node_ext.rb', line 334
def attribute_write? ? &.adjoin("=") : end
#inspect
def inspect -> String
# File 'lib/prism/node.rb', line 2327
def inspect InspectVisitor.compose(self) end
#message
def message: () -> String?
# File 'lib/prism/node.rb', line 2312
def &.slice end
#message_loc
attr_reader message_loc: Location?
#opening
def opening: () -> String?
# File 'lib/prism/node.rb', line 2317
def opening opening_loc&.slice end
#opening_loc
attr_reader opening_loc: Location?
#type
Return a symbol representation of this node type. See Node#type.
# File 'lib/prism/node.rb', line 2332
def type :call_node end