Writable
UML Class diagram from self
redef fun tpl_class(model) do
var name = name.escape_to_dot
var t = new Template
t.add "{name} [\n label = \"\{"
if kind == abstract_kind then
t.add "abstract\\n{name}"
else if kind == interface_kind then
t.add "interface\\n{name}"
else
t.add "{name}"
end
if arity > 0 then
t.add "["
t.add mparameters.first.name
for i in [1 .. mparameters.length[ do
t.add ", "
t.add mparameters[i].name
end
t.add "]"
end
t.add "|"
var props = collect_intro_mproperties(model.filter)
for i in props do
if not i isa MAttribute then continue
t.add i.tpl_class(model)
t.add "\\l"
end
t.add "|"
for i in props do
if not i isa MMethod then continue
t.add i.tpl_class(model)
t.add "\\l"
end
t.add "\}\"\n]\n"
var g = in_hierarchy(model.mainmodule).direct_greaters
for i in g do
if not model.filter.accept_mentity(i) then continue
t.add "{i.name} -> {name} [dir=back"
if i.kind == interface_kind then
t.add " arrowtail=open style=dashed"
else
t.add " arrowtail=empty"
end
t.add "];\n"
end
return t
end
src/uml/uml_class.nit:54,2--100,4
redef fun tpl_class(model) do
var t = new Template
t.add "("
var params = new Array[MParameter]
for i in mparameters do
params.add i
end
if params.length > 0 then
t.add params.first.name.escape_to_dot
t.add ": "
t.add params.first.mtype.tpl_class(model)
for i in [1 .. params.length [ do
t.add ", "
t.add params[i].name.escape_to_dot
t.add ": "
t.add params[i].mtype.tpl_class(model)
end
end
t.add ")"
if return_mtype != null then
t.add ": "
t.add return_mtype.tpl_class(model)
end
return t
end
src/uml/uml_class.nit:117,2--141,4