Class: RDocF95::TopLevel
- Inherits:
-
Context
- Object
- CodeObject
- Context
- RDocF95::TopLevel
- Defined in:
- lib/rdoc-f95/code_objects.rb,
lib/rdoc-f95/parsers/parse_f95.rb
Overview
Extend TopLevel class for parse_f95.rb. Original class is defined in code_objects.rb.
-
Cross-reference of files are enabled
-
The case of names of classes or modules or methods are ignored
Constant Summary collapse
- @@all_classes =
{}
- @@all_modules =
{}
- @@all_files =
{}
Instance Attribute Summary collapse
-
#diagram ⇒ Object
Returns the value of attribute diagram.
-
#file_absolute_name ⇒ Object
Returns the value of attribute file_absolute_name.
-
#file_relative_name ⇒ Object
Returns the value of attribute file_relative_name.
-
#file_stat ⇒ Object
Returns the value of attribute file_stat.
Attributes inherited from Context
#aliases, #attributes, #constants, #in_files, #includes, #method_list, #name, #requires, #sections, #visibility
Attributes inherited from CodeObject
#comment, #document_children, #document_self, #done_documenting, #force_documentation, #parent, #section, #viewer
Class Method Summary collapse
- .all_classes_and_modules ⇒ Object
- .all_files ⇒ Object
- .find_class_named(name) ⇒ Object
- .reset ⇒ Object
Instance Method Summary collapse
-
#add_class_or_module(collection, class_type, name, superclass) ⇒ Object
Adding a class or module to a TopLevel is special, as we only want one copy of a particular top-level class.
- #find_class_or_module_named(symbol, ignore_case = nil) ⇒ Object
-
#find_file_named(name, method = nil, ignore_case = nil) ⇒ Object
Find a named file.
- #find_local_symbol(symbol, ignore_case = nil) ⇒ Object
-
#find_module_named(name, ignore_case = nil) ⇒ Object
Find a named module.
- #full_name ⇒ Object
-
#initialize(file_name) ⇒ TopLevel
constructor
A new instance of TopLevel.
Methods inherited from Context
#<=>, #add_alias, #add_attribute, #add_class, #add_constant, #add_include, #add_method, #add_module, #add_require, #add_to, #classes, #defined_in?, #each_attribute, #each_classmodule, #each_constant, #each_includes, #each_method, #find_attribute_named, #find_constant_named, #find_enclosing_module_named, #find_file, #find_instance_method_named, #find_method_named, #find_symbol, #include_includes?, #include_requires?, #initialize_classes_and_modules, #initialize_methods_etc, #modules, #ongoing_visibility=, #record_location, #remove_classes_and_modules, #remove_methods_etc, #set_current_section, #set_visibility_for, #toplevel
Methods inherited from CodeObject
attr_overridable, #remove_classes_and_modules, #remove_methods_etc, #start_doc, #stop_doc
Constructor Details
#initialize(file_name) ⇒ TopLevel
Returns a new instance of TopLevel.
477 478 479 480 481 482 483 484 |
# File 'lib/rdoc-f95/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 |
Instance Attribute Details
#diagram ⇒ Object
Returns the value of attribute diagram.
467 468 469 |
# File 'lib/rdoc-f95/code_objects.rb', line 467 def diagram @diagram end |
#file_absolute_name ⇒ Object
Returns the value of attribute file_absolute_name.
466 467 468 |
# File 'lib/rdoc-f95/code_objects.rb', line 466 def file_absolute_name @file_absolute_name end |
#file_relative_name ⇒ Object
Returns the value of attribute file_relative_name.
465 466 467 |
# File 'lib/rdoc-f95/code_objects.rb', line 465 def file_relative_name @file_relative_name end |
#file_stat ⇒ Object
Returns the value of attribute file_stat.
464 465 466 |
# File 'lib/rdoc-f95/code_objects.rb', line 464 def file_stat @file_stat end |
Class Method Details
.all_classes_and_modules ⇒ Object
525 526 527 |
# File 'lib/rdoc-f95/code_objects.rb', line 525 def self.all_classes_and_modules @@all_classes.values + @@all_modules.values end |
.all_files ⇒ Object
479 480 481 |
# File 'lib/rdoc-f95/parsers/parse_f95.rb', line 479 def TopLevel.all_files @@all_files end |
.find_class_named(name) ⇒ Object
529 530 531 532 533 534 535 |
# File 'lib/rdoc-f95/code_objects.rb', line 529 def self.find_class_named(name) @@all_classes.each_value do |c| res = c.find_class_named(name) return res if res end nil end |
.reset ⇒ Object
472 473 474 475 |
# File 'lib/rdoc-f95/code_objects.rb', line 472 def self.reset @@all_classes = {} @@all_modules = {} end |
Instance Method Details
#add_class_or_module(collection, class_type, name, superclass) ⇒ Object
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.
496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 |
# File 'lib/rdoc-f95/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_RDOC 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_RDOC collection[name] = cls unless @done_documenting cls.parent = self end cls end |
#find_class_or_module_named(symbol, ignore_case = nil) ⇒ Object
541 542 543 544 545 |
# File 'lib/rdoc-f95/code_objects.rb', line 541 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_file_named(name, method = nil, ignore_case = nil) ⇒ Object
Find a named file
504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 |
# File 'lib/rdoc-f95/parsers/parse_f95.rb', line 504 def find_file_named(name, method=nil, ignore_case=nil) return nil unless name result = nil @@all_files.each{|file_name, toplevel| result = toplevel if file_name == name } dir = File.dirname(@file_relative_name) @@all_files.each{|file_name, toplevel| if /^#{dir}\/(.*)/ =~ file_name result = toplevel if $1 == name end } if result if method result_method = result.find_local_symbol(method, ignore_case) return result_method else return result end else return nil end end |
#find_local_symbol(symbol, ignore_case = nil) ⇒ Object
537 538 539 |
# File 'lib/rdoc-f95/code_objects.rb', line 537 def find_local_symbol(symbol) find_class_or_module_named(symbol) || super end |
#find_module_named(name, ignore_case = nil) ⇒ Object
Find a named module
550 551 552 |
# File 'lib/rdoc-f95/code_objects.rb', line 550 def find_module_named(name) find_class_or_module_named(name) || find_enclosing_module_named(name) end |
#full_name ⇒ Object
486 487 488 |
# File 'lib/rdoc-f95/code_objects.rb', line 486 def full_name nil end |