/staruml-typescript

Typescript extension for StarUML 3.0

Primary LanguageJavaScriptMIT LicenseMIT

important ! it's a fork of Java Extension for StraUML (https://github.com/staruml/staruml-java)

TypeScript Extension for StarUML

This extension for StarUML(http://staruml.io) support to generate TypeScript code from UML model and to reverse TypeScript code to UML model. Install this extension from Extension Manager of StarUML.

Note This extensions do not provide perfect reverse engineering which is a test and temporal feature. If you need a complete reverse engineering feature, please check other professional reverse engineering tools.

Note This extension is based on TypeScript 1.7 Specification.

TypeScript Code Generation

  1. Click the menu (Tools > TypeScript > Generate Code...)
  2. Select a base model (or package) that will be generated to TypeScript.
  3. Select a folder where generated TypeScript source files will be placed.

Belows are the rules to convert from UML model elements to TypeScript source codes.

UMLClass

  • converted to TypeScript Class. (as a separate .TypeScript file)
  • visibility to one of modifiers public, protected, private and none.
  • isAbstract property to abstract modifier.
  • isFinalSpecialization and isLeaf property to final modifier.
  • Default constructor is generated.
  • All contained types (UMLClass, UMLInterface, UMLEnumeration) are generated as inner type definition.
  • Documentation property to TypeScriptDoc comment.

UMLAttribute

  • converted to TypeScript Field.
  • visibility property to one of modifiers public, protected, private and none.
  • name property to field identifier.
  • type property to field type.
  • multiplicity property to array type.
  • isStatic property to static modifier.
  • isLeaf property to final modifier.
  • defaultValue property to initial value.
  • Documentation property to TypeScriptDoc comment.

UMLOperation

  • converted to TypeScript Methods.
  • visibility property to one of modifiers public, protected, private and none.
  • name property to method identifier.
  • isAbstract property to abstract modifier.
  • isStatic property to static modifier.
  • UMLParameter to TypeScript Method Parameters.
  • UMLParameter's name property to parameter identifier.
  • UMLParameter's type property to type of parameter.
  • UMLParameter with direction = return to return type of method. When no return parameter, void is used.
  • UMLParameter with isReadOnly = true to final modifier of parameter.
  • Documentation property to TypeScriptDoc comment.

UMLInterface

  • converted to TypeScript Interface. (as a separate .TypeScript file)
  • visibility property to one of modifiers public, protected, private and none.
  • Documentation property to TypeScriptDoc comment.

UMLEnumeration

  • converted to TypeScript Enum. (as a separate .TypeScript file)
  • visibility property to one of modifiers public, protected, private and none.
  • UMLEnumerationLiteral to literals of enum.

UMLAssociationEnd

  • converted to TypeScript Field.
  • visibility property to one of modifiers public, protected, private and none.
  • name property to field identifier.
  • type property to field type.
  • If multiplicity is one of 0..*, 1..*, *, then collection type (TypeScript.util.List<> when isOrdered = true or TypeScript.util.Set<>) is used.
  • defaultValue property to initial value.
  • Documentation property to TypeScriptDoc comment.

UMLGeneralization

  • converted to TypeScript Extends (extends).
  • Allowed only for UMLClass to UMLClass, and UMLInterface to UMLInterface.

UMLInterfaceRealization

  • converted to TypeScript Implements (implements).
  • Allowed only for UMLClass to UMLInterface.

TypeScript Reverse Engineering

  1. Click the menu (Tools > TypeScript > Reverse Code...)
  2. Select a folder containing TypeScript source files to be converted to UML model elements.
  3. TypeScriptReverse model will be created in the Project.

Belows are the rules to convert from TypeScript source code to UML model elements.

TypeScript Package

  • converted to UMLPackage.

TypeScript Class

  • converted to UMLClass.
  • Class name to name property.
  • Type parameters to UMLTemplateParameter.
  • Access modifier public, protected and private to visibility property.
  • abstract modifier to isAbstract property.
  • final modifier to isLeaf property.
  • Constructors to UMLOperation with stereotype <<constructor>>.
  • All contained types (UMLClass, UMLInterface, UMLEnumeration) are generated as inner type definition.
  • TypeScriptDoc comment to Documentation.

TypeScript Field (to UMLAttribute)

  • converted to UMLAttribute if "Use Association" is off in Preferences.

  • Field type to type property.

    • Primitive Types : type property has the primitive type name as string.
    • T[](array), TypeScript.util.List<T>, TypeScript.util.Set<T> or its decendants: type property refers to T with multiplicity *.
    • T (User-Defined Types) : type property refers to the T type.
    • Otherwise : type property has the type name as string.
  • Access modifier public, protected and private to visibility property.

  • static modifier to isStatic property.

  • final modifier to isLeaf and isReadOnly property.

  • transient modifier to a Tag with name="transient" and checked=true .

  • volatile modifier to a Tag with name="volatile" and checked=true.

  • Initial value to defaultValue property.

  • TypeScriptDoc comment to Documentation.

TypeScript Field (to UMLAssociation)

  • converted to (Directed) UMLAssociation if "Use Association" is on in Preferences and there is a UML type element (UMLClass, UMLInterface, or UMLEnumeration) correspond to the field type.

  • Field type to end2.reference property.

    • T[](array), TypeScript.util.List<T>, TypeScript.util.Set<T> or its decendants: reference property refers to T with multiplicity *.
    • T (User-Defined Types) : reference property refers to the T type.
    • Otherwise : converted to UMLAttribute, not UMLAssociation.
  • Access modifier public, protected and private to visibility property.

  • TypeScriptDoc comment to Documentation.

TypeScript Method

  • converted to UMLOperation.
  • Type parameters to UMLTemplateParameter.
  • Access modifier public, protected and private to visibility property.
  • static modifier to isStatic property.
  • abstract modifier to isAbstract property.
  • final modifier to isLeaf property.
  • synchronized modifier to concurrency="concurrent" property.
  • native modifier to a Tag with name="native" and checked=true.
  • strictfp modifier to a Tag with name="strictfp" and checked=true.
  • throws clauses to raisedExceptions property.
  • TypeScriptDoc comment to Documentation.

TypeScript Interface

  • converted to UMLInterface.
  • Class name to name property.
  • Type parameters to UMLTemplateParameter.
  • Access modifier public, protected and private to visibility property.
  • TypeScriptDoc comment to Documentation.

TypeScript Enum

  • converted to UMLEnumeration.
  • Enum name to name property.
  • Type parameters to UMLTemplateParameter.
  • Access modifier public, protected and private to visibility property.
  • Enum constants are converted to UMLEnumerationLiteral.
  • TypeScriptDoc comment to Documentation.

TypeScript AnnotationType

  • converted to UMLClass with stereotype <<annotationType>>.
  • Annotation type elements to UMLOperation. (Default value to a Tag with name="default").
  • TypeScriptDoc comment to Documentation.

Licensed under the MIT license (see LICENSE file).