Class: Prism::PreExecutionNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::PreExecutionNode
- Defined in:
- lib/prism/node.rb,
sig/generated/prism/node.rbs,
ext/prism/api_node.c
Overview
Class Method Summary collapse
-
.type ⇒ :pre_execution_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.
-
#closing ⇒ String
:call-seq: closing -> String.
-
#closing_loc ⇒ Location
:category: Locations :call-seq: closing_loc -> Location.
-
#compact_child_nodes ⇒ Array[node]
See Node.compact_child_nodes.
-
#copy(node_id: self.node_id, location: self.location, flags: self.flags, statements: self.statements, keyword_loc: self.keyword_loc, opening_loc: self.opening_loc, closing_loc: self.closing_loc) ⇒ PreExecutionNode
:call-seq: copy(**fields) -> PreExecutionNode.
-
#deconstruct_keys(keys) ⇒ Hash[Symbol, untyped]
: (Array? keys) -> Hash[Symbol, untyped].
-
#each_child_node {|arg0| ... } ⇒ Object
See Node.each_child_node.
-
#initialize(source, node_id, location, flags, statements, keyword_loc, opening_loc, closing_loc) ⇒ PreExecutionNode
constructor
Initialize a new PreExecutionNode node.
-
#inspect ⇒ String
: () -> String.
-
#keyword ⇒ String
:call-seq: keyword -> String.
-
#keyword_loc ⇒ Location
:category: Locations :call-seq: keyword_loc -> Location.
-
#opening ⇒ String
:call-seq: opening -> String.
-
#opening_loc ⇒ Location
:category: Locations :call-seq: opening_loc -> Location.
-
#save_closing_loc(repository) ⇒ Relocation::Entry
:category: Repository Save the closing_loc location using the given saved source so that it can be retrieved later.
-
#save_keyword_loc(repository) ⇒ Relocation::Entry
:category: Repository Save the keyword_loc location using the given saved source so that it can be retrieved later.
-
#save_opening_loc(repository) ⇒ Relocation::Entry
:category: Repository Save the opening_loc location using the given saved source so that it can be retrieved later.
-
#statements ⇒ StatementsNode?
:call-seq: statements -> StatementsNode | nil.
-
#type ⇒ :pre_execution_node
See
Node#type.
Constructor Details
#initialize(source, node_id, location, flags, statements, keyword_loc, opening_loc, closing_loc) ⇒ PreExecutionNode
Initialize a new PreExecutionNode node.
: (Source source, Integer node_id, Location location, Integer flags, StatementsNode? statements, Location keyword_loc, Location opening_loc, Location closing_loc) -> void
27223 27224 27225 27226 27227 27228 27229 27230 27231 27232 |
# File 'lib/prism/node.rb', line 27223 def initialize(source, node_id, location, flags, statements, keyword_loc, opening_loc, closing_loc) @source = source @node_id = node_id @location = location @flags = flags @statements = statements @keyword_loc = keyword_loc @opening_loc = opening_loc @closing_loc = closing_loc end |
Class Method Details
.type ⇒ :pre_execution_node
See Node.type.
: () -> :pre_execution_node
27319 27320 27321 |
# File 'lib/prism/node.rb', line 27319 def self.type :pre_execution_node end |
Instance Method Details
#===(other) ⇒ boolish
: (untyped other) -> boolish
27441 27442 27443 27444 27445 27446 27447 |
# File 'lib/prism/node.rb', line 27441 def ===(other) # :nodoc: other.is_a?(PreExecutionNode) && (statements === other.statements) && (keyword_loc.nil? == other.keyword_loc.nil?) && (opening_loc.nil? == other.opening_loc.nil?) && (closing_loc.nil? == other.closing_loc.nil?) end |
#accept(visitor) ⇒ Object
See Node.accept.
: (_Visitor visitor) -> untyped
27248 27249 27250 |
# File 'lib/prism/node.rb', line 27248 def accept(visitor) visitor.visit_pre_execution_node(self) end |
#child_nodes ⇒ Array[node?] Also known as: deconstruct
See Node.child_nodes.
: () -> Array
27255 27256 27257 |
# File 'lib/prism/node.rb', line 27255 def child_nodes [statements] end |
#closing ⇒ String
:call-seq:
closing -> String
Slice the location of closing_loc from the source.
: () -> String
27434 27435 27436 |
# File 'lib/prism/node.rb', line 27434 def closing closing_loc.slice end |
#closing_loc ⇒ Location
:category: Locations :call-seq:
closing_loc -> Location
Returns the Location represented by closing_loc.
: () -> Location
27391 27392 27393 27394 27395 |
# File 'lib/prism/node.rb', line 27391 def closing_loc location = @closing_loc return location if location.is_a?(Location) @closing_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#compact_child_nodes ⇒ Array[node]
See Node.compact_child_nodes.
: () -> Array
27272 27273 27274 27275 27276 |
# File 'lib/prism/node.rb', line 27272 def compact_child_nodes compact = [] #: Array[Prism::node] if (statements = self.statements); compact << statements; end compact end |
#copy(node_id: self.node_id, location: self.location, flags: self.flags, statements: self.statements, keyword_loc: self.keyword_loc, opening_loc: self.opening_loc, closing_loc: self.closing_loc) ⇒ PreExecutionNode
:call-seq:
copy(**fields) -> PreExecutionNode
Creates a copy of self with the given fields, using self as the template.
: (?node_id: Integer, ?location: Location, ?flags: Integer, ?statements: StatementsNode?, ?keyword_loc: Location, ?opening_loc: Location, ?closing_loc: Location) -> PreExecutionNode
27284 27285 27286 |
# File 'lib/prism/node.rb', line 27284 def copy(node_id: self.node_id, location: self.location, flags: self.flags, statements: self.statements, keyword_loc: self.keyword_loc, opening_loc: self.opening_loc, closing_loc: self.closing_loc) PreExecutionNode.new(source, node_id, location, flags, statements, keyword_loc, opening_loc, closing_loc) end |
#deconstruct_keys(keys) ⇒ Hash[Symbol, untyped]
: (Array? keys) -> Hash[Symbol, untyped]
27291 27292 27293 27294 27295 27296 27297 27298 27299 27300 27301 27302 27303 27304 27305 27306 27307 |
# File 'lib/prism/node.rb', line 27291 def deconstruct_keys(keys) # :nodoc: (keys || i[node_id location statements keyword_loc opening_loc closing_loc keyword opening closing]).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 :statements then deconstructed[:statements] = self.statements when :keyword_loc then deconstructed[:keyword_loc] = self.keyword_loc when :opening_loc then deconstructed[:opening_loc] = self.opening_loc when :closing_loc then deconstructed[:closing_loc] = self.closing_loc when :keyword then deconstructed[:keyword] = self.keyword when :opening then deconstructed[:opening] = self.opening when :closing then deconstructed[:closing] = self.closing end end end |
#each_child_node ⇒ Enumerator[node, void] #each_child_node ⇒ void
See Node.each_child_node.
: () -> Enumerator[node, void] : () { (node) -> void } -> void
27263 27264 27265 27266 27267 |
# File 'lib/prism/node.rb', line 27263 def each_child_node(&blk) return to_enum(:each_child_node) unless block_given? if (statements = self.statements); yield statements; end end |
#inspect ⇒ String
: () -> String
27324 27325 27326 |
# File 'lib/prism/node.rb', line 27324 def inspect # :nodoc: InspectVisitor.compose(self) end |
#keyword ⇒ String
:call-seq:
keyword -> String
Slice the location of keyword_loc from the source.
: () -> String
27414 27415 27416 |
# File 'lib/prism/node.rb', line 27414 def keyword keyword_loc.slice end |
#keyword_loc ⇒ Location
:category: Locations :call-seq:
keyword_loc -> Location
Returns the Location represented by keyword_loc.
: () -> Location
27347 27348 27349 27350 27351 |
# File 'lib/prism/node.rb', line 27347 def keyword_loc location = @keyword_loc return location if location.is_a?(Location) @keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#opening ⇒ String
:call-seq:
opening -> String
Slice the location of opening_loc from the source.
: () -> String
27424 27425 27426 |
# File 'lib/prism/node.rb', line 27424 def opening opening_loc.slice end |
#opening_loc ⇒ Location
:category: Locations :call-seq:
opening_loc -> Location
Returns the Location represented by opening_loc.
: () -> Location
27369 27370 27371 27372 27373 |
# File 'lib/prism/node.rb', line 27369 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) ⇒ Relocation::Entry
:category: Repository Save the closing_loc location using the given saved source so that it can be retrieved later.
: (_Repository repository) -> Relocation::Entry
27402 27403 27404 |
# File 'lib/prism/node.rb', line 27402 def save_closing_loc(repository) repository.enter(node_id, :closing_loc) end |
#save_keyword_loc(repository) ⇒ Relocation::Entry
:category: Repository Save the keyword_loc location using the given saved source so that it can be retrieved later.
: (_Repository repository) -> Relocation::Entry
27358 27359 27360 |
# File 'lib/prism/node.rb', line 27358 def save_keyword_loc(repository) repository.enter(node_id, :keyword_loc) end |
#save_opening_loc(repository) ⇒ Relocation::Entry
:category: Repository Save the opening_loc location using the given saved source so that it can be retrieved later.
: (_Repository repository) -> Relocation::Entry
27380 27381 27382 |
# File 'lib/prism/node.rb', line 27380 def save_opening_loc(repository) repository.enter(node_id, :opening_loc) end |
#statements ⇒ StatementsNode?
:call-seq:
statements -> StatementsNode | nil
Returns the statements attribute.
: () -> StatementsNode?
27336 27337 27338 |
# File 'lib/prism/node.rb', line 27336 def statements @statements end |
#type ⇒ :pre_execution_node
See Node#type.
: () -> :pre_execution_node
27312 27313 27314 |
# File 'lib/prism/node.rb', line 27312 def type :pre_execution_node end |