Provides facilities of exporting a Model to a UML class diagram

Redefined classes

redef class MAttribute

nitc :: uml_class $ MAttribute

A global attribute
redef class MClass

nitc :: uml_class $ MClass

A named class
redef class MClassType

nitc :: uml_class $ MClassType

A type based on a class.
redef abstract class MEntity

nitc :: uml_class $ MEntity

A named and possibly documented entity in the model.
redef class MGenericType

nitc :: uml_class $ MGenericType

A type based on a generic class.
redef class MMethod

nitc :: uml_class $ MMethod

A global method
redef class MNullableType

nitc :: uml_class $ MNullableType

A type prefixed with "nullable"
redef class MParameterType

nitc :: uml_class $ MParameterType

The type associated to a formal parameter generic type of a class
redef class MSignature

nitc :: uml_class $ MSignature

A signature of a method
redef class MVirtualType

nitc :: uml_class $ MVirtualType

A virtual formal type.
redef class MVisibility

nitc :: uml_class $ MVisibility

A visibility (for modules, class and properties)
redef class UMLModel

nitc :: uml_class $ UMLModel

UML model builder.

All class definitions

redef class MAttribute

nitc :: uml_class $ MAttribute

A global attribute
redef class MClass

nitc :: uml_class $ MClass

A named class
redef class MClassType

nitc :: uml_class $ MClassType

A type based on a class.
redef abstract class MEntity

nitc :: uml_class $ MEntity

A named and possibly documented entity in the model.
redef class MGenericType

nitc :: uml_class $ MGenericType

A type based on a generic class.
redef class MMethod

nitc :: uml_class $ MMethod

A global method
redef class MNullableType

nitc :: uml_class $ MNullableType

A type prefixed with "nullable"
redef class MParameterType

nitc :: uml_class $ MParameterType

The type associated to a formal parameter generic type of a class
redef class MSignature

nitc :: uml_class $ MSignature

A signature of a method
redef class MVirtualType

nitc :: uml_class $ MVirtualType

A virtual formal type.
redef class MVisibility

nitc :: uml_class $ MVisibility

A visibility (for modules, class and properties)
redef class UMLModel

nitc :: uml_class $ UMLModel

UML model builder.
package_diagram nitc::uml_class uml_class nitc::uml_base uml_base nitc::uml_class->nitc::uml_base nitc::model_collect model_collect nitc::uml_base->nitc::model_collect ...nitc::model_collect ... ...nitc::model_collect->nitc::model_collect nitc::uml_module uml_module nitc::uml_module->nitc::uml_class nitc::uml uml nitc::uml->nitc::uml_module nitc::uml... ... nitc::uml...->nitc::uml

Ancestors

module abstract_collection

core :: abstract_collection

Abstract collection classes and services.
module abstract_text

core :: abstract_text

Abstract class for manipulation of sequences of characters
module annotation

nitc :: annotation

Management and utilities on annotations
module array

core :: array

This module introduces the standard array structure.
module bitset

core :: bitset

Services to handle BitSet
module bytes

core :: bytes

Services for byte streams and arrays
module caching

serialization :: caching

Services for caching serialization engines
module circular_array

core :: circular_array

Efficient data structure to access both end of the sequence.
module codec_base

core :: codec_base

Base for codecs to use with streams
module codecs

core :: codecs

Group module for all codec-related manipulations
module collection

core :: collection

This module define several collection classes.
module console

console :: console

Defines some ANSI Terminal Control Escape Sequences.
module core

core :: core

Standard classes and methods used by default by Nit programs and libraries.
module digraph

graph :: digraph

Implementation of directed graphs, also called digraphs.
module engine_tools

serialization :: engine_tools

Advanced services for serialization engines
module environ

core :: environ

Access to the environment variables of the process
module error

core :: error

Standard error-management infrastructure.
module exec

core :: exec

Invocation and management of operating system sub-processes.
module file

core :: file

File manipulations (create, read, write, etc.)
module fixed_ints

core :: fixed_ints

Basic integers of fixed-precision
module fixed_ints_text

core :: fixed_ints_text

Text services to complement fixed_ints
module flat

core :: flat

All the array-based text representations
module gc

core :: gc

Access to the Nit internal garbage collection mechanism
module hash_collection

