1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 # UML generator in dot format.
22 redef class ToolContext
24 # Phase that generates UML diagrams from model entities.
25 var umlphase
: Phase = new UMLPhase(self, null)
28 var opt_gen
= new OptionEnum(["class", "package"], "Choose which type of uml diagram to generate", 0, "--diagram")
31 var opt_privacy
= new OptionBool("Generates private API", "-p", "--private")
34 option_context
.add_option opt_gen
35 option_context
.add_option opt_privacy
40 private class UMLPhase
42 redef fun process_mainmodule
(mainmodule
, mmodules
)
44 var view
= new ModelView(mainmodule
.model
)
45 if not toolcontext
.opt_privacy
.value
then
46 view
.min_visibility
= protected_visibility
49 var d
= new UMLModel(view
, mainmodule
)
50 if toolcontext
.opt_gen
.value
== 0 then
51 print d
.generate_class_uml
.write_to_string
52 else if toolcontext
.opt_gen
.value
== 1 then
53 print d
.generate_package_uml
.write_to_string
59 var toolcontext
= new ToolContext
60 toolcontext
.process_options
(args
)
61 var arguments
= toolcontext
.option_context
.rest
65 var mbuilder
= new ModelBuilder(model
, toolcontext
)
66 var mmodules
= mbuilder
.parse_full
(arguments
)
68 if mmodules
.is_empty
then return
70 toolcontext
.run_global_phases
(mmodules
)