123456789_123456789_123456789_123456789_123456789_

Class: Prism::ConstantPathTargetNode

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Node
Instance Chain:
self, Node
Inherits: Prism::Node
Defined in: lib/prism/node_ext.rb

Instance Attribute Summary

Node - Inherited

#newline_flag?

: () -> bool.

Instance Method Summary

  • #full_name

    Returns the full name of this constant path.

  • #full_name_parts

    Returns the list of parts for the full name of this constant path.

Node - Inherited

#deprecated

: (*String replacements) -> void.

#newline_flag!

: (Array lines) -> void.

Instance Method Details

#full_name

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

[ GitHub ]

  
# File 'lib/prism/node_ext.rb', line 289

def full_name
  full_name_parts.join("::")
end

#full_name_parts

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

[ GitHub ]

  
# File '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