Module: YARD::Registry

Defined in:
lib/yard-js/core_ext/yard/registry.rb

Class Method Summary collapse

Class Method Details

.resolve(namespace, name, inheritance = false, proxy_fallback = false, type = nil) ⇒ Object


3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/yard-js/core_ext/yard/registry.rb', line 3

def self.resolve(namespace, name, inheritance = false, proxy_fallback = false, type = nil)
  if namespace.is_a?(CodeObjects::Proxy)
    return proxy_fallback ? CodeObjects::Proxy.new(namespace, name, type) : nil
  end

  if namespace == :root || !namespace
    namespace = root
  else
    namespace = namespace.parent until namespace.is_a?(CodeObjects::NamespaceObject)
  end
  orignamespace = namespace

  name = name.to_s.sub(/^\./, '')
  nss = namespace.path.split('.')
  nss = [] if nss == ['']
  while nss.size >= 0
    if obj = at((nss + [name]).compact.join('.'))
      return obj
    end
    break if nss.size == 0
    nss.pop
  end

  proxy_fallback ? CodeObjects::Proxy.new(orignamespace, name, type) : nil
end