Class: Prism::ImplicitNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::ImplicitNode
- Defined in:
- lib/prism/node.rb,
ext/prism/api_node.c
Overview
Represents a node that is implicitly being added to the tree but doesn’t correspond directly to a node in the source.
{ foo: }
^^^^
{ Foo: }
^^^^
foo in { bar: }
^^^^
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
attr_reader value: LocalVariableReadNode | CallNode | ConstantReadNode | LocalVariableTargetNode.
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.
-
#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, value: self.value) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?value: LocalVariableReadNode | CallNode | ConstantReadNode | LocalVariableTargetNode) -> ImplicitNode.
-
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, value: LocalVariableReadNode | CallNode | ConstantReadNode | LocalVariableTargetNode }.
-
#each_child_node {|value| ... } ⇒ Object
def each_child_node: () { (Prism::node) -> void } -> void | () -> Enumerator.
-
#initialize(source, node_id, location, flags, value) ⇒ ImplicitNode
constructor
Initialize a new ImplicitNode node.
-
#inspect ⇒ Object
def inspect -> String.
-
#type ⇒ Object
Return a symbol representation of this node type.
Constructor Details
#initialize(source, node_id, location, flags, value) ⇒ ImplicitNode
Initialize a new ImplicitNode node.
9395 9396 9397 9398 9399 9400 9401 |
# File 'lib/prism/node.rb', line 9395 def initialize(source, node_id, location, flags, value) @source = source @node_id = node_id @location = location @flags = flags @value = value end |
Instance Attribute Details
#value ⇒ Object (readonly)
attr_reader value: LocalVariableReadNode | CallNode | ConstantReadNode | LocalVariableTargetNode
9444 9445 9446 |
# File 'lib/prism/node.rb', line 9444 def value @value end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See Node::type.
9457 9458 9459 |
# File 'lib/prism/node.rb', line 9457 def self.type :implicit_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.
9463 9464 9465 9466 |
# File 'lib/prism/node.rb', line 9463 def ===(other) other.is_a?(ImplicitNode) && (value === other.value) end |
#accept(visitor) ⇒ Object
def accept: (Visitor visitor) -> void
9404 9405 9406 |
# File 'lib/prism/node.rb', line 9404 def accept(visitor) visitor.visit_implicit_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array
9409 9410 9411 |
# File 'lib/prism/node.rb', line 9409 def child_nodes [value] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
9426 9427 9428 |
# File 'lib/prism/node.rb', line 9426 def comment_targets [value] #: Array[Prism::node | Location] end |
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array
9421 9422 9423 |
# File 'lib/prism/node.rb', line 9421 def compact_child_nodes [value] end |
#copy(node_id: self.node_id, location: self.location, flags: self.flags, value: self.value) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?value: LocalVariableReadNode | CallNode | ConstantReadNode | LocalVariableTargetNode) -> ImplicitNode
9431 9432 9433 |
# File 'lib/prism/node.rb', line 9431 def copy(node_id: self.node_id, location: self.location, flags: self.flags, value: self.value) ImplicitNode.new(source, node_id, location, flags, value) end |
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, value: LocalVariableReadNode | CallNode | ConstantReadNode | LocalVariableTargetNode }
9439 9440 9441 |
# File 'lib/prism/node.rb', line 9439 def deconstruct_keys(keys) { node_id: node_id, location: location, value: value } end |
#each_child_node {|value| ... } ⇒ Object
def each_child_node: () { (Prism::node) -> void } -> void | () -> Enumerator
9414 9415 9416 9417 9418 |
# File 'lib/prism/node.rb', line 9414 def each_child_node return to_enum(:each_child_node) unless block_given? yield value end |
#inspect ⇒ Object
def inspect -> String
9447 9448 9449 |
# File 'lib/prism/node.rb', line 9447 def inspect InspectVisitor.compose(self) end |
#type ⇒ Object
Return a symbol representation of this node type. See ‘Node#type`.
9452 9453 9454 |
# File 'lib/prism/node.rb', line 9452 def type :implicit_node end |