core :: hash_collection

Introduce HashMap and HashSet.
module ini

ini :: ini

Read and write INI configuration files
module inspect

serialization :: inspect

Refine Serializable::inspect to show more useful information
module iso8859_1

core :: iso8859_1

Codec for ISO8859-1 I/O
module kernel

core :: kernel

Most basic classes and methods.
module lexer

nitc :: lexer

Lexer and its tokens.
module lexer_work

nitc :: lexer_work

Internal algorithm and data structures for the Nit lexer
module list

core :: list

This module handle double linked lists
module literal

nitc :: literal

Parsing of literal values in the abstract syntax tree.
module loader

nitc :: loader

Loading of Nit source files
module location

nitc :: location

Nit source-file and locations in source-file
module math

core :: math

Mathematical operations
module mdoc

nitc :: mdoc

Documentation of model entities
module meta

meta :: meta

Simple user-defined meta-level to manipulate types of instances as object.
module mmodule

nitc :: mmodule

modules and module hierarchies in the metamodel
module mmodule_data

nitc :: mmodule_data

Define and retrieve data in modules
module model

nitc :: model

Classes, types and properties
module model_base

nitc :: model_base

The abstract concept of model and related common things
module model_collect

nitc :: model_collect

Collect things from the model.
module model_examples

nitc :: model_examples

Examples for Model entities
module modelbuilder_base

nitc :: modelbuilder_base

Load nit source files and build the associated model
module modelize_class

nitc :: modelize_class

Analysis and verification of class definitions to instantiate model element
module modelize_property

nitc :: modelize_property

Analysis and verification of property definitions to instantiate model element
module more_collections

more_collections :: more_collections

Highly specific, but useful, collections-related classes.
module mpackage

nitc :: mpackage

Modelisation of a Nit package
module native

core :: native

Native structures for text and bytes
module nitpm_shared

nitc :: nitpm_shared

Services related to the Nit package manager
module numeric

core :: numeric

Advanced services for Numeric types
module opts

opts :: opts

Management of options on the command line
module ordered_tree

ordered_tree :: ordered_tree

Manipulation and presentation of ordered trees.
module parse_annotations

nitc :: parse_annotations

Simple annotation parsing
module parser

nitc :: parser

Parser.
module parser_nodes

nitc :: parser_nodes

AST nodes of the Nit language
module parser_prod

nitc :: parser_prod

Production AST nodes full definition.
module parser_work

nitc :: parser_work

Internal algorithm and data structures for the Nit parser
module phase

nitc :: phase

Phases of the processing of nit programs
module poset

poset :: poset

Pre order sets and partial order set (ie hierarchies)
module protocol

core :: protocol

module queue

core :: queue

Queuing data structures and wrappers
module range

core :: range

Module for range of discrete objects.
module re

core :: re

Regular expression support for all services based on Pattern
module ropes

core :: ropes

Tree-based representation of a String.
module serialization

serialization :: serialization

General serialization services
module serialization_core

serialization :: serialization_core

Abstract services to serialize Nit objects to different formats
module sorter

core :: sorter

This module contains classes used to compare things and sorts arrays.
module stream

core :: stream

Input and output streams of characters
module tables

nitc :: tables

Module that interfaces the parsing tables.
module template

template :: template

Basic template system
module text

core :: text

All the classes and methods related to the manipulation of text entities
module time

core :: time

Management of time and dates
module toolcontext

nitc :: toolcontext

Common command-line tool infrastructure than handle options and error messages
module union_find

core :: union_find

union–find algorithm using an efficient disjoint-set data structure
module utf8

core :: utf8

Codec for UTF-8 I/O
module version

nitc :: version

This file was generated by git-gen-version.sh

Parents

module uml_base

nitc :: uml_base

Exposes the base class for UML generation of a Model

Children

module uml_module

nitc :: uml_module

Services for generation of a UML package diagram based on a Model

Descendants

module a_star-m

a_star-m

module api

nitc :: api

Components required to build a web server about the nit model.
module api_auth

nitc :: api_auth

module api_base

nitc :: api_base

Base classes used by nitweb.
module api_docdown

nitc :: api_docdown

Nitdoc specific Markdown format handling for Nitweb
module api_feedback

nitc :: api_feedback

