method
find_symbol
v1_9_1_378 -
Show latest stable
- Class:
RDoc::Context
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.
# File lib/rdoc/code_objects.rb, line 482
def find_symbol(symbol, method = nil)
result = nil
case symbol
when /^::(.*)/ then
result = toplevel.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
else
# if a method is specified, then we're definitely looking for
# a module, otherwise it could be any symbol
if method
result = find_module_named(symbol)
else
result = find_local_symbol(symbol)
if result.nil?
if symbol =~ /^[A-Z]/
result = parent
while result && result.name != symbol
result = result.parent
end
end
end
end
end
if result and method then
fail unless result.respond_to? :find_local_symbol
result = result.find_local_symbol(method)
end
result
end Related methods
- Instance methods
- <=>
- add_alias
- add_alias_impl
- add_attribute
- add_class
- add_class_or_module
- add_constant
- add_include
- add_method
- add_module
- add_require
- add_to
- classes
- defined_in?
- each_attribute
- each_classmodule
- each_constant
- each_method
- find_enclosing_module_named
- find_local_symbol
- find_module_named
- find_symbol
- initialize_classes_and_modules
- initialize_methods_etc
- methods_matching
- modules
- ongoing_visibility=
- record_location
- remove_classes_and_modules
- remove_methods_etc
- set_current_section
- set_visibility_for
- toplevel
- Class methods
- new
- Protected methods
-
classes_hash -
modules_hash - Private methods
-
find_attribute_named -
find_constant_named -
find_file_named -
find_instance_method_named -
find_method_named