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.
6447 6448 6449 6450 6451 6452 6453 6454 6455 |
# File 'lib/prism/node.rb', line 6447 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?
6506 6507 6508 |
# File 'lib/prism/node.rb', line 6506 def statements @statements end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See ‘Node::type`.
6542 6543 6544 |
# File 'lib/prism/node.rb', line 6542 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.
6548 6549 6550 6551 6552 6553 |
# File 'lib/prism/node.rb', line 6548 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
6458 6459 6460 |
# File 'lib/prism/node.rb', line 6458 def accept(visitor) visitor.(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array
6463 6464 6465 |
# File 'lib/prism/node.rb', line 6463 def child_nodes [statements] end |
#closing ⇒ Object
def closing: () -> String
6527 6528 6529 |
# File 'lib/prism/node.rb', line 6527 def closing closing_loc.slice end |
#closing_loc ⇒ Object
attr_reader closing_loc: Location
6509 6510 6511 6512 6513 |
# File 'lib/prism/node.rb', line 6509 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]
6475 6476 6477 |
# File 'lib/prism/node.rb', line 6475 def comment_targets [opening_loc, *statements, closing_loc] #: Array[Prism::node | Location] end |
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array
6468 6469 6470 6471 6472 |
# File 'lib/prism/node.rb', line 6468 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
6480 6481 6482 |
# File 'lib/prism/node.rb', line 6480 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 }
6488 6489 6490 |
# File 'lib/prism/node.rb', line 6488 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
6532 6533 6534 |
# File 'lib/prism/node.rb', line 6532 def inspect InspectVisitor.compose(self) end |
#opening ⇒ Object
def opening: () -> String
6522 6523 6524 |
# File 'lib/prism/node.rb', line 6522 def opening opening_loc.slice end |
#opening_loc ⇒ Object
attr_reader opening_loc: Location
6493 6494 6495 6496 6497 |
# File 'lib/prism/node.rb', line 6493 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.
6517 6518 6519 |
# File 'lib/prism/node.rb', line 6517 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.
6501 6502 6503 |
# File 'lib/prism/node.rb', line 6501 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`.
6537 6538 6539 |
# File 'lib/prism/node.rb', line 6537 def type :embedded_statements_node end |