Class: Prism::KeywordRestParameterNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::KeywordRestParameterNode
- Defined in:
- lib/prism/node.rb,
ext/prism/api_node.c
Overview
Represents a keyword 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) -> KeywordRestParameterNode.
-
#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) ⇒ KeywordRestParameterNode
constructor
Initialize a new KeywordRestParameterNode 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) ⇒ KeywordRestParameterNode
Initialize a new KeywordRestParameterNode node.
11555 11556 11557 11558 11559 11560 11561 11562 11563 |
# File 'lib/prism/node.rb', line 11555 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?
11604 11605 11606 |
# File 'lib/prism/node.rb', line 11604 def name @name end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See ‘Node::type`.
11654 11655 11656 |
# File 'lib/prism/node.rb', line 11654 def self.type :keyword_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.
11660 11661 11662 11663 11664 11665 11666 |
# File 'lib/prism/node.rb', line 11660 def ===(other) other.is_a?(KeywordRestParameterNode) && (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
11566 11567 11568 |
# File 'lib/prism/node.rb', line 11566 def accept(visitor) visitor.visit_keyword_rest_parameter_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array
11571 11572 11573 |
# File 'lib/prism/node.rb', line 11571 def child_nodes [] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
11581 11582 11583 |
# File 'lib/prism/node.rb', line 11581 def comment_targets [*name_loc, operator_loc] #: Array[Prism::node | Location] end |
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array
11576 11577 11578 |
# File 'lib/prism/node.rb', line 11576 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) -> KeywordRestParameterNode
11586 11587 11588 |
# File 'lib/prism/node.rb', line 11586 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) KeywordRestParameterNode.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 }
11594 11595 11596 |
# File 'lib/prism/node.rb', line 11594 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
11644 11645 11646 |
# File 'lib/prism/node.rb', line 11644 def inspect InspectVisitor.compose(self) end |
#name_loc ⇒ Object
attr_reader name_loc: Location?
11607 11608 11609 11610 11611 11612 11613 11614 11615 11616 11617 |
# File 'lib/prism/node.rb', line 11607 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
11639 11640 11641 |
# File 'lib/prism/node.rb', line 11639 def operator operator_loc.slice end |
#operator_loc ⇒ Object
attr_reader operator_loc: Location
11626 11627 11628 11629 11630 |
# File 'lib/prism/node.rb', line 11626 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
11599 11600 11601 |
# File 'lib/prism/node.rb', line 11599 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.
11621 11622 11623 |
# File 'lib/prism/node.rb', line 11621 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.
11634 11635 11636 |
# File 'lib/prism/node.rb', line 11634 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`.
11649 11650 11651 |
# File 'lib/prism/node.rb', line 11649 def type :keyword_rest_parameter_node end |