Class | RDoc::TopLevel
In: | rdoc/code_objects.rb
Parent: | Context

A TopLevel context is a source file

### Methods

add_class_or_module all_classes_and_modules find_class_named find_class_or_module_named find_local_symbol find_module_named full_name new reset

### Attributes

diagram | [RW] |
file_absolute_name | [RW] |
file_relative_name | [RW] |
file_stat | [RW] |

### Public Class methods

all_classes_and_modules()

[Source]

    # File rdoc/code_objects.rb, line 518
        def TopLevel.all_classes_and_modules
          @@all_classes.values + @@all_modules.values
        end

find_class_named(name)

[Source]

    # File rdoc/code_objects.rb, line 522
        def TopLevel.find_class_named(name)
         @@all_classes.each_value do |c|
            res = c.find_class_named(name)
            return res if res
          end
          nil
        end

new(file_name)

[Source]

    # File rdoc/code_objects.rb, line 477
        def initialize(file_name)
          super()
          @name = "TopLevel"
          @file_relative_name = file_name
          @file_absolute_name = file_name
          @file_stat          = File.stat(file_name)
          @diagram            = nil
        end

reset()

[Source]

    # File rdoc/code_objects.rb, line 472
        def TopLevel::reset
          @@all_classes = {}
          @@all_modules = {}
        end

### Public Instance methods

add_class_or_module(collection, class_type, name, superclass)

Adding a class or module to a TopLevel is special, as we only want one copy of a particular top-level class. For example, if both file A and file B implement class C, we only want one ClassModule object for C. This code arranges to share classes and modules between files.

[Source]

    # File rdoc/code_objects.rb, line 496
        def add_class_or_module(collection, class_type, name, superclass)
          cls = collection[name]
          if cls
            puts "Reusing class/module #{name}" if $DEBUG
          else
            if class_type == NormalModule
              all = @@all_modules
            else
              all = @@all_classes
            end
            cls = all[name]
            if !cls
              cls = class_type.new(name, superclass)
              all[name] = cls  unless @done_documenting
            end
            puts "Adding class/module #{name} to #@name" if $DEBUG
            collection[name] = cls unless @done_documenting
            cls.parent = self
          end
          cls
        end

find_class_or_module_named(symbol)

[Source]

    # File rdoc/code_objects.rb, line 534
        def find_class_or_module_named(symbol)
          @@all_classes.each_value {|c| return c if c.name == symbol}
          @@all_modules.each_value {|m| return m if m.name == symbol}
          nil
        end

find_local_symbol(symbol)

[Source]

    # File rdoc/code_objects.rb, line 530
        def find_local_symbol(symbol)
          find_class_or_module_named(symbol) || super
        end

find_module_named(name)

Find a named module

[Source]

    # File rdoc/code_objects.rb, line 541
        def find_module_named(name)
          find_class_or_module_named(name) || find_enclosing_module_named(name)
        end

full_name()

[Source]

    # File rdoc/code_objects.rb, line 486
        def full_name
          nil
        end

[Validate]