Class: Prism::EmbeddedStatementsNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::EmbeddedStatementsNode
- Defined in:
- lib/prism/node.rb,
ext/prism/api_node.c
Overview
Represents an interpolated set of statements.
"foo #{bar}"
^^^^^^
Instance Attribute Summary collapse
-
#statements ⇒ Object
readonly
attr_reader statements: StatementsNode?.
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.
-
#closing ⇒ Object
def closing: () -> String.
-
#closing_loc ⇒ Object
attr_reader closing_loc: Location.
-
#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, opening_loc: self.opening_loc, statements: self.statements, closing_loc: self.closing_loc) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location, ?statements: StatementsNode?, ?closing_loc: Location) -> EmbeddedStatementsNode.
-
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, opening_loc: Location, statements: StatementsNode?, closing_loc: Location }.
-
#initialize(source, node_id, location, flags, opening_loc, statements, closing_loc) ⇒ EmbeddedStatementsNode
constructor
Initialize a new EmbeddedStatementsNode node.
-
#inspect ⇒ Object
def inspect -> String.
-
#opening ⇒ Object
def opening: () -> String.
-
#opening_loc ⇒ Object
attr_reader opening_loc: Location.
-
#save_closing_loc(repository) ⇒ Object
Save the closing_loc location using the given saved source so that it can be retrieved later.
-
#save_opening_loc(repository) ⇒ Object
Save the opening_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, opening_loc, statements, closing_loc) ⇒ EmbeddedStatementsNode
Initialize a new EmbeddedStatementsNode node.
6479 6480 6481 6482 6483 6484 6485 6486 6487 |
# File 'lib/prism/node.rb', line 6479 def initialize(source, node_id, location, flags, opening_loc, statements, closing_loc) @source = source @node_id = node_id @location = location @flags = flags @opening_loc = opening_loc @statements = statements @closing_loc = closing_loc end |
Instance Attribute Details
#statements ⇒ Object (readonly)
attr_reader statements: StatementsNode?
6538 6539 6540 |
# File 'lib/prism/node.rb', line 6538 def statements @statements end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See ‘Node::type`.
6574 6575 6576 |
# File 'lib/prism/node.rb', line 6574 def self.type :embedded_statements_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.
6580 6581 6582 6583 6584 6585 |
# File 'lib/prism/node.rb', line 6580 def ===(other) other.is_a?(EmbeddedStatementsNode) && (opening_loc.nil? == other.opening_loc.nil?) && (statements === other.statements) && (closing_loc.nil? == other.closing_loc.nil?) end |
#accept(visitor) ⇒ Object
def accept: (Visitor visitor) -> void
6490 6491 6492 |
# File 'lib/prism/node.rb', line 6490 def accept(visitor) visitor.(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array
6495 6496 6497 |
# File 'lib/prism/node.rb', line 6495 def child_nodes [statements] end |
#closing ⇒ Object
def closing: () -> String
6559 6560 6561 |
# File 'lib/prism/node.rb', line 6559 def closing closing_loc.slice end |
#closing_loc ⇒ Object
attr_reader closing_loc: Location
6541 6542 6543 6544 6545 |
# File 'lib/prism/node.rb', line 6541 def closing_loc location = @closing_loc return location if location.is_a?(Location) @closing_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
6507 6508 6509 |
# File 'lib/prism/node.rb', line 6507 def comment_targets [opening_loc, *statements, closing_loc] #: Array[Prism::node | Location] end |
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array
6500 6501 6502 6503 6504 |
# File 'lib/prism/node.rb', line 6500 def compact_child_nodes compact = [] #: Array[Prism::node] compact << statements if statements compact end |
#copy(node_id: self.node_id, location: self.location, flags: self.flags, opening_loc: self.opening_loc, statements: self.statements, closing_loc: self.closing_loc) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location, ?statements: StatementsNode?, ?closing_loc: Location) -> EmbeddedStatementsNode
6512 6513 6514 |
# File 'lib/prism/node.rb', line 6512 def copy(node_id: self.node_id, location: self.location, flags: self.flags, opening_loc: self.opening_loc, statements: self.statements, closing_loc: self.closing_loc) EmbeddedStatementsNode.new(source, node_id, location, flags, opening_loc, statements, closing_loc) end |
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, opening_loc: Location, statements: StatementsNode?, closing_loc: Location }
6520 6521 6522 |
# File 'lib/prism/node.rb', line 6520 def deconstruct_keys(keys) { node_id: node_id, location: location, opening_loc: opening_loc, statements: statements, closing_loc: closing_loc } end |
#inspect ⇒ Object
def inspect -> String
6564 6565 6566 |
# File 'lib/prism/node.rb', line 6564 def inspect InspectVisitor.compose(self) end |
#opening ⇒ Object
def opening: () -> String
6554 6555 6556 |
# File 'lib/prism/node.rb', line 6554 def opening opening_loc.slice end |
#opening_loc ⇒ Object
attr_reader opening_loc: Location
6525 6526 6527 6528 6529 |
# File 'lib/prism/node.rb', line 6525 def opening_loc location = @opening_loc return location if location.is_a?(Location) @opening_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#save_closing_loc(repository) ⇒ Object
Save the closing_loc location using the given saved source so that it can be retrieved later.
6549 6550 6551 |
# File 'lib/prism/node.rb', line 6549 def save_closing_loc(repository) repository.enter(node_id, :closing_loc) end |
#save_opening_loc(repository) ⇒ Object
Save the opening_loc location using the given saved source so that it can be retrieved later.
6533 6534 6535 |
# File 'lib/prism/node.rb', line 6533 def save_opening_loc(repository) repository.enter(node_id, :opening_loc) end |
#type ⇒ Object
Return a symbol representation of this node type. See ‘Node#type`.
6569 6570 6571 |
# File 'lib/prism/node.rb', line 6569 def type :embedded_statements_node end |