find_symbol(symbol, method = nil)
public
Look up symbol. If method is non-nil, then we assume the
symbol references a module that contains that method.
Show source
def find_symbol(symbol, method = nil)
result = nil
case symbol
when /^::([A-Z].*)/ then
result = top_level.find_symbol($1)
when /::/ then
modules = symbol.split(/::/)
unless modules.empty? then
module_name = modules.shift
result = find_module_named(module_name)
if result then
modules.each do |name|
result = result.find_module_named name
break unless result
end
end
end
end
unless result then
if method then
result = find_module_named symbol
else
result = find_local_symbol symbol
if result.nil? then
if symbol =~ /^[A-Z]/ then
result = parent
while result && result.name != symbol do
result = result.parent
end
end
end
end
end
result = result.find_local_symbol method if result and method
result
end