PageRenderTime 14ms CodeModel.GetById 11ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/tutorial/external_tool/eiffeldoc_like.e

http://github.com/tybor/Liberty
Specman e | 108 lines | 82 code | 17 blank | 9 comment | 8 complexity | 6f4b9a1e353aace6b5986a88a7dac711 MD5 | raw file
  1class EIFFELDOC_LIKE
  2   -- This example illustrates how to make a tool that works like eiffeldoc.
  3   -- It lists all the classes of all clusters
  4   --*** Currently broken. You'll probably want to use CLUSTER.read_classes and then find some way to get at the
  5   --*** data in CLUSTER.pool . ACE.for_all and ACE.for_all_clusters may be helpful in the process. <FM-30/07/2007>
  6
  7inherit
  8   CLUSTER_VISITOR
  9   VISITOR
 10
 11insert
 12   EXTERNAL_TOOL
 13
 14create {ANY}
 15   make
 16
 17feature {}
 18   make
 19      do
 20         root_class_name := as_any
 21         bootstrap
 22         ace.for_all_clusters(agent visit_cluster(?))
 23      end
 24
 25   parse_arguments
 26      local
 27         argi: INTEGER; arg: STRING
 28      do
 29         -- Only called in non-ace mode
 30         search_for_verbose_flag
 31         from
 32            argi := 1
 33         until
 34            argi > argument_count
 35         loop
 36            arg := argument(argi)
 37            -- The `is_xxx_flag' functions have side effects (they are not pure queries)
 38            if is_help_flag(arg) then
 39            elseif is_version_flag(arg) then
 40            elseif is_verbose_flag(arg) then
 41            elseif is_style_warning_flag(arg) then
 42            elseif is_no_warning_flag(arg) then
 43            elseif add_loadpath(arg) then
 44            else
 45               system_tools.bad_use_exit(command_name, usage)
 46            end
 47
 48            argi := argi + 1
 49         end
 50      end
 51
 52   add_loadpath (loadpath: STRING): BOOLEAN
 53      do
 54         if loadpath.has_suffix(once ".ace") or else loadpath.has_suffix(once ".ACE") then
 55            -- nothing to do: bootstrap takes care of that
 56            Result := True
 57         elseif loadpath.has_suffix(once ".se") or else loadpath.has_suffix(once ".SE") then
 58            system_tools.add_loadpath_file(loadpath)
 59            Result := True
 60         end
 61      end
 62
 63   is_valid_argument_for_ace_mode (arg: STRING): BOOLEAN
 64      do
 65         -- This is called by smart_eiffel.ace from a loop similar to the one in parse_arguments
 66         Result := is_version_flag(arg) or else is_style_warning_flag(arg) or else is_no_warning_flag(arg) or else is_verbose_flag(arg)
 67      end
 68
 69   valid_argument_for_ace_mode: STRING "Only the flags -verbose, -version and -help are allowed%Nin ACE file mode.%N"
 70
 71   use_short_mode: BOOLEAN True
 72
 73   usage: STRING "[
 74   Usage: eiffeldoc_like [options] <LoadPathFileName>.se ...
 75      or: eiffeldoc_like [options] <ACEfileName>.ace
 76
 77    Option summary:
 78
 79    Information:
 80      -help               Display this help information
 81      -version            Display Liberty Eiffel version information
 82      -verbose            Display detailed information about what
 83                           eiffeldoc_like is doing
 84
 85    Warning levels:
 86      -style_warning      Print warnings about style violations
 87      -no_warning         Don't print any warnings
 88
 89   ]"
 90
 91feature {CLUSTER}
 92   visit_cluster (a_cluster: CLUSTER)
 93         -- For each class in `a_cluster' print its name
 94      local
 95         path: STRING; directory: DIRECTORY
 96      do
 97         io.put_string(once "Cluster: ")
 98         io.put_line(a_cluster.name)
 99         path := a_cluster.directory_path
100         if path /= Void and then not path.is_empty then
101            create directory.scan(path)
102            directory.for_each(agent io.put_line(?))
103         else
104            io.put_line(once "Path void or empty")
105         end
106      end
107
108end -- class EIFFELDOC_LIKE