Module: Steep::ModuleHelper

Included in:
Services::GotoService, Source, TypeConstruction
Defined in:
lib/steep/module_helper.rb

Instance Method Summary collapse

Instance Method Details

#module_name_from_node(parent_node, constant_name) ⇒ Object



3
4
5
6
7
# File 'lib/steep/module_helper.rb', line 3

def module_name_from_node(parent_node, constant_name)
  if namespace = namespace_from_node(parent_node)
    RBS::TypeName.new(name: constant_name, namespace: namespace)
  end
end

#namespace_from_node(node) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/steep/module_helper.rb', line 9

def namespace_from_node(node)
  if node
    case node.type
    when :cbase
      RBS::Namespace.root
    when :const
      if parent = namespace_from_node(node.children[0])
        parent.append(node.children[1])
      end
    end
  else
    RBS::Namespace.empty
  end
end