Feedback related features
module api_light

nitc :: api_light

Highlight and collect messages from a piece of code
module api_model

nitc :: api_model

module commands_docdown

nitc :: commands_docdown

Doc down related queries
module commands_graph

nitc :: commands_graph

Graph commands
module commands_http

nitc :: commands_http

Initialize commands from HTTP requests
module commands_parser

nitc :: commands_parser

A parser that create DocCommand from a string
module html_commands

nitc :: html_commands

Render commands results as HTML
module json_commands

nitc :: json_commands

Translate command results to json
module md_commands

nitc :: md_commands

Render commands results as Markdown
module nitdoc

nitc :: nitdoc

Generator of static API documentation for the Nit language
module nituml

nitc :: nituml

UML generator in dot format.
module nitweb

nitc :: nitweb

Runs a webserver based on nitcorn that render things from model.
module nitx

nitc :: nitx

nitx, a command tool that displays useful data about Nit code
module static

nitc :: static

Nitdoc generation framework
module static_base

nitc :: static_base

Base entities shared by all the nitdoc code
module static_cards

nitc :: static_cards

Cards templates for the static documentation
module static_html

nitc :: static_html

Render documentation pages as HTML
module static_index

nitc :: static_index

Manage indexing of Nit model for Nitdoc QuickSearch.
module static_structure

nitc :: static_structure

Composes the pages of the static documentation
module term

nitc :: term

module uml

nitc :: uml

Group head module for UML generation services
# Provides facilities of exporting a `Model` to a UML class diagram
module uml_class

import uml_base
import model::model_collect

redef class UMLModel
	# Generates a UML class diagram from a `Model`
	fun generate_class_uml: Writable do
		var tpl = new Template
		tpl.add "digraph G \{\n"
		tpl.add """	fontname = "Bitstream Vera Sans"
				fontsize = 8
				node [
					fontname = "Bitstream Vera Sans"
					fontsize = 8
					shape = "record"
				]

				edge [
					fontname = "Bitstream Vera Sans"
					fontsize = 8
				]\n"""
		for mclass in model.collect_mclasses(filter) do
			tpl.add mclass.tpl_class(self)
			tpl.add "\n"
		end
		tpl.add "\}"
		return tpl
	end
end

redef class MEntity
	# Generates a dot-compatible `Writable` UML Class diagram from `self`
	fun tpl_class(model: UMLModel): Writable is abstract
end

redef class MClass

	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

end

redef class MMethod
	redef fun tpl_class(model) do
		var tpl = new Template
		tpl.add visibility.tpl_class
		tpl.add " "
		tpl.add name.escape_to_dot
		tpl.add intro.msignature.tpl_class(model)
		return tpl
	end
end

redef class MSignature

	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
end

redef class MAttribute
	redef fun tpl_class(model) do
		var tpl = new Template
		tpl.add visibility.tpl_class
		tpl.add " "
		tpl.add name.escape_to_dot
		tpl.add ": "
		tpl.add intro.static_mtype.tpl_class(model)
		return tpl
	end
end

redef class MVisibility
	# Returns the visibility as a UML token
	#
	#    assert public_visibility.tpl_class == "+"
	#    assert private_visibility.tpl_class == "-"
	fun tpl_class: Writable do
		if self == private_visibility then
			return "-"
		else if self == protected_visibility then
			return "#"
		else if self == public_visibility then
			return "+"
		else
			return "+"
		end
	end
end

redef class MClassType
	redef fun tpl_class(model) do
		return name
	end
end

redef class MGenericType
	redef fun tpl_class(model) do
		var t = new Template
		t.add name.substring(0, name.index_of('['))
		t.add "["
		t.add arguments.first.tpl_class(model)
		for i in [1 .. arguments.length[ do
			t.add ", "
			t.add arguments[i].tpl_class(model)
		end
		t.add "]"
		return t
	end
end

redef class MParameterType
	redef fun tpl_class(model) do
		return name
	end
end

redef class MVirtualType
	redef fun tpl_class(model) do
		return name
	end
end

redef class MNullableType
	redef fun tpl_class(model) do
		var t = new Template
		t.add "nullable "
		t.add mtype.tpl_class(model)
		return t
	end
end
src/uml/uml_class.nit:15,1--214,3