File: transformer/object-into-document/link.rb

Overview
Module Structure
Code

Overview

Module Structure

  module: <Toplevel Module>
  module: TmDoc#10
  module: Transformer
  module: ObjectIntoDocument#12
  module: Link#14
has properties
function: transform_link_to_file / 1 #18
function: transform_links_to_line / 1 #25
function: transform_link_to_line / 1 #36
function: transform_link_to_module / 1 #43
function: transform_link_to_property / 1 #72

Code

   1  # $Id: link.rb,v 1.6 2011/12/08 22:04:11 machan Exp $
   2 
   3  require 'tmdoc/tmstd'
   4  require 'tmdoc/constant'
   5  require 'tmdoc/model/object'
   6  require 'tmdoc/model/document'
   7  require 'tmdoc/transformer/object-into-document/path'
   8 
   9 
  10  module TmDoc
  11 
  12  module Transformer::ObjectIntoDocument
  13 
  14  module Link
  15 
  16  module_function
  17 
  18      def transform_link_to_file(mo_file)
  19          ASSERT.kind_of mo_file, MOP::File
  20 
  21          MDL::File.new mo_file.name
  22      end
  23 
  24 
  25      def transform_links_to_line(mo_locations)
  26          ASSERT.kind_of mo_locations, MOL::SetOfLocation
  27 
  28          MDL::SeqOfLine.new(
  29              mo_locations.sort.map { |mo_location|
  30                  transform_link_to_line(mo_location)
  31              }
  32          )
  33      end
  34 
  35 
  36      def transform_link_to_line(mo_location)
  37          ASSERT.kind_of mo_location, MOL::Location
  38 
  39          MDL::Line.new mo_location.a_file.name, mo_location.line_num
  40      end
  41 
  42 
  43      def transform_link_to_module(mo_module)
  44          ASSERT.kind_of mo_module,   MOLA::GenericModule
  45 
  46          args = [mo_module.name, Path.transform(mo_module.above_path)]
  47 
  48          md_link_to_module =
  49              if mo_module.kind_of? MOLA::GenericClass
  50                  if mo_module.kind_of? MOLN::UnknownClass
  51                      MDL::UnknownClass.new *args
  52                  else
  53                      MDL::Class.new *args
  54                  end
  55              else
  56                  case mo_module
  57                  when MOLN::ToplevelModule
  58                      MDL::ToplevelModule.new *args
  59                  when MOLN::BuiltinModule
  60                      MDL::BuiltinModule.new *args
  61                  when MOLN::UnknownModule
  62                      MDL::UnknownModule.new *args
  63                  else
  64                      MDL::Module.new *args
  65                  end
  66              end
  67 
  68          ASSERT.kind_of md_link_to_module, MDL::Module
  69      end
  70 
  71 
  72      def transform_link_to_property(mo_property)
  73          ASSERT.kind_of mo_property, MOLA::Property
  74 
  75          MDL::Property.new(
  76              Path.transform(mo_property.above_path),
  77              mo_property.name,
  78              mo_property.uniq_num
  79          )
  80      end
  81  end
  82 
  83  end # TmDoc::Transformer::ObjectIntoDocument
  84 
  85  end # TmDoc