Class: Prism::PinnedExpressionNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::PinnedExpressionNode
- Defined in:
- lib/prism/node.rb,
sig/generated/prism/node.rbs,
ext/prism/api_node.c
Overview
Represents the use of the ^ operator for pinning an expression in a pattern matching expression.
foo in ^(bar)
^^^^^^
Class Method Summary collapse
-
.type ⇒ :pinned_expression_node
See
Node.type.
Instance Method Summary collapse
-
#===(other) ⇒ boolish
: (untyped other) -> boolish.
-
#accept(visitor) ⇒ Object
See Node.accept.
-
#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, expression: self.expression, operator_loc: self.operator_loc, lparen_loc: self.lparen_loc, rparen_loc: self.rparen_loc) ⇒ PinnedExpressionNode
:call-seq: copy(**fields) -> PinnedExpressionNode.
-
#deconstruct_keys(keys) ⇒ Hash[Symbol, untyped]
: (Array? keys) -> Hash[Symbol, untyped].
-
#each_child_node {|arg0| ... } ⇒ Object
See Node.each_child_node.
-
#expression ⇒ Prism::node
:call-seq: expression -> Node.
-
#initialize(source, node_id, location, flags, expression, operator_loc, lparen_loc, rparen_loc) ⇒ PinnedExpressionNode
constructor
Initialize a new PinnedExpressionNode node.
-
#inspect ⇒ String
: () -> String.
-
#lparen ⇒ String
:call-seq: lparen -> String.
-
#lparen_loc ⇒ Location
:category: Locations :call-seq: lparen_loc -> Location.
-
#operator ⇒ String
:call-seq: operator -> String.
-
#operator_loc ⇒ Location
:category: Locations :call-seq: operator_loc -> Location.
-
#rparen ⇒ String
:call-seq: rparen -> String.
-
#rparen_loc ⇒ Location
:category: Locations :call-seq: rparen_loc -> Location.
-
#save_lparen_loc(repository) ⇒ Relocation::Entry
:category: Repository Save the lparen_loc location using the given saved source so that it can be retrieved later.
-
#save_operator_loc(repository) ⇒ Relocation::Entry
:category: Repository Save the operator_loc location using the given saved source so that it can be retrieved later.
-
#save_rparen_loc(repository) ⇒ Relocation::Entry
:category: Repository Save the rparen_loc location using the given saved source so that it can be retrieved later.
-
#type ⇒ :pinned_expression_node
See
Node#type.
Constructor Details
#initialize(source, node_id, location, flags, expression, operator_loc, lparen_loc, rparen_loc) ⇒ PinnedExpressionNode
Initialize a new PinnedExpressionNode node.
: (Source source, Integer node_id, Location location, Integer flags, Prism::node expression, Location operator_loc, Location lparen_loc, Location rparen_loc) -> void
26527 26528 26529 26530 26531 26532 26533 26534 26535 26536 |
# File 'lib/prism/node.rb', line 26527 def initialize(source, node_id, location, flags, expression, operator_loc, lparen_loc, rparen_loc) @source = source @node_id = node_id @location = location @flags = flags @expression = expression @operator_loc = operator_loc @lparen_loc = lparen_loc @rparen_loc = rparen_loc end |
Class Method Details
.type ⇒ :pinned_expression_node
See Node.type.
: () -> :pinned_expression_node
26621 26622 26623 |
# File 'lib/prism/node.rb', line 26621 def self.type :pinned_expression_node end |
Instance Method Details
#===(other) ⇒ boolish
: (untyped other) -> boolish
26771 26772 26773 26774 26775 26776 26777 |
# File 'lib/prism/node.rb', line 26771 def ===(other) # :nodoc: other.is_a?(PinnedExpressionNode) && (expression === other.expression) && (operator_loc.nil? == other.operator_loc.nil?) && (lparen_loc.nil? == other.lparen_loc.nil?) && (rparen_loc.nil? == other.rparen_loc.nil?) end |
#accept(visitor) ⇒ Object
See Node.accept.
: (_Visitor visitor) -> untyped
26552 26553 26554 |
# File 'lib/prism/node.rb', line 26552 def accept(visitor) visitor.visit_pinned_expression_node(self) end |
#child_nodes ⇒ Array[node?] Also known as: deconstruct
See Node.child_nodes.
: () -> Array
26559 26560 26561 |
# File 'lib/prism/node.rb', line 26559 def child_nodes [expression] end |
#compact_child_nodes ⇒ Array[node]
See Node.compact_child_nodes.
: () -> Array
26576 26577 26578 |
# File 'lib/prism/node.rb', line 26576 def compact_child_nodes [expression] end |
#copy(node_id: self.node_id, location: self.location, flags: self.flags, expression: self.expression, operator_loc: self.operator_loc, lparen_loc: self.lparen_loc, rparen_loc: self.rparen_loc) ⇒ PinnedExpressionNode
:call-seq:
copy(**fields) -> PinnedExpressionNode
Creates a copy of self with the given fields, using self as the template.
: (?node_id: Integer, ?location: Location, ?flags: Integer, ?expression: Prism::node, ?operator_loc: Location, ?lparen_loc: Location, ?rparen_loc: Location) -> PinnedExpressionNode
26586 26587 26588 |
# File 'lib/prism/node.rb', line 26586 def copy(node_id: self.node_id, location: self.location, flags: self.flags, expression: self.expression, operator_loc: self.operator_loc, lparen_loc: self.lparen_loc, rparen_loc: self.rparen_loc) PinnedExpressionNode.new(source, node_id, location, flags, expression, operator_loc, lparen_loc, rparen_loc) end |
#deconstruct_keys(keys) ⇒ Hash[Symbol, untyped]
: (Array? keys) -> Hash[Symbol, untyped]
26593 26594 26595 26596 26597 26598 26599 26600 26601 26602 26603 26604 26605 26606 26607 26608 26609 |
# File 'lib/prism/node.rb', line 26593 def deconstruct_keys(keys) # :nodoc: (keys || i[node_id location expression operator_loc lparen_loc rparen_loc operator lparen rparen]).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 :expression then deconstructed[:expression] = self.expression when :operator_loc then deconstructed[:operator_loc] = self.operator_loc when :lparen_loc then deconstructed[:lparen_loc] = self.lparen_loc when :rparen_loc then deconstructed[:rparen_loc] = self.rparen_loc when :operator then deconstructed[:operator] = self.operator when :lparen then deconstructed[:lparen] = self.lparen when :rparen then deconstructed[:rparen] = self.rparen end end end |
#each_child_node ⇒ Enumerator[node, void] #each_child_node ⇒ void
See Node.each_child_node.
: () -> Enumerator[node, void] : () { (node) -> void } -> void
26567 26568 26569 26570 26571 |
# File 'lib/prism/node.rb', line 26567 def each_child_node(&blk) return to_enum(:each_child_node) unless block_given? yield expression end |
#expression ⇒ Prism::node
:call-seq:
expression -> Node
The expression used in the pinned expression
foo in ^(bar)
^^^
: () -> Prism::node
26645 26646 26647 |
# File 'lib/prism/node.rb', line 26645 def expression @expression end |
#inspect ⇒ String
: () -> String
26626 26627 26628 |
# File 'lib/prism/node.rb', line 26626 def inspect # :nodoc: InspectVisitor.compose(self) end |
#lparen ⇒ String
:call-seq:
lparen -> String
Slice the location of lparen_loc from the source.
: () -> String
26754 26755 26756 |
# File 'lib/prism/node.rb', line 26754 def lparen lparen_loc.slice end |
#lparen_loc ⇒ Location
:category: Locations :call-seq:
lparen_loc -> Location
The Location of the opening parenthesis.
foo in ^(bar)
^
: () -> Location
26692 26693 26694 26695 26696 |
# File 'lib/prism/node.rb', line 26692 def lparen_loc location = @lparen_loc return location if location.is_a?(Location) @lparen_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#operator ⇒ String
:call-seq:
operator -> String
Slice the location of operator_loc from the source.
: () -> String
26744 26745 26746 |
# File 'lib/prism/node.rb', line 26744 def operator operator_loc.slice end |
#operator_loc ⇒ Location
:category: Locations :call-seq:
operator_loc -> Location
The Location of the ^ operator
foo in ^(bar)
^
: () -> Location
26663 26664 26665 26666 26667 |
# File 'lib/prism/node.rb', line 26663 def operator_loc location = @operator_loc return location if location.is_a?(Location) @operator_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#rparen ⇒ String
:call-seq:
rparen -> String
Slice the location of rparen_loc from the source.
: () -> String
26764 26765 26766 |
# File 'lib/prism/node.rb', line 26764 def rparen rparen_loc.slice end |
#rparen_loc ⇒ Location
:category: Locations :call-seq:
rparen_loc -> Location
The Location of the closing parenthesis.
foo in ^(bar)
^
: () -> Location
26721 26722 26723 26724 26725 |
# File 'lib/prism/node.rb', line 26721 def rparen_loc location = @rparen_loc return location if location.is_a?(Location) @rparen_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#save_lparen_loc(repository) ⇒ Relocation::Entry
:category: Repository Save the lparen_loc location using the given saved source so that it can be retrieved later.
: (_Repository repository) -> Relocation::Entry
26703 26704 26705 |
# File 'lib/prism/node.rb', line 26703 def save_lparen_loc(repository) repository.enter(node_id, :lparen_loc) end |
#save_operator_loc(repository) ⇒ Relocation::Entry
:category: Repository Save the operator_loc location using the given saved source so that it can be retrieved later.
: (_Repository repository) -> Relocation::Entry
26674 26675 26676 |
# File 'lib/prism/node.rb', line 26674 def save_operator_loc(repository) repository.enter(node_id, :operator_loc) end |
#save_rparen_loc(repository) ⇒ Relocation::Entry
:category: Repository Save the rparen_loc location using the given saved source so that it can be retrieved later.
: (_Repository repository) -> Relocation::Entry
26732 26733 26734 |
# File 'lib/prism/node.rb', line 26732 def save_rparen_loc(repository) repository.enter(node_id, :rparen_loc) end |
#type ⇒ :pinned_expression_node
See Node#type.
: () -> :pinned_expression_node
26614 26615 26616 |
# File 'lib/prism/node.rb', line 26614 def type :pinned_expression_node end |