feat: add the uml generator

This commit is contained in:
Michel Jonathan Schmitz
2019-05-27 13:10:41 +02:00
parent a9c0fddb23
commit 0f21da4a92
24 changed files with 2310 additions and 96 deletions

34
test/model/TestClass.ts Normal file
View File

@@ -0,0 +1,34 @@
/*
* Copyright (C) 2018-2019 StApps
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {TestFirstUnion} from './TestUnion';
export class TestClass<T> {
test2: T;
test4: TestFirstUnion;
constructor(type: T) {
this.test2 = type;
this.test4 = 'test1';
}
/**
* Should not be processed at all
*/
testClassFunction(): boolean {
return true;
}
}
export class TestSecondClass extends TestClass<string> {}

25
test/model/TestEnum.ts Normal file
View File

@@ -0,0 +1,25 @@
/*
* Copyright (C) 2018-2019 StApps
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
export enum TestFirstEnum {
TEST1,
TEST2,
TEST3,
}
export enum TestSecondEnum {
TEST1 = 'one',
TEST2 = 'two',
TEST3 = 'three',
}

View File

@@ -0,0 +1,17 @@
/*
* Copyright (C) 2018-2019 StApps
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
export function testFunction(): boolean {
return true;
}

View File

@@ -0,0 +1,34 @@
/*
* Copyright (C) 2018-2019 StApps
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {TestClass, TestSecondClass} from './TestClass';
import {TestFirstEnum} from './TestEnum';
import {TestThirdUnion} from './TestUnion';
export interface TestInterface {
articleBody: string[];
categorySpecificValues?: { [s: string]: string };
inputType: 'multipleChoice';
maintainer: TestThirdUnion | TestFirstEnum;
remainingAttendeeCapacity?: number;
test1: Array<TestThirdUnion | typeof TestFirstEnum>;
test2: TestClass<string>;
test3: 'test1' | 'test2';
test4: TestSecondClass;
universityRole: keyof TestFirstEnum;
}
export interface TestSecondInterface {
[k: string]: string;
}

24
test/model/TestUnion.ts Normal file
View File

@@ -0,0 +1,24 @@
/*
* Copyright (C) 2018-2019 StApps
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
export type TestFirstUnion = 'test1' | 'test2';
export type TestSecondUnion = 'test3';
export type TestThirdUnion = TestFirstUnion | TestSecondUnion;
export type TestFourthUnion<T extends TestFirstUnion> = T extends TestFirstUnion
? TestFirstUnion
: never;

View File

@@ -0,0 +1,552 @@
/*
* Copyright (C) 2019 StApps
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {LightweightClassDefinition} from '../../src/uml/model/LightweightClassDefinition';
import {LightweightDefinition} from '../../src/uml/model/LightweightDefinition';
import {LightweightEnumDefinition} from '../../src/uml/model/LightweightEnumDefinition';
export const generatedModel: Array<
LightweightDefinition | LightweightClassDefinition | LightweightEnumDefinition
> = [
{
name: 'TestClass',
type: 'class',
properties: [
{
name: 'test2',
optional: false,
inherited: false,
type: {
hasTypeInformation: true,
isArray: false,
isLiteral: false,
isPrimitive: false,
isReference: false,
isReflection: false,
isTyped: false,
isTypeParameter: true,
isUnion: false,
specificationTypes: [],
genericsTypes: [],
name: 'T',
},
},
{
name: 'test4',
optional: false,
inherited: false,
type: {
hasTypeInformation: true,
isArray: false,
isLiteral: false,
isPrimitive: false,
isReference: true,
isReflection: false,
isTyped: false,
isTypeParameter: false,
isUnion: false,
specificationTypes: [],
genericsTypes: [],
name: 'TestFirstUnion',
},
},
],
extendedDefinitions: [],
implementedDefinitions: [],
typeParameters: ['T'],
},
{
name: 'TestSecondClass',
type: 'class',
properties: [
{
name: 'test2',
optional: false,
inherited: true,
type: {
hasTypeInformation: true,
isArray: false,
isLiteral: false,
isPrimitive: true,
isReference: false,
isReflection: false,
isTyped: false,
isTypeParameter: false,
isUnion: false,
specificationTypes: [],
genericsTypes: [],
name: 'string',
},
},
{
name: 'test4',
optional: false,
inherited: true,
type: {
hasTypeInformation: true,
isArray: false,
isLiteral: false,
isPrimitive: false,
isReference: true,
isReflection: false,
isTyped: false,
isTypeParameter: false,
isUnion: false,
specificationTypes: [],
genericsTypes: [],
name: 'TestFirstUnion',
},
},
],
extendedDefinitions: ['TestClass'],
implementedDefinitions: [],
typeParameters: [],
},
{
name: 'TestFirstEnum',
values: ['TEST1', 'TEST2', 'TEST3'],
},
{
name: 'TestSecondEnum',
values: ['TEST1 = "one"', 'TEST2 = "two"', 'TEST3 = "three"'],
},
{
name: 'TestInterface',
type: 'interface',
properties: [
{
name: 'articleBody',
optional: false,
inherited: false,
type: {
hasTypeInformation: false,
isArray: true,
isLiteral: false,
isPrimitive: false,
isReference: false,
isReflection: false,
isTyped: false,
isTypeParameter: false,
isUnion: false,
specificationTypes: [
{
hasTypeInformation: true,
isArray: false,
isLiteral: false,
isPrimitive: true,
isReference: false,
isReflection: false,
isTyped: false,
isTypeParameter: false,
isUnion: false,
specificationTypes: [],
genericsTypes: [],
name: 'string',
},
],
genericsTypes: [],
name: 'string',
},
},
{
name: 'categorySpecificValues',
optional: true,
inherited: false,
type: {
hasTypeInformation: false,
isArray: false,
isLiteral: false,
isPrimitive: false,
isReference: false,
isReflection: false,
isTyped: false,
isTypeParameter: false,
isUnion: true,
specificationTypes: [
{
hasTypeInformation: true,
isArray: false,
isLiteral: false,
isPrimitive: true,
isReference: false,
isReflection: false,
isTyped: false,
isTypeParameter: false,
isUnion: false,
specificationTypes: [],
genericsTypes: [],
name: 'undefined',
},
{
hasTypeInformation: false,
isArray: false,
isLiteral: false,
isPrimitive: false,
isReference: false,
isReflection: true,
isTyped: false,
isTypeParameter: false,
isUnion: false,
specificationTypes: [],
genericsTypes: [],
name: 'object',
},
],
genericsTypes: [],
name: '',
},
},
{
name: 'inputType',
optional: false,
inherited: false,
type: {
hasTypeInformation: true,
isArray: false,
isLiteral: true,
isPrimitive: false,
isReference: false,
isReflection: false,
isTyped: false,
isTypeParameter: false,
isUnion: false,
specificationTypes: [],
genericsTypes: [],
name: 'multipleChoice',
},
},
{
name: 'maintainer',
optional: false,
inherited: false,
type: {
hasTypeInformation: false,
isArray: false,
isLiteral: false,
isPrimitive: false,
isReference: false,
isReflection: false,
isTyped: false,
isTypeParameter: false,
isUnion: true,
specificationTypes: [
{
hasTypeInformation: true,
isArray: false,
isLiteral: false,
isPrimitive: false,
isReference: true,
isReflection: false,
isTyped: false,
isTypeParameter: false,
isUnion: false,
specificationTypes: [],
genericsTypes: [],
name: 'TestThirdUnion',
},
{
hasTypeInformation: true,
isArray: false,
isLiteral: false,
isPrimitive: false,
isReference: true,
isReflection: false,
isTyped: false,
isTypeParameter: false,
isUnion: false,
specificationTypes: [],
genericsTypes: [],
name: 'TestFirstEnum',
},
],
genericsTypes: [],
name: '',
},
},
{
name: 'remainingAttendeeCapacity',
optional: true,
inherited: false,
type: {
hasTypeInformation: false,
isArray: false,
isLiteral: false,
isPrimitive: false,
isReference: false,
isReflection: false,
isTyped: false,
isTypeParameter: false,
isUnion: true,
specificationTypes: [
{
hasTypeInformation: true,
isArray: false,
isLiteral: false,
isPrimitive: true,
isReference: false,
isReflection: false,
isTyped: false,
isTypeParameter: false,
isUnion: false,
specificationTypes: [],
genericsTypes: [],
name: 'undefined',
},
{
hasTypeInformation: true,
isArray: false,
isLiteral: false,
isPrimitive: true,
isReference: false,
isReflection: false,
isTyped: false,
isTypeParameter: false,
isUnion: false,
specificationTypes: [],
genericsTypes: [],
name: 'number',
},
],
genericsTypes: [],
name: '',
},
},
{
name: 'test1',
optional: false,
inherited: false,
type: {
hasTypeInformation: true,
isArray: false,
isLiteral: false,
isPrimitive: false,
isReference: false,
isReflection: false,
isTyped: true,
isTypeParameter: false,
isUnion: false,
specificationTypes: [],
genericsTypes: [
{
hasTypeInformation: false,
isArray: false,
isLiteral: false,
isPrimitive: false,
isReference: false,
isReflection: false,
isTyped: false,
isTypeParameter: false,
isUnion: true,
specificationTypes: [
{
hasTypeInformation: true,
isArray: false,
isLiteral: false,
isPrimitive: false,
isReference: true,
isReflection: false,
isTyped: false,
isTypeParameter: false,
isUnion: false,
specificationTypes: [],
genericsTypes: [],
name: 'TestThirdUnion',
},
{
hasTypeInformation: true,
isArray: false,
isLiteral: false,
isPrimitive: false,
isReference: true,
isReflection: false,
isTyped: false,
isTypeParameter: false,
isUnion: false,
specificationTypes: [],
genericsTypes: [],
name: 'TestFirstEnum',
},
],
genericsTypes: [],
name: '',
},
],
name: 'Array',
},
},
{
name: 'test2',
optional: false,
inherited: false,
type: {
hasTypeInformation: true,
isArray: false,
isLiteral: false,
isPrimitive: false,
isReference: true,
isReflection: false,
isTyped: true,
isTypeParameter: false,
isUnion: false,
specificationTypes: [],
genericsTypes: [
{
hasTypeInformation: true,
isArray: false,
isLiteral: false,
isPrimitive: true,
isReference: false,
isReflection: false,
isTyped: false,
isTypeParameter: false,
isUnion: false,
specificationTypes: [],
genericsTypes: [],
name: 'string',
},
],
name: 'TestClass',
},
},
{
name: 'test3',
optional: false,
inherited: false,
type: {
hasTypeInformation: false,
isArray: false,
isLiteral: false,
isPrimitive: false,
isReference: false,
isReflection: false,
isTyped: false,
isTypeParameter: false,
isUnion: true,
specificationTypes: [
{
hasTypeInformation: true,
isArray: false,
isLiteral: true,
isPrimitive: false,
isReference: false,
isReflection: false,
isTyped: false,
isTypeParameter: false,
isUnion: false,
specificationTypes: [],
genericsTypes: [],
name: 'test1',
},
{
hasTypeInformation: true,
isArray: false,
isLiteral: true,
isPrimitive: false,
isReference: false,
isReflection: false,
isTyped: false,
isTypeParameter: false,
isUnion: false,
specificationTypes: [],
genericsTypes: [],
name: 'test2',
},
],
genericsTypes: [],
name: '',
},
},
{
name: 'test4',
optional: false,
inherited: false,
type: {
hasTypeInformation: true,
isArray: false,
isLiteral: false,
isPrimitive: false,
isReference: true,
isReflection: false,
isTyped: false,
isTypeParameter: false,
isUnion: false,
specificationTypes: [],
genericsTypes: [],
name: 'TestSecondClass',
},
},
{
name: 'universityRole',
optional: false,
inherited: false,
type: {
hasTypeInformation: true,
isArray: false,
isLiteral: false,
isPrimitive: true,
isReference: false,
isReflection: false,
isTyped: false,
isTypeParameter: false,
isUnion: false,
specificationTypes: [
{
hasTypeInformation: true,
isArray: false,
isLiteral: false,
isPrimitive: false,
isReference: false,
isReflection: false,
isTyped: false,
isTypeParameter: false,
isUnion: false,
specificationTypes: [],
genericsTypes: [],
name: 'TestFirstEnum',
},
],
genericsTypes: [],
name: 'keyof TestFirstEnum',
},
},
],
extendedDefinitions: [],
implementedDefinitions: [],
typeParameters: [],
},
{
name: 'TestSecondInterface',
type: 'interface',
properties: [],
extendedDefinitions: [],
implementedDefinitions: [],
typeParameters: [],
},
{
name: 'TestFirstUnion',
values: ['test1', 'test2'],
},
{
name: 'TestFourthUnion',
values: [],
},
{
name: 'TestSecondUnion',
values: ['test3'],
},
{
name: 'TestThirdUnion',
values: ['TestFirstUnion', 'TestSecondUnion'],
},
];