Class: Prism::SplatNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::SplatNode
- Defined in:
- lib/prism/node.rb,
ext/prism/api_node.c
Overview
Represents the use of the splat operator.
[*a]
^^
Instance Attribute Summary collapse
-
#expression ⇒ Object
readonly
attr_reader expression: Prism::node?.
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, operator_loc: self.operator_loc, expression: self.expression) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?operator_loc: Location, ?expression: Prism::node?) -> SplatNode.
-
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, operator_loc: Location, expression: Prism::node? }.
-
#each_child_node {|expression| ... } ⇒ Object
def each_child_node: () { (Prism::node) -> void } -> void | () -> Enumerator.
-
#initialize(source, node_id, location, flags, operator_loc, expression) ⇒ SplatNode
constructor
Initialize a new SplatNode node.
-
#inspect ⇒ Object
def inspect -> String.
-
#operator ⇒ Object
def operator: () -> String.
-
#operator_loc ⇒ Object
attr_reader operator_loc: Location.
-
#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, operator_loc, expression) ⇒ SplatNode
Initialize a new SplatNode node.
17929 17930 17931 17932 17933 17934 17935 17936 |
# File 'lib/prism/node.rb', line 17929 def initialize(source, node_id, location, flags, operator_loc, expression) @source = source @node_id = node_id @location = location @flags = flags @operator_loc = operator_loc @expression = expression end |
Instance Attribute Details
#expression ⇒ Object (readonly)
attr_reader expression: Prism::node?
17994 17995 17996 |
# File 'lib/prism/node.rb', line 17994 def expression @expression end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See Node::type.
18012 18013 18014 |
# File 'lib/prism/node.rb', line 18012 def self.type :splat_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.
18018 18019 18020 18021 18022 |
# File 'lib/prism/node.rb', line 18018 def ===(other) other.is_a?(SplatNode) && (operator_loc.nil? == other.operator_loc.nil?) && (expression === other.expression) end |
#accept(visitor) ⇒ Object
def accept: (Visitor visitor) -> void
17939 17940 17941 |
# File 'lib/prism/node.rb', line 17939 def accept(visitor) visitor.visit_splat_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array
17944 17945 17946 |
# File 'lib/prism/node.rb', line 17944 def child_nodes [expression] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
17963 17964 17965 |
# File 'lib/prism/node.rb', line 17963 def comment_targets [operator_loc, *expression] #: Array[Prism::node | Location] end |
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array
17956 17957 17958 17959 17960 |
# File 'lib/prism/node.rb', line 17956 def compact_child_nodes compact = [] #: Array[Prism::node] compact << expression if expression compact end |
#copy(node_id: self.node_id, location: self.location, flags: self.flags, operator_loc: self.operator_loc, expression: self.expression) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?operator_loc: Location, ?expression: Prism::node?) -> SplatNode
17968 17969 17970 |
# File 'lib/prism/node.rb', line 17968 def copy(node_id: self.node_id, location: self.location, flags: self.flags, operator_loc: self.operator_loc, expression: self.expression) SplatNode.new(source, node_id, location, flags, operator_loc, expression) end |
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, operator_loc: Location, expression: Prism::node? }
17976 17977 17978 |
# File 'lib/prism/node.rb', line 17976 def deconstruct_keys(keys) { node_id: node_id, location: location, operator_loc: operator_loc, expression: expression } end |
#each_child_node {|expression| ... } ⇒ Object
def each_child_node: () { (Prism::node) -> void } -> void | () -> Enumerator
17949 17950 17951 17952 17953 |
# File 'lib/prism/node.rb', line 17949 def each_child_node return to_enum(:each_child_node) unless block_given? yield expression if expression end |
#inspect ⇒ Object
def inspect -> String
18002 18003 18004 |
# File 'lib/prism/node.rb', line 18002 def inspect InspectVisitor.compose(self) end |
#operator ⇒ Object
def operator: () -> String
17997 17998 17999 |
# File 'lib/prism/node.rb', line 17997 def operator operator_loc.slice end |
#operator_loc ⇒ Object
attr_reader operator_loc: Location
17981 17982 17983 17984 17985 |
# File 'lib/prism/node.rb', line 17981 def operator_loc location = @operator_loc return location if location.is_a?(Location) @operator_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#save_operator_loc(repository) ⇒ Object
Save the operator_loc location using the given saved source so that it can be retrieved later.
17989 17990 17991 |
# File 'lib/prism/node.rb', line 17989 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`.
18007 18008 18009 |
# File 'lib/prism/node.rb', line 18007 def type :splat_node end |