Class: Prism::ImplicitNode

Inherits:
PrismNode
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, node_id, location, flags, value) ⇒ ImplicitNode

Initialize a new ImplicitNode node.



8737
8738
8739
8740
8741
8742
8743
# File 'lib/prism/node.rb', line 8737

def initialize(source, node_id, location, flags, value)
  @source = source
  @node_id = node_id
  @location = location
  @flags = flags
  @value = value
end

Instance Attribute Details

#valueObject (readonly)

attr_reader value: LocalVariableReadNode | CallNode | ConstantReadNode | LocalVariableTargetNode



8779
8780
8781
# File 'lib/prism/node.rb', line 8779

def value
  @value
end

Class Method Details

.typeObject

Return a symbol representation of this node type. See ‘Node::type`.



8792
8793
8794
# File 'lib/prism/node.rb', line 8792

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.



8798
8799
8800
8801
# File 'lib/prism/node.rb', line 8798

def ===(other)
  other.is_a?(ImplicitNode) &&
    (value === other.value)
end

#accept(visitor) ⇒ Object

def accept: (Visitor visitor) -> void



8746
8747
8748
# File 'lib/prism/node.rb', line 8746

def accept(visitor)
  visitor.visit_implicit_node(self)
end

#child_nodesObject Also known as: deconstruct

def child_nodes: () -> Array[nil | Node]



8751
8752
8753
# File 'lib/prism/node.rb', line 8751

def child_nodes
  [value]
end

#comment_targetsObject

def comment_targets: () -> Array[Node | Location]



8761
8762
8763
# File 'lib/prism/node.rb', line 8761

def comment_targets
  [value] #: Array[Prism::node | Location]
end

#compact_child_nodesObject

def compact_child_nodes: () -> Array



8756
8757
8758
# File 'lib/prism/node.rb', line 8756

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



8766
8767
8768
# File 'lib/prism/node.rb', line 8766

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 }



8774
8775
8776
# File 'lib/prism/node.rb', line 8774

def deconstruct_keys(keys)
  { node_id: node_id, location: location, value: value }
end

#inspectObject

def inspect -> String



8782
8783
8784
# File 'lib/prism/node.rb', line 8782

def inspect
  InspectVisitor.compose(self)
end

#typeObject

Return a symbol representation of this node type. See ‘Node#type`.



8787
8788
8789
# File 'lib/prism/node.rb', line 8787

def type
  :implicit_node
end