123456789_123456789_123456789_123456789_123456789_

Module: RBS::AST::Ruby::Helpers::ConstantHelper

Class Method Summary

Class Method Details

.constant_as_type_name(node) (mod_func)

[ GitHub ]

  
# File 'lib/rbs/ast/ruby/helpers/constant_helper.rb', line 10

def constant_as_type_name(node)
  case node
  when Prism::ConstantPathNode, Prism::ConstantReadNode
    begin
      TypeName.parse(node.full_name)
    rescue Prism::ConstantPathNode::DynamicPartsInConstantPathError
      nil
    end
  when Prism::ConstantWriteNode
    TypeName.new(name: node.name, namespace: Namespace.empty)
  when Prism::ConstantPathWriteNode
    constant_as_type_name(node.target)
  end
end