class Prism::ConstantPathTargetNode
Represents writing to a constant path in a context that doesn’t have an explicit value.
Foo::Foo, Bar::Bar = baz ^^^^^^^^ ^^^^^^^^
Represents writing to a constant path in a context that doesn’t have an explicit value.
Foo::Foo, Bar::Bar = baz ^^^^^^^^ ^^^^^^^^
Public Class Methods
(Source source, Integer node_id, Location location, Integer flags, Prism::node? parent, Symbol? name, Location delimiter_loc, Location name_loc) → void
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 9815 def initialize(source, node_id, location, flags, parent, name, delimiter_loc, name_loc) @source = source @node_id = node_id @location = location @flags = flags @parent = parent @name = name @delimiter_loc = delimiter_loc @name_loc = name_loc end
Initialize a new ConstantPathTargetNode node.
Initialize a new ConstantPathTargetNode node.
: (Source source, Integer node_id, Location location, Integer flags, Prism::node? parent, Symbol? name, Location delimiter_loc, Location name_loc) -> void
Public Instance Methods
(untyped other) → boolish
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/sig/generated/prism/node.rbs, line 6524
def ===: (untyped other) -> boolish
: (untyped other) -> boolish
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/sig/generated/prism/node.rbs, line 6452
def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped]
: (Array? keys) -> Hash[Symbol, untyped]
() → String
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node_ext.rb, line 289 def full_name full_name_parts.join("::") end
Returns the full name of this constant path. For example: “Foo::Bar”
Returns the full name of this constant path. For example: “Foo::Bar”
: () -> String
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node_ext.rb, line 267 def full_name_parts parts = case (parent = self.parent) when ConstantPathNode, ConstantReadNode parent.full_name_parts when nil [:""] else # e.g. self::Foo, (var)::Bar = baz raise ConstantPathNode::DynamicPartsInConstantPathError, "Constant target path contains dynamic parts. Cannot compute full name" end if (name = self.name).nil? raise ConstantPathNode::ErrorRecoveryNodesInConstantPathError, "Constant target path contains error recovery nodes. Cannot compute full name" end parts.push(name) end
Returns the list of parts for the full name of this constant path. For example: [:Foo, :Bar]
Returns the list of parts for the full name of this constant path. For example: [:Foo, :Bar]
: () -> Array
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/sig/generated/prism/node.rbs, line 6465
def inspect: () -> String
: () -> String
() → Symbol?
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 9936 def name @name end
() → Prism::node?
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 9926 def parent @parent end
Returns the parent attribute.
:call-seq: parent -> Node | nil
Returns the parent attribute.
: () -> Prism::node?
Locations
Public Instance Methods
() → Location
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 9947 def delimiter_loc location = @delimiter_loc return location if location.is_a?(Location) @delimiter_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end
Returns the Location represented by delimiter_loc.
:category: Locations :call-seq: delimiter_loc -> Location
Returns the Location represented by delimiter_loc.
: () -> Location
() → Location
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 9969 def name_loc location = @name_loc return location if location.is_a?(Location) @name_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end
Node Interface
These methods are present on all subclasses of Node. Read the node interface docs for more information.
Public Class Methods
Public Instance Methods
(_Visitor visitor) → untyped
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 9840 def accept(visitor) visitor.visit_constant_path_target_node(self) end
() → Array[node?]
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 9847 def child_nodes [parent] end
() → Array[node]
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 9864 def compact_child_nodes compact = [] #: Array[Prism::node] if (parent = self.parent); compact << parent; end compact end
(?node_id: Integer, ?location: Location, ?flags: Integer, ?parent: Prism::node?, ?name: Symbol?, ?delimiter_loc: Location, ?name_loc: Location) → ConstantPathTargetNode
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 9876 def copy(node_id: self.node_id, location: self.location, flags: self.flags, parent: self.parent, name: self.name, delimiter_loc: self.delimiter_loc, name_loc: self.name_loc) ConstantPathTargetNode.new(source, node_id, location, flags, parent, name, delimiter_loc, name_loc) end
Creates a copy of self with the given fields, using self as the template.
:call-seq: copy(**fields) -> ConstantPathTargetNode
Creates a copy of self with the given fields, using self as the template.
: (?node_id: Integer, ?location: Location, ?flags: Integer, ?parent: Prism::node?, ?name: Symbol?, ?delimiter_loc: Location, ?name_loc: Location) -> ConstantPathTargetNode
() → Enumerator[node, void]
() { (node) → void } → void
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 9855 def each_child_node(&blk) return to_enum(:each_child_node) unless block_given? if (parent = self.parent); yield parent; end end
See Node.each_child_node.
See Node.each_child_node.
: () -> Enumerator[node, void] : () { (node) -> void } -> void
Repository
Methods related to Relocation.
Public Instance Methods
(_Repository repository) → Relocation::Entry
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 9958 def save_delimiter_loc(repository) repository.enter(node_id, :delimiter_loc) end
Save the delimiter_loc location using the given saved source so that it can be retrieved later.
:category: Repository Save the delimiter_loc location using the given saved source so that it can be retrieved later.
: (_Repository repository) -> Relocation::Entry
(_Repository repository) → Relocation::Entry
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 9980 def save_name_loc(repository) repository.enter(node_id, :name_loc) end
Save the name_loc location using the given saved source so that it can be retrieved later.
:category: Repository Save the name_loc location using the given saved source so that it can be retrieved later.
: (_Repository repository) -> Relocation::Entry
Slicing
Public Instance Methods
() → String
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 9992 def delimiter delimiter_loc.slice end
Slice the location of delimiter_loc from the source.
:call-seq: delimiter -> String
Slice the location of delimiter_loc from the source.
: () -> String