lib/yard/lib/yard/registry.rb
def 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
        if name =~ /^#{CodeObjects::NSEPQ}/
          [name, name[2..-1]].each do |n|
            found = at(n)
            return found if found && (type.nil? || found.type == type)
          end
        else
          while namespace
            if namespace.is_a?(CodeObjects::NamespaceObject)
              if inheritance
                nss = namespace.inheritance_tree(true)
                if namespace.respond_to?(:superclass)
                  if namespace.superclass != P('BasicObject')
                    nss |= [P('Object')]
                  end
                  nss |= [P('BasicObject')]
                end
              else
                nss = [namespace]
              end
              nss.each do |ns|
                next if ns.is_a?(CodeObjects::Proxy)
                found = partial_resolve(ns, name, type)
                return found if found
              end
            end
            namespace = namespace.parent
          end
        end
        proxy_fallback ? CodeObjects::Proxy.new(orignamespace, name, type) : nil
      end
# Attempts to find an object by name starting at +namespace+, performing
# a lookup similar to Ruby's method of resolving a constant in a namespace.
#
# @example Looks for instance method #reverse starting from A::B::C
#   Registry.resolve(P("A::B::C"), "#reverse")
# @example Looks for a constant in the root namespace
#   Registry.resolve(nil, 'CONSTANT')
# @example Looks for a class method respecting the inheritance tree
#   Registry.resolve(myclass, 'mymethod', true)
# @example Looks for a constant but returns a proxy if not found
#   Registry.resolve(P('A::B::C'), 'D', false, true) # => #<yardoc proxy A::B::C::D>
# @example Looks for a complex path from a namespace
#   Registry.resolve(P('A::B'), 'B::D') # => #<yardoc class A::B::D>
# @param [CodeObjects::NamespaceObject, nil] namespace the starting namespace
#   (module or class). If +nil+ or +:root+, starts from the {root} object.
# @param [String, Symbol] name the name (or complex path) to look for from
#   +namespace+.
# @param [Boolean] inheritance Follows inheritance chain (mixins, superclass)
#   when performing name resolution if set to +true+.
# @param [Boolean] proxy_fallback If +true+, returns a proxy representing
#   the unresolved path (namespace + name) if no object is found.
# @param [Symbol, nil] type the {CodeObjects::Base#type} that the resolved
#   object must be equal to. No type checking if nil.
# @return [CodeObjects::Base] the object if it is found
# @return [CodeObjects::Proxy] a Proxy representing the object if
#   +proxy_fallback+ is +true+.
# @return [nil] if +proxy_fallback+ is +false+ and no object was found.
# @see P
Attempts to find an object by name starting at +namespace+, performing
a lookup similar to Ruby's method of resolving a constant in a namespace.
Attempts to find an object by name starting at + namespace + performing a lookup similar to Ruby ' s method of resolving a constant in a namespace .
def 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
        if name =~ /^#{CodeObjects::NSEPQ}/
          [name, name[2..-1]].each do |n|
            found = at(n)
            return found if found && (type.nil? || found.type == type)
          end
        else
          while namespace
            if namespace.is_a?(CodeObjects::NamespaceObject)
              if inheritance
                nss = namespace.inheritance_tree(true)
                if namespace.respond_to?(:superclass)
                  if namespace.superclass != P('BasicObject')
                    nss |= [P('Object')]
                  end
                  nss |= [P('BasicObject')]
                end
              else
                nss = [namespace]
              end
              nss.each do |ns|
                next if ns.is_a?(CodeObjects::Proxy)
                found = partial_resolve(ns, name, type)
                return found if found
              end
            end
            namespace = namespace.parent
          end
        end
        proxy_fallback ? CodeObjects::Proxy.new(orignamespace, name, type) : nil
      end
def 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 if name =~ / ^ #{ CodeObjects :: NSEPQ } / [ name , name [ 2 .. - 1 ] ] . each do | n | found = at ( n ) return found if found && ( type . nil? || found . type == type ) end else while namespace if namespace . is_a? ( CodeObjects :: NamespaceObject ) if inheritance nss = namespace . inheritance_tree ( true ) if namespace . respond_to? ( :superclass ) if namespace . superclass != P ( 'BasicObject' ) nss |= [ P ( 'Object' ) ] end nss |= [ P ( 'BasicObject' ) ] end else nss = [ namespace ] end nss . each do | ns | next if ns . is_a? ( CodeObjects :: Proxy ) found = partial_resolve ( ns , name , type ) return found if found end end namespace = namespace . parent end end proxy_fallback ? CodeObjects :: Proxy . new ( orignamespace , name , type ) : nil end
Attempts to find an object by name starting at +namespace+, performing
a lookup similar to Ruby's method of resolving a constant in a namespace.
Attempts to find an object by name starting at + namespace + performing a lookup similar to Ruby ' s method of resolving a constant in a namespace .
the object if it is found
the object if it is found
CodeObjects::Base
a Proxy representing the object if +proxy_fallback+ is +true+.
a Proxy representing the object if + proxy_fallback + is + true + .
CodeObjects::Proxy
if +proxy_fallback+ is +false+ and no object was found.
if + proxy_fallback + is + false + and no object was found .
nil
namespace
name
inheritance
proxy_fallback
type
type the {CodeObjects::Base#type} that the resolved object must be equal to. No type checking if nil.
type the { CodeObjects :: Base#type } that the resolved object must be equal to . No type checking if nil .
example
Looks for instance method #reverse starting from A::B::C Registry.resolve(P("A::B::C"), "#reverse")
Looks for instance method #reverse starting from A :: B :: C Registry . resolve ( P ( " A :: B :: C " ) " #reverse " )
example
Looks for a constant in the root namespace Registry.resolve(nil, 'CONSTANT')
Looks for a constant in the root namespace Registry . resolve ( nil ' CONSTANT ' )
example
Looks for a class method respecting the inheritance tree Registry.resolve(myclass, 'mymethod', true)
Looks for a class method respecting the inheritance tree Registry . resolve ( myclass ' mymethod ' true )
example
Looks for a constant but returns a proxy if not found Registry.resolve(P('A::B::C'), 'D', false, true) # => #
Looks for a constant but returns a proxy if not found Registry . resolve ( P ( ' A :: B :: C ' ) ' D ' false true ) # = > #
example
Looks for a complex path from a namespace Registry.resolve(P('A::B'), 'B::D') # => #
Looks for a complex path from a namespace Registry . resolve ( P ( ' A :: B ' ) ' B :: D ' ) # = > #
see
None