Class: Prism::RestParameterNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::RestParameterNode
- Defined in:
- lib/prism/node.rb,
ext/prism/api_node.c
Overview
Represents a rest parameter to a method, block, or lambda definition.
def a(*b)
^^
end
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
attr_reader name: Symbol?.
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.
-
#child_nodes ⇒ Object
(also: #deconstruct)
def child_nodes: () -> Array.
-
#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, name: self.name, name_loc: self.name_loc, operator_loc: self.operator_loc) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol?, ?name_loc: Location?, ?operator_loc: Location) -> RestParameterNode.
-
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, name: Symbol?, name_loc: Location?, operator_loc: Location }.
-
#initialize(source, node_id, location, flags, name, name_loc, operator_loc) ⇒ RestParameterNode
constructor
Initialize a new RestParameterNode node.
-
#inspect ⇒ Object
def inspect -> String.
-
#name_loc ⇒ Object
attr_reader name_loc: Location?.
-
#operator ⇒ Object
def operator: () -> String.
-
#operator_loc ⇒ Object
attr_reader operator_loc: Location.
-
#repeated_parameter? ⇒ Boolean
def repeated_parameter?: () -> bool.
-
#save_name_loc(repository) ⇒ Object
Save the name_loc location using the given saved source so that it can be retrieved later.
-
#save_operator_loc(repository) ⇒ Object
Save the operator_loc location using the given saved source so that it can be retrieved later.
-
#type ⇒ Object
Return a symbol representation of this node type.
Constructor Details
#initialize(source, node_id, location, flags, name, name_loc, operator_loc) ⇒ RestParameterNode
Initialize a new RestParameterNode node.
16056 16057 16058 16059 16060 16061 16062 16063 16064 |
# File 'lib/prism/node.rb', line 16056 def initialize(source, node_id, location, flags, name, name_loc, operator_loc) @source = source @node_id = node_id @location = location @flags = flags @name = name @name_loc = name_loc @operator_loc = operator_loc end |
Instance Attribute Details
#name ⇒ Object (readonly)
attr_reader name: Symbol?
16105 16106 16107 |
# File 'lib/prism/node.rb', line 16105 def name @name end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See ‘Node::type`.
16155 16156 16157 |
# File 'lib/prism/node.rb', line 16155 def self.type :rest_parameter_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.
16161 16162 16163 16164 16165 16166 16167 |
# File 'lib/prism/node.rb', line 16161 def ===(other) other.is_a?(RestParameterNode) && (flags === other.flags) && (name === other.name) && (name_loc.nil? == other.name_loc.nil?) && (operator_loc.nil? == other.operator_loc.nil?) end |
#accept(visitor) ⇒ Object
def accept: (Visitor visitor) -> void
16067 16068 16069 |
# File 'lib/prism/node.rb', line 16067 def accept(visitor) visitor.visit_rest_parameter_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array
16072 16073 16074 |
# File 'lib/prism/node.rb', line 16072 def child_nodes [] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
16082 16083 16084 |
# File 'lib/prism/node.rb', line 16082 def comment_targets [*name_loc, operator_loc] #: Array[Prism::node | Location] end |
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array
16077 16078 16079 |
# File 'lib/prism/node.rb', line 16077 def compact_child_nodes [] end |
#copy(node_id: self.node_id, location: self.location, flags: self.flags, name: self.name, name_loc: self.name_loc, operator_loc: self.operator_loc) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol?, ?name_loc: Location?, ?operator_loc: Location) -> RestParameterNode
16087 16088 16089 |
# File 'lib/prism/node.rb', line 16087 def copy(node_id: self.node_id, location: self.location, flags: self.flags, name: self.name, name_loc: self.name_loc, operator_loc: self.operator_loc) RestParameterNode.new(source, node_id, location, flags, name, name_loc, operator_loc) end |
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, name: Symbol?, name_loc: Location?, operator_loc: Location }
16095 16096 16097 |
# File 'lib/prism/node.rb', line 16095 def deconstruct_keys(keys) { node_id: node_id, location: location, name: name, name_loc: name_loc, operator_loc: operator_loc } end |
#inspect ⇒ Object
def inspect -> String
16145 16146 16147 |
# File 'lib/prism/node.rb', line 16145 def inspect InspectVisitor.compose(self) end |
#name_loc ⇒ Object
attr_reader name_loc: Location?
16108 16109 16110 16111 16112 16113 16114 16115 16116 16117 16118 |
# File 'lib/prism/node.rb', line 16108 def name_loc location = @name_loc case location when nil nil when Location location else @name_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end end |
#operator ⇒ Object
def operator: () -> String
16140 16141 16142 |
# File 'lib/prism/node.rb', line 16140 def operator operator_loc.slice end |
#operator_loc ⇒ Object
attr_reader operator_loc: Location
16127 16128 16129 16130 16131 |
# File 'lib/prism/node.rb', line 16127 def operator_loc location = @operator_loc return location if location.is_a?(Location) @operator_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#repeated_parameter? ⇒ Boolean
def repeated_parameter?: () -> bool
16100 16101 16102 |
# File 'lib/prism/node.rb', line 16100 def repeated_parameter? flags.anybits?(ParameterFlags::REPEATED_PARAMETER) end |
#save_name_loc(repository) ⇒ Object
Save the name_loc location using the given saved source so that it can be retrieved later.
16122 16123 16124 |
# File 'lib/prism/node.rb', line 16122 def save_name_loc(repository) repository.enter(node_id, :name_loc) unless @name_loc.nil? end |
#save_operator_loc(repository) ⇒ Object
Save the operator_loc location using the given saved source so that it can be retrieved later.
16135 16136 16137 |
# File 'lib/prism/node.rb', line 16135 def save_operator_loc(repository) repository.enter(node_id, :operator_loc) end |
#type ⇒ Object
Return a symbol representation of this node type. See ‘Node#type`.
16150 16151 16152 |
# File 'lib/prism/node.rb', line 16150 def type :rest_parameter_node end |