Class: Prism::ErrorRecoveryNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::ErrorRecoveryNode
- Defined in:
- lib/prism/node.rb,
sig/generated/prism/node.rbs,
ext/prism/api_node.c
Overview
Represents a node that is either missing or unexpected and results in a syntax error.
Class Method Summary collapse
-
.type ⇒ :error_recovery_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, unexpected: self.unexpected) ⇒ ErrorRecoveryNode
:call-seq: copy(**fields) -> ErrorRecoveryNode.
-
#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, unexpected) ⇒ ErrorRecoveryNode
constructor
Initialize a new ErrorRecoveryNode node.
-
#inspect ⇒ String
: () -> String.
-
#type ⇒ :error_recovery_node
See
Node#type. -
#unexpected ⇒ Prism::node?
:call-seq: unexpected -> Node | nil.
Constructor Details
#initialize(source, node_id, location, flags, unexpected) ⇒ ErrorRecoveryNode
Initialize a new ErrorRecoveryNode node.
: (Source source, Integer node_id, Location location, Integer flags, Prism::node? unexpected) -> void
12254 12255 12256 12257 12258 12259 12260 |
# File 'lib/prism/node.rb', line 12254 def initialize(source, node_id, location, flags, unexpected) @source = source @node_id = node_id @location = location @flags = flags @unexpected = unexpected end |
Class Method Details
.type ⇒ :error_recovery_node
See Node.type.
: () -> :error_recovery_node
12341 12342 12343 |
# File 'lib/prism/node.rb', line 12341 def self.type :error_recovery_node end |
Instance Method Details
#===(other) ⇒ boolish
: (untyped other) -> boolish
12367 12368 12369 12370 |
# File 'lib/prism/node.rb', line 12367 def ===(other) # :nodoc: other.is_a?(ErrorRecoveryNode) && (unexpected === other.unexpected) end |
#accept(visitor) ⇒ Object
See Node.accept.
: (_Visitor visitor) -> untyped
12276 12277 12278 |
# File 'lib/prism/node.rb', line 12276 def accept(visitor) visitor.visit_error_recovery_node(self) end |
#child_nodes ⇒ Array[node?] Also known as: deconstruct
See Node.child_nodes.
: () -> Array
12283 12284 12285 |
# File 'lib/prism/node.rb', line 12283 def child_nodes [unexpected] end |
#compact_child_nodes ⇒ Array[node]
See Node.compact_child_nodes.
: () -> Array
12300 12301 12302 12303 12304 |
# File 'lib/prism/node.rb', line 12300 def compact_child_nodes compact = [] #: Array[Prism::node] if (unexpected = self.unexpected); compact << unexpected; end compact end |
#copy(node_id: self.node_id, location: self.location, flags: self.flags, unexpected: self.unexpected) ⇒ ErrorRecoveryNode
:call-seq:
copy(**fields) -> ErrorRecoveryNode
Creates a copy of self with the given fields, using self as the template.
: (?node_id: Integer, ?location: Location, ?flags: Integer, ?unexpected: Prism::node?) -> ErrorRecoveryNode
12312 12313 12314 |
# File 'lib/prism/node.rb', line 12312 def copy(node_id: self.node_id, location: self.location, flags: self.flags, unexpected: self.unexpected) ErrorRecoveryNode.new(source, node_id, location, flags, unexpected) end |
#deconstruct_keys(keys) ⇒ Hash[Symbol, untyped]
: (Array? keys) -> Hash[Symbol, untyped]
12319 12320 12321 12322 12323 12324 12325 12326 12327 12328 12329 |
# File 'lib/prism/node.rb', line 12319 def deconstruct_keys(keys) # :nodoc: (keys || %i[node_id location unexpected]).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 :unexpected then deconstructed[:unexpected] = self.unexpected end end end |
#each_child_node ⇒ Enumerator[node, void] #each_child_node ⇒ void
See Node.each_child_node.
: () -> Enumerator[node, void] : () { (node) -> void } -> void
12291 12292 12293 12294 12295 |
# File 'lib/prism/node.rb', line 12291 def each_child_node(&blk) return to_enum(:each_child_node) unless block_given? if (unexpected = self.unexpected); yield unexpected; end end |
#inspect ⇒ String
: () -> String
12346 12347 12348 |
# File 'lib/prism/node.rb', line 12346 def inspect # :nodoc: InspectVisitor.compose(self) end |
#type ⇒ :error_recovery_node
See Node#type.
: () -> :error_recovery_node
12334 12335 12336 |
# File 'lib/prism/node.rb', line 12334 def type :error_recovery_node end |
#unexpected ⇒ Prism::node?
:call-seq:
unexpected -> Node | nil
The unexpected node that was found in the tree, if there was one.
: () -> Prism::node?
12358 12359 12360 |
# File 'lib/prism/node.rb', line 12358 def unexpected @unexpected end |