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

Included in:
Declarations::Base, InlineParser::Parser
Defined in:
lib/rbs/ast/ruby/helpers/constant_helper.rb,
sig/ast/ruby/helpers/constant_helper.rbs

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.constant_as_type_name(node) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 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

Instance Method Details

#self?.constant_as_type_nameTypeName?

Parameters:

  • (Prism::node, nil)

Returns:



6
# File 'sig/ast/ruby/helpers/constant_helper.rbs', line 6

def self?.constant_as_type_name: (Prism::node?) -> TypeName?