class Ruby::Prism::ConstantPathNode

Public Instance Methods

Returns the full name of this constant path. For example: “Foo::Bar”

: () -> String

# File lib/ruby/prism/node_ext.rb, line 257
def full_name
  full_name_parts.join("::")
end

Returns the list of parts for the full name of this constant path. For example: [:Foo, :Bar]

: () -> Array

# File lib/ruby/prism/node_ext.rb, line 233
def full_name_parts
  parts = [] #: Array[Symbol]
  current = self #: node?

  while current.is_a?(ConstantPathNode)
    name = current.name
    if name.nil?
      raise ErrorRecoveryNodesInConstantPathError, "Constant path contains error recovery nodes. Cannot compute full name"
    end

    parts.unshift(name)
    current = current.parent
  end

  if !current.is_a?(ConstantReadNode) && !current.nil?
    raise DynamicPartsInConstantPathError, "Constant path contains dynamic parts. Cannot compute full name"
  end

  parts.unshift(current&.name || :"")
end