@finos/legend-application-pure-ide 6.2.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +3 -0
- package/lib/application/LegendPureIDE.d.ts +26 -0
- package/lib/application/LegendPureIDE.d.ts.map +1 -0
- package/lib/application/LegendPureIDE.js +43 -0
- package/lib/application/LegendPureIDE.js.map +1 -0
- package/lib/application/LegendPureIDEApplicationConfig.d.ts +28 -0
- package/lib/application/LegendPureIDEApplicationConfig.d.ts.map +1 -0
- package/lib/application/LegendPureIDEApplicationConfig.js +30 -0
- package/lib/application/LegendPureIDEApplicationConfig.js.map +1 -0
- package/lib/application/LegendPureIDEPluginManager.d.ts +32 -0
- package/lib/application/LegendPureIDEPluginManager.d.ts.map +1 -0
- package/lib/application/LegendPureIDEPluginManager.js +46 -0
- package/lib/application/LegendPureIDEPluginManager.js.map +1 -0
- package/lib/components/Core_LegendPureIDEApplicationPlugin.d.ts +23 -0
- package/lib/components/Core_LegendPureIDEApplicationPlugin.d.ts.map +1 -0
- package/lib/components/Core_LegendPureIDEApplicationPlugin.js +29 -0
- package/lib/components/Core_LegendPureIDEApplicationPlugin.js.map +1 -0
- package/lib/components/LegendPureIDEApplication.d.ts +18 -0
- package/lib/components/LegendPureIDEApplication.d.ts.map +1 -0
- package/lib/components/LegendPureIDEApplication.js +21 -0
- package/lib/components/LegendPureIDEApplication.js.map +1 -0
- package/lib/components/LegendPureIDEBaseStoreProvider.d.ts +23 -0
- package/lib/components/LegendPureIDEBaseStoreProvider.d.ts.map +1 -0
- package/lib/components/LegendPureIDEBaseStoreProvider.js +30 -0
- package/lib/components/LegendPureIDEBaseStoreProvider.js.map +1 -0
- package/lib/components/editor/ActivityBar.d.ts +20 -0
- package/lib/components/editor/ActivityBar.d.ts.map +1 -0
- package/lib/components/editor/ActivityBar.js +41 -0
- package/lib/components/editor/ActivityBar.js.map +1 -0
- package/lib/components/editor/Editor.d.ts +18 -0
- package/lib/components/editor/Editor.d.ts.map +1 -0
- package/lib/components/editor/Editor.js +80 -0
- package/lib/components/editor/Editor.js.map +1 -0
- package/lib/components/editor/EditorStoreProvider.d.ts +22 -0
- package/lib/components/editor/EditorStoreProvider.d.ts.map +1 -0
- package/lib/components/editor/EditorStoreProvider.js +32 -0
- package/lib/components/editor/EditorStoreProvider.js.map +1 -0
- package/lib/components/editor/StatusBar.d.ts +22 -0
- package/lib/components/editor/StatusBar.d.ts.map +1 -0
- package/lib/components/editor/StatusBar.js +39 -0
- package/lib/components/editor/StatusBar.js.map +1 -0
- package/lib/components/editor/aux-panel/AuxiliaryPanel.d.ts +20 -0
- package/lib/components/editor/aux-panel/AuxiliaryPanel.d.ts.map +1 -0
- package/lib/components/editor/aux-panel/AuxiliaryPanel.js +65 -0
- package/lib/components/editor/aux-panel/AuxiliaryPanel.js.map +1 -0
- package/lib/components/editor/aux-panel/ConsolePanel.d.ts +20 -0
- package/lib/components/editor/aux-panel/ConsolePanel.d.ts.map +1 -0
- package/lib/components/editor/aux-panel/ConsolePanel.js +24 -0
- package/lib/components/editor/aux-panel/ConsolePanel.js.map +1 -0
- package/lib/components/editor/aux-panel/SearchPanel.d.ts +20 -0
- package/lib/components/editor/aux-panel/SearchPanel.d.ts.map +1 -0
- package/lib/components/editor/aux-panel/SearchPanel.js +90 -0
- package/lib/components/editor/aux-panel/SearchPanel.js.map +1 -0
- package/lib/components/editor/aux-panel/TestRunnerPanel.d.ts +20 -0
- package/lib/components/editor/aux-panel/TestRunnerPanel.d.ts.map +1 -0
- package/lib/components/editor/aux-panel/TestRunnerPanel.js +151 -0
- package/lib/components/editor/aux-panel/TestRunnerPanel.js.map +1 -0
- package/lib/components/editor/command-center/CreateNewDirectoryCommand.d.ts +20 -0
- package/lib/components/editor/command-center/CreateNewDirectoryCommand.d.ts.map +1 -0
- package/lib/components/editor/command-center/CreateNewDirectoryCommand.js +48 -0
- package/lib/components/editor/command-center/CreateNewDirectoryCommand.js.map +1 -0
- package/lib/components/editor/command-center/CreateNewFileCommand.d.ts +20 -0
- package/lib/components/editor/command-center/CreateNewFileCommand.d.ts.map +1 -0
- package/lib/components/editor/command-center/CreateNewFileCommand.js +48 -0
- package/lib/components/editor/command-center/CreateNewFileCommand.js.map +1 -0
- package/lib/components/editor/command-center/FileSearchCommand.d.ts +20 -0
- package/lib/components/editor/command-center/FileSearchCommand.d.ts.map +1 -0
- package/lib/components/editor/command-center/FileSearchCommand.js +60 -0
- package/lib/components/editor/command-center/FileSearchCommand.js.map +1 -0
- package/lib/components/editor/command-center/TextSearchCommand.d.ts +20 -0
- package/lib/components/editor/command-center/TextSearchCommand.d.ts.map +1 -0
- package/lib/components/editor/command-center/TextSearchCommand.js +50 -0
- package/lib/components/editor/command-center/TextSearchCommand.js.map +1 -0
- package/lib/components/editor/edit-panel/DiagramEditor.d.ts +23 -0
- package/lib/components/editor/edit-panel/DiagramEditor.d.ts.map +1 -0
- package/lib/components/editor/edit-panel/DiagramEditor.js +71 -0
- package/lib/components/editor/edit-panel/DiagramEditor.js.map +1 -0
- package/lib/components/editor/edit-panel/EditPanel.d.ts +21 -0
- package/lib/components/editor/edit-panel/EditPanel.d.ts.map +1 -0
- package/lib/components/editor/edit-panel/EditPanel.js +55 -0
- package/lib/components/editor/edit-panel/EditPanel.js.map +1 -0
- package/lib/components/editor/edit-panel/FileEditor.d.ts +23 -0
- package/lib/components/editor/edit-panel/FileEditor.d.ts.map +1 -0
- package/lib/components/editor/edit-panel/FileEditor.js +114 -0
- package/lib/components/editor/edit-panel/FileEditor.js.map +1 -0
- package/lib/components/editor/shared/ConceptIconUtils.d.ts +17 -0
- package/lib/components/editor/shared/ConceptIconUtils.d.ts.map +1 -0
- package/lib/components/editor/shared/ConceptIconUtils.js +50 -0
- package/lib/components/editor/shared/ConceptIconUtils.js.map +1 -0
- package/lib/components/editor/side-bar/ConceptTreeExplorer.d.ts +24 -0
- package/lib/components/editor/side-bar/ConceptTreeExplorer.d.ts.map +1 -0
- package/lib/components/editor/side-bar/ConceptTreeExplorer.js +165 -0
- package/lib/components/editor/side-bar/ConceptTreeExplorer.js.map +1 -0
- package/lib/components/editor/side-bar/DirectoryTreeExplorer.d.ts +20 -0
- package/lib/components/editor/side-bar/DirectoryTreeExplorer.d.ts.map +1 -0
- package/lib/components/editor/side-bar/DirectoryTreeExplorer.js +142 -0
- package/lib/components/editor/side-bar/DirectoryTreeExplorer.js.map +1 -0
- package/lib/components/editor/side-bar/SideBar.d.ts +23 -0
- package/lib/components/editor/side-bar/SideBar.d.ts.map +1 -0
- package/lib/components/editor/side-bar/SideBar.js +40 -0
- package/lib/components/editor/side-bar/SideBar.js.map +1 -0
- package/lib/extensions.css +17 -0
- package/lib/extensions.css.map +1 -0
- package/lib/index.css +17 -0
- package/lib/index.css.map +1 -0
- package/lib/index.d.ts +22 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +39 -0
- package/lib/index.js.map +1 -0
- package/lib/package.json +85 -0
- package/lib/server/PureServerClient.d.ts +55 -0
- package/lib/server/PureServerClient.d.ts.map +1 -0
- package/lib/server/PureServerClient.js +120 -0
- package/lib/server/PureServerClient.js.map +1 -0
- package/lib/server/models/Command.d.ts +24 -0
- package/lib/server/models/Command.d.ts.map +1 -0
- package/lib/server/models/Command.js +35 -0
- package/lib/server/models/Command.js.map +1 -0
- package/lib/server/models/ConceptTree.d.ts +76 -0
- package/lib/server/models/ConceptTree.d.ts.map +1 -0
- package/lib/server/models/ConceptTree.js +116 -0
- package/lib/server/models/ConceptTree.js.map +1 -0
- package/lib/server/models/DiagramInfo.d.ts +144 -0
- package/lib/server/models/DiagramInfo.d.ts.map +1 -0
- package/lib/server/models/DiagramInfo.js +478 -0
- package/lib/server/models/DiagramInfo.js.map +1 -0
- package/lib/server/models/DirectoryTree.d.ts +37 -0
- package/lib/server/models/DirectoryTree.d.ts.map +1 -0
- package/lib/server/models/DirectoryTree.js +70 -0
- package/lib/server/models/DirectoryTree.js.map +1 -0
- package/lib/server/models/Execution.d.ts +100 -0
- package/lib/server/models/Execution.d.ts.map +1 -0
- package/lib/server/models/Execution.js +183 -0
- package/lib/server/models/Execution.js.map +1 -0
- package/lib/server/models/Initialization.d.ts +49 -0
- package/lib/server/models/Initialization.d.ts.map +1 -0
- package/lib/server/models/Initialization.js +64 -0
- package/lib/server/models/Initialization.js.map +1 -0
- package/lib/server/models/PureFile.d.ts +34 -0
- package/lib/server/models/PureFile.d.ts.map +1 -0
- package/lib/server/models/PureFile.js +56 -0
- package/lib/server/models/PureFile.js.map +1 -0
- package/lib/server/models/SearchEntry.d.ts +36 -0
- package/lib/server/models/SearchEntry.d.ts.map +1 -0
- package/lib/server/models/SearchEntry.js +63 -0
- package/lib/server/models/SearchEntry.js.map +1 -0
- package/lib/server/models/SourceInformation.d.ts +25 -0
- package/lib/server/models/SourceInformation.d.ts.map +1 -0
- package/lib/server/models/SourceInformation.js +35 -0
- package/lib/server/models/SourceInformation.js.map +1 -0
- package/lib/server/models/Test.d.ts +57 -0
- package/lib/server/models/Test.d.ts.map +1 -0
- package/lib/server/models/Test.js +92 -0
- package/lib/server/models/Test.js.map +1 -0
- package/lib/server/models/Usage.d.ts +31 -0
- package/lib/server/models/Usage.d.ts.map +1 -0
- package/lib/server/models/Usage.js +36 -0
- package/lib/server/models/Usage.js.map +1 -0
- package/lib/stores/ConceptTreeState.d.ts +34 -0
- package/lib/stores/ConceptTreeState.d.ts.map +1 -0
- package/lib/stores/ConceptTreeState.js +117 -0
- package/lib/stores/ConceptTreeState.js.map +1 -0
- package/lib/stores/DiagramEditorState.d.ts +40 -0
- package/lib/stores/DiagramEditorState.d.ts.map +1 -0
- package/lib/stores/DiagramEditorState.js +90 -0
- package/lib/stores/DiagramEditorState.js.map +1 -0
- package/lib/stores/DirectoryTreeState.d.ts +35 -0
- package/lib/stores/DirectoryTreeState.d.ts.map +1 -0
- package/lib/stores/DirectoryTreeState.js +119 -0
- package/lib/stores/DirectoryTreeState.js.map +1 -0
- package/lib/stores/EditorConfig.d.ts +25 -0
- package/lib/stores/EditorConfig.d.ts.map +1 -0
- package/lib/stores/EditorConfig.js +27 -0
- package/lib/stores/EditorConfig.js.map +1 -0
- package/lib/stores/EditorStore.d.ts +102 -0
- package/lib/stores/EditorStore.d.ts.map +1 -0
- package/lib/stores/EditorStore.js +761 -0
- package/lib/stores/EditorStore.js.map +1 -0
- package/lib/stores/EditorTabManagerState.d.ts +31 -0
- package/lib/stores/EditorTabManagerState.d.ts.map +1 -0
- package/lib/stores/EditorTabManagerState.js +62 -0
- package/lib/stores/EditorTabManagerState.js.map +1 -0
- package/lib/stores/FileEditorState.d.ts +37 -0
- package/lib/stores/FileEditorState.d.ts.map +1 -0
- package/lib/stores/FileEditorState.js +99 -0
- package/lib/stores/FileEditorState.js.map +1 -0
- package/lib/stores/LegendPureIDEApplicationPlugin.d.ts +26 -0
- package/lib/stores/LegendPureIDEApplicationPlugin.d.ts.map +1 -0
- package/lib/stores/LegendPureIDEApplicationPlugin.js +27 -0
- package/lib/stores/LegendPureIDEApplicationPlugin.js.map +1 -0
- package/lib/stores/LegendPureIDEBaseStore.d.ts +25 -0
- package/lib/stores/LegendPureIDEBaseStore.d.ts.map +1 -0
- package/lib/stores/LegendPureIDEBaseStore.js +25 -0
- package/lib/stores/LegendPureIDEBaseStore.js.map +1 -0
- package/lib/stores/LegendPureIDECommand.d.ts +32 -0
- package/lib/stores/LegendPureIDECommand.d.ts.map +1 -0
- package/lib/stores/LegendPureIDECommand.js +82 -0
- package/lib/stores/LegendPureIDECommand.js.map +1 -0
- package/lib/stores/SearchCommandState.d.ts +28 -0
- package/lib/stores/SearchCommandState.d.ts.map +1 -0
- package/lib/stores/SearchCommandState.js +53 -0
- package/lib/stores/SearchCommandState.js.map +1 -0
- package/lib/stores/SearchResultState.d.ts +43 -0
- package/lib/stores/SearchResultState.d.ts.map +1 -0
- package/lib/stores/SearchResultState.js +92 -0
- package/lib/stores/SearchResultState.js.map +1 -0
- package/lib/stores/TestRunnerState.d.ts +87 -0
- package/lib/stores/TestRunnerState.d.ts.map +1 -0
- package/lib/stores/TestRunnerState.js +336 -0
- package/lib/stores/TestRunnerState.js.map +1 -0
- package/lib/stores/TreeState.d.ts +42 -0
- package/lib/stores/TreeState.d.ts.map +1 -0
- package/lib/stores/TreeState.js +139 -0
- package/lib/stores/TreeState.js.map +1 -0
- package/package.json +85 -0
- package/src/application/LegendPureIDE.tsx +73 -0
- package/src/application/LegendPureIDEApplicationConfig.ts +58 -0
- package/src/application/LegendPureIDEPluginManager.ts +67 -0
- package/src/components/Core_LegendPureIDEApplicationPlugin.tsx +37 -0
- package/src/components/LegendPureIDEApplication.tsx +27 -0
- package/src/components/LegendPureIDEBaseStoreProvider.tsx +57 -0
- package/src/components/editor/ActivityBar.tsx +74 -0
- package/src/components/editor/Editor.tsx +180 -0
- package/src/components/editor/EditorStoreProvider.tsx +57 -0
- package/src/components/editor/StatusBar.tsx +95 -0
- package/src/components/editor/aux-panel/AuxiliaryPanel.tsx +155 -0
- package/src/components/editor/aux-panel/ConsolePanel.tsx +49 -0
- package/src/components/editor/aux-panel/SearchPanel.tsx +421 -0
- package/src/components/editor/aux-panel/TestRunnerPanel.tsx +455 -0
- package/src/components/editor/command-center/CreateNewDirectoryCommand.tsx +86 -0
- package/src/components/editor/command-center/CreateNewFileCommand.tsx +84 -0
- package/src/components/editor/command-center/FileSearchCommand.tsx +112 -0
- package/src/components/editor/command-center/TextSearchCommand.tsx +103 -0
- package/src/components/editor/edit-panel/DiagramEditor.tsx +108 -0
- package/src/components/editor/edit-panel/EditPanel.tsx +114 -0
- package/src/components/editor/edit-panel/FileEditor.tsx +156 -0
- package/src/components/editor/shared/ConceptIconUtils.tsx +78 -0
- package/src/components/editor/side-bar/ConceptTreeExplorer.tsx +401 -0
- package/src/components/editor/side-bar/DirectoryTreeExplorer.tsx +366 -0
- package/src/components/editor/side-bar/SideBar.tsx +51 -0
- package/src/index.tsx +46 -0
- package/src/server/PureServerClient.ts +299 -0
- package/src/server/models/Command.ts +40 -0
- package/src/server/models/ConceptTree.ts +152 -0
- package/src/server/models/DiagramInfo.ts +793 -0
- package/src/server/models/DirectoryTree.ts +100 -0
- package/src/server/models/Execution.ts +223 -0
- package/src/server/models/Initialization.ts +92 -0
- package/src/server/models/PureFile.ts +76 -0
- package/src/server/models/SearchEntry.ts +85 -0
- package/src/server/models/SourceInformation.ts +37 -0
- package/src/server/models/Test.ts +125 -0
- package/src/server/models/Usage.ts +49 -0
- package/src/stores/ConceptTreeState.ts +156 -0
- package/src/stores/DiagramEditorState.ts +150 -0
- package/src/stores/DirectoryTreeState.ts +168 -0
- package/src/stores/EditorConfig.ts +26 -0
- package/src/stores/EditorStore.ts +1087 -0
- package/src/stores/EditorTabManagerState.ts +74 -0
- package/src/stores/FileEditorState.ts +148 -0
- package/src/stores/LegendPureIDEApplicationPlugin.ts +30 -0
- package/src/stores/LegendPureIDEBaseStore.ts +36 -0
- package/src/stores/LegendPureIDECommand.ts +84 -0
- package/src/stores/SearchCommandState.ts +61 -0
- package/src/stores/SearchResultState.ts +131 -0
- package/src/stores/TestRunnerState.ts +470 -0
- package/src/stores/TreeState.ts +179 -0
- package/tsconfig.json +98 -0
|
@@ -0,0 +1,793 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2020-present, Goldman Sachs
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import {
|
|
18
|
+
ClassView,
|
|
19
|
+
Diagram,
|
|
20
|
+
GeneralizationView,
|
|
21
|
+
Point,
|
|
22
|
+
PropertyView,
|
|
23
|
+
Rectangle,
|
|
24
|
+
_relationshipView_simplifyPath,
|
|
25
|
+
} from '@finos/legend-extension-dsl-diagram';
|
|
26
|
+
import {
|
|
27
|
+
Class,
|
|
28
|
+
CoreModel,
|
|
29
|
+
DerivedProperty,
|
|
30
|
+
ELEMENT_PATH_DELIMITER,
|
|
31
|
+
Enumeration,
|
|
32
|
+
GenericType,
|
|
33
|
+
GenericTypeExplicitReference,
|
|
34
|
+
Multiplicity,
|
|
35
|
+
PackageableElementExplicitReference,
|
|
36
|
+
Profile,
|
|
37
|
+
Property,
|
|
38
|
+
PropertyExplicitReference,
|
|
39
|
+
PureModel,
|
|
40
|
+
resolvePackagePathAndElementName,
|
|
41
|
+
Stereotype,
|
|
42
|
+
StereotypeExplicitReference,
|
|
43
|
+
SystemModel,
|
|
44
|
+
Tag,
|
|
45
|
+
TaggedValue,
|
|
46
|
+
TagExplicitReference,
|
|
47
|
+
getOrCreatePackage,
|
|
48
|
+
addElementToPackage,
|
|
49
|
+
getTag,
|
|
50
|
+
getStereotype,
|
|
51
|
+
getOwnProperty,
|
|
52
|
+
} from '@finos/legend-graph';
|
|
53
|
+
import { addUniqueEntry, guaranteeNonNullable } from '@finos/legend-shared';
|
|
54
|
+
import {
|
|
55
|
+
createModelSchema,
|
|
56
|
+
primitive,
|
|
57
|
+
object,
|
|
58
|
+
list,
|
|
59
|
+
optional,
|
|
60
|
+
} from 'serializr';
|
|
61
|
+
import { SourceInformation } from './SourceInformation.js';
|
|
62
|
+
|
|
63
|
+
// ----------------------------------- Shared PURE serialization model ---------------------------------------
|
|
64
|
+
//
|
|
65
|
+
// We don't intend to build Pure graph from these serialization models, hence, we never really want to export them
|
|
66
|
+
// to use outside of this file; their sole purpose is to get the result from the diagram info endpoints
|
|
67
|
+
// to convert to Legend protocol model to use in Legend Studio diagram renderer
|
|
68
|
+
|
|
69
|
+
class PURE__Profile {
|
|
70
|
+
package!: string;
|
|
71
|
+
name!: string;
|
|
72
|
+
tags: string[] = [];
|
|
73
|
+
stereotypes: string[] = [];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
createModelSchema(PURE__Profile, {
|
|
77
|
+
name: primitive(),
|
|
78
|
+
package: primitive(),
|
|
79
|
+
stereotypes: list(primitive()),
|
|
80
|
+
tags: list(primitive()),
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
class PURE__Steoreotype {
|
|
84
|
+
profile!: string;
|
|
85
|
+
value!: string;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
createModelSchema(PURE__Steoreotype, {
|
|
89
|
+
profile: primitive(),
|
|
90
|
+
value: primitive(),
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
class PURE__Tag {
|
|
94
|
+
profile!: string;
|
|
95
|
+
value!: string;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
createModelSchema(PURE__Tag, {
|
|
99
|
+
profile: primitive(),
|
|
100
|
+
value: primitive(),
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
class PURE__TaggedValue {
|
|
104
|
+
tag!: PURE__Tag;
|
|
105
|
+
value!: string;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
createModelSchema(PURE__TaggedValue, {
|
|
109
|
+
tag: object(PURE__Tag),
|
|
110
|
+
value: primitive(),
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
class PURE__GenericType {
|
|
114
|
+
rawType?: string;
|
|
115
|
+
typeParameter?: string; // this will be specified when for generics case
|
|
116
|
+
// typeArguments
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
createModelSchema(PURE__GenericType, {
|
|
120
|
+
rawType: optional(primitive()),
|
|
121
|
+
typeParameter: optional(primitive()),
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
class PURE__Property {
|
|
125
|
+
name!: string;
|
|
126
|
+
stereotypes: PURE__Steoreotype[] = [];
|
|
127
|
+
taggedValues: PURE__TaggedValue[] = [];
|
|
128
|
+
|
|
129
|
+
// aggregation!: string;
|
|
130
|
+
multiplicity!: string;
|
|
131
|
+
// parameters // this is meant for qualified properties only
|
|
132
|
+
genericType!: PURE__GenericType;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
createModelSchema(PURE__Property, {
|
|
136
|
+
genericType: object(PURE__GenericType),
|
|
137
|
+
multiplicity: primitive(),
|
|
138
|
+
name: primitive(),
|
|
139
|
+
stereotypes: list(object(PURE__Steoreotype)),
|
|
140
|
+
taggedValues: list(object(PURE__TaggedValue)),
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
class PURE__PackageableElementPointer {
|
|
144
|
+
package!: string;
|
|
145
|
+
name!: string;
|
|
146
|
+
sourceInformation!: SourceInformation;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
createModelSchema(PURE__PackageableElementPointer, {
|
|
150
|
+
name: primitive(),
|
|
151
|
+
package: primitive(),
|
|
152
|
+
sourceInformation: object(SourceInformation),
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
class PURE__Class {
|
|
156
|
+
package!: string;
|
|
157
|
+
name!: string;
|
|
158
|
+
sourceInformation!: SourceInformation;
|
|
159
|
+
stereotypes: PURE__Steoreotype[] = [];
|
|
160
|
+
taggedValues: PURE__TaggedValue[] = [];
|
|
161
|
+
|
|
162
|
+
// typeParameters: string[] = [];
|
|
163
|
+
generalizations: PURE__GenericType[] = [];
|
|
164
|
+
properties: PURE__Property[] = [];
|
|
165
|
+
qualifiedProperties: PURE__Property[] = [];
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
createModelSchema(PURE__Class, {
|
|
169
|
+
generalizations: list(object(PURE__GenericType)),
|
|
170
|
+
name: primitive(),
|
|
171
|
+
package: primitive(),
|
|
172
|
+
properties: list(object(PURE__Property)),
|
|
173
|
+
qualifiedProperties: list(object(PURE__Property)),
|
|
174
|
+
sourceInformation: object(SourceInformation),
|
|
175
|
+
stereotypes: list(object(PURE__Steoreotype)),
|
|
176
|
+
taggedValues: list(object(PURE__TaggedValue)),
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
class PURE__Enumeration {
|
|
180
|
+
package!: string;
|
|
181
|
+
name!: string;
|
|
182
|
+
// sourceInformation!: SourceInformation;
|
|
183
|
+
|
|
184
|
+
enumValues: string[] = [];
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
createModelSchema(PURE__Enumeration, {
|
|
188
|
+
name: primitive(),
|
|
189
|
+
package: primitive(),
|
|
190
|
+
enumValues: list(primitive()),
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
// -------------------------------------- Diagram -----------------------------------------
|
|
194
|
+
|
|
195
|
+
class PURE__Point {
|
|
196
|
+
x!: number;
|
|
197
|
+
y!: number;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
createModelSchema(PURE__Point, {
|
|
201
|
+
x: primitive(),
|
|
202
|
+
y: primitive(),
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
class PURE__Rectangle {
|
|
206
|
+
height!: number;
|
|
207
|
+
width!: number;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
createModelSchema(PURE__Rectangle, {
|
|
211
|
+
height: primitive(),
|
|
212
|
+
width: primitive(),
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
class PURE__Geometry {
|
|
216
|
+
points: PURE__Point[] = [];
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
createModelSchema(PURE__Geometry, {
|
|
220
|
+
points: list(object(PURE__Point)),
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
class PURE__GeneralizationView {
|
|
224
|
+
id!: string;
|
|
225
|
+
source!: string;
|
|
226
|
+
target!: string;
|
|
227
|
+
geometry!: PURE__Geometry;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
createModelSchema(PURE__GeneralizationView, {
|
|
231
|
+
geometry: object(PURE__Geometry),
|
|
232
|
+
id: primitive(),
|
|
233
|
+
source: primitive(),
|
|
234
|
+
target: primitive(),
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
class PURE__PropertyViewPropertyPointer {
|
|
238
|
+
name!: string;
|
|
239
|
+
owningType!: string;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
createModelSchema(PURE__PropertyViewPropertyPointer, {
|
|
243
|
+
name: primitive(),
|
|
244
|
+
owningType: primitive(),
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
class PURE__PropertyView {
|
|
248
|
+
id!: string;
|
|
249
|
+
source!: string;
|
|
250
|
+
target!: string;
|
|
251
|
+
property!: PURE__PropertyViewPropertyPointer;
|
|
252
|
+
geometry!: PURE__Geometry;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
createModelSchema(PURE__PropertyView, {
|
|
256
|
+
geometry: object(PURE__Geometry),
|
|
257
|
+
id: primitive(),
|
|
258
|
+
property: object(PURE__PropertyViewPropertyPointer),
|
|
259
|
+
source: primitive(),
|
|
260
|
+
target: primitive(),
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
class PURE__TypeView {
|
|
264
|
+
id!: string;
|
|
265
|
+
type!: string;
|
|
266
|
+
position!: PURE__Point;
|
|
267
|
+
rectangleGeometry!: PURE__Rectangle;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
createModelSchema(PURE__TypeView, {
|
|
271
|
+
id: primitive(),
|
|
272
|
+
position: object(PURE__Point),
|
|
273
|
+
rectangleGeometry: object(PURE__Rectangle),
|
|
274
|
+
type: primitive(),
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
class PURE__Diagram {
|
|
278
|
+
package!: string;
|
|
279
|
+
name!: string;
|
|
280
|
+
stereotypes: PURE__Steoreotype[] = [];
|
|
281
|
+
taggedValues: PURE__TaggedValue[] = [];
|
|
282
|
+
|
|
283
|
+
// associationViews
|
|
284
|
+
generalizationViews: PURE__GeneralizationView[] = [];
|
|
285
|
+
propertyViews: PURE__PropertyView[] = [];
|
|
286
|
+
typeViews: PURE__TypeView[] = [];
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
createModelSchema(PURE__Diagram, {
|
|
290
|
+
name: primitive(),
|
|
291
|
+
generalizationViews: list(object(PURE__GeneralizationView)),
|
|
292
|
+
package: primitive(),
|
|
293
|
+
propertyViews: list(object(PURE__PropertyView)),
|
|
294
|
+
stereotypes: list(object(PURE__Steoreotype)),
|
|
295
|
+
taggedValues: list(object(PURE__TaggedValue)),
|
|
296
|
+
typeViews: list(object(PURE__TypeView)),
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
// ----------------------------------- Diagram Info ---------------------------------------
|
|
300
|
+
|
|
301
|
+
class DiagramDomainInfo {
|
|
302
|
+
// associations // skip these for now as we don't support association views
|
|
303
|
+
classes: PURE__Class[] = [];
|
|
304
|
+
enumerations: PURE__Enumeration[] = [];
|
|
305
|
+
profiles: PURE__Profile[] = [];
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
createModelSchema(DiagramDomainInfo, {
|
|
309
|
+
// associations
|
|
310
|
+
classes: list(object(PURE__Class)),
|
|
311
|
+
enumerations: list(object(PURE__Enumeration)),
|
|
312
|
+
profiles: list(object(PURE__Profile)),
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
export class DiagramInfo {
|
|
316
|
+
name!: string;
|
|
317
|
+
diagram!: PURE__Diagram;
|
|
318
|
+
domainInfo?: DiagramDomainInfo;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
createModelSchema(DiagramInfo, {
|
|
322
|
+
diagram: object(PURE__Diagram),
|
|
323
|
+
name: primitive(),
|
|
324
|
+
domainInfo: optional(object(DiagramDomainInfo)),
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
export class DiagramClassInfo {
|
|
328
|
+
// associations
|
|
329
|
+
class!: PURE__Class;
|
|
330
|
+
enumerations: PURE__Enumeration[] = [];
|
|
331
|
+
profiles: PURE__Profile[] = [];
|
|
332
|
+
specializations: PURE__PackageableElementPointer[] = [];
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
createModelSchema(DiagramClassInfo, {
|
|
336
|
+
// associations
|
|
337
|
+
class: object(PURE__Class),
|
|
338
|
+
enumerations: list(object(PURE__Enumeration)),
|
|
339
|
+
profiles: list(object(PURE__Profile)),
|
|
340
|
+
specializations: list(object(PURE__PackageableElementPointer)),
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
// ----------------------------------------- Serializer --------------------------------------------
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Serialize the diagram in Studio to Pure grammar for M2 DSL Diagram
|
|
347
|
+
* so we can persist it.
|
|
348
|
+
*/
|
|
349
|
+
export const serializeDiagram = (diagram: Diagram): string => {
|
|
350
|
+
const typeViews = diagram.classViews.map(
|
|
351
|
+
(cv) =>
|
|
352
|
+
` TypeView ${cv.id}(\n` +
|
|
353
|
+
` type=${cv.class.value.path},\n` +
|
|
354
|
+
` position=(${cv.position.x.toFixed(5)}, ${cv.position.y.toFixed(
|
|
355
|
+
5,
|
|
356
|
+
)}),\n` +
|
|
357
|
+
` width=${cv.rectangle.width.toFixed(5)},\n` +
|
|
358
|
+
` height=${cv.rectangle.height.toFixed(5)},\n` +
|
|
359
|
+
` stereotypesVisible=true,\n` +
|
|
360
|
+
` attributesVisible=true,\n` +
|
|
361
|
+
` attributeStereotypesVisible=true,\n` +
|
|
362
|
+
` attributeTypesVisible=true,\n` +
|
|
363
|
+
` color=#FFFFCC,\n` +
|
|
364
|
+
` lineWidth=1.0)`,
|
|
365
|
+
);
|
|
366
|
+
|
|
367
|
+
const generalizationViews = diagram.generalizationViews.map(
|
|
368
|
+
(gv, idx) =>
|
|
369
|
+
// NOTE: the relationship views in Diagram protocols don't have an ID
|
|
370
|
+
` GeneralizationView gview_${idx}(\n` +
|
|
371
|
+
` source=${gv.from.classView.value.id},\n` +
|
|
372
|
+
` target=${gv.to.classView.value.id},\n` +
|
|
373
|
+
` points=[${gv
|
|
374
|
+
.buildFullPath()
|
|
375
|
+
.map((pos) => `(${pos.x.toFixed(5)},${pos.y.toFixed(5)})`)
|
|
376
|
+
.join(',')}],\n` +
|
|
377
|
+
` label='',\n` +
|
|
378
|
+
` color=#000000,\n` +
|
|
379
|
+
` lineWidth=-1.0,\n` +
|
|
380
|
+
` lineStyle=SIMPLE)`,
|
|
381
|
+
);
|
|
382
|
+
|
|
383
|
+
const propertyViews = diagram.propertyViews.map(
|
|
384
|
+
(pv, idx) =>
|
|
385
|
+
` PropertyView pview_${idx}(\n` +
|
|
386
|
+
` property=${pv.property.value._OWNER.path}.${pv.property.value.name},\n` +
|
|
387
|
+
` source=${pv.from.classView.value.id},\n` +
|
|
388
|
+
` target=${pv.to.classView.value.id}\n,` +
|
|
389
|
+
` points=[${pv
|
|
390
|
+
.buildFullPath()
|
|
391
|
+
.map((pos) => `(${pos.x.toFixed(5)},${pos.y.toFixed(5)})`)
|
|
392
|
+
.join(',')}],\n` +
|
|
393
|
+
` label='',\n` +
|
|
394
|
+
` propertyPosition=(0.0,0.0),\n` +
|
|
395
|
+
` multiplicityPosition=(0.0,0.0),\n` +
|
|
396
|
+
` color=#000000,\n` +
|
|
397
|
+
` lineWidth=-1.0,\n` +
|
|
398
|
+
` stereotypesVisible=true,\n` +
|
|
399
|
+
` nameVisible=true,\n` +
|
|
400
|
+
` lineStyle=SIMPLE)`,
|
|
401
|
+
);
|
|
402
|
+
|
|
403
|
+
return (
|
|
404
|
+
`Diagram ${diagram.path}(width=0.0, height=0.0)\n` +
|
|
405
|
+
`{\n` +
|
|
406
|
+
`${[...typeViews, ...generalizationViews, ...propertyViews].join(
|
|
407
|
+
'\n\n',
|
|
408
|
+
)}\n` +
|
|
409
|
+
`}`
|
|
410
|
+
);
|
|
411
|
+
};
|
|
412
|
+
|
|
413
|
+
// ------------------------------ Graph builder (for diagram renderer) ----------------------------------
|
|
414
|
+
|
|
415
|
+
export interface DiagramClassMetadata {
|
|
416
|
+
isStubbed: boolean;
|
|
417
|
+
sourceInformation: SourceInformation | undefined;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
const getOrCreateClass = (
|
|
421
|
+
path: string,
|
|
422
|
+
graph: PureModel,
|
|
423
|
+
diagramClasses: Map<string, DiagramClassMetadata>,
|
|
424
|
+
sourceInformation: SourceInformation | undefined,
|
|
425
|
+
): Class => {
|
|
426
|
+
const existingClass = graph.getOwnNullableClass(path);
|
|
427
|
+
if (!existingClass) {
|
|
428
|
+
const [_package, name] = resolvePackagePathAndElementName(path);
|
|
429
|
+
const _class = new Class(name);
|
|
430
|
+
addElementToPackage(
|
|
431
|
+
getOrCreatePackage(graph.root, _package, true, new Map()),
|
|
432
|
+
_class,
|
|
433
|
+
);
|
|
434
|
+
graph.setOwnType(path, _class);
|
|
435
|
+
diagramClasses.set(path, {
|
|
436
|
+
isStubbed: true,
|
|
437
|
+
sourceInformation,
|
|
438
|
+
});
|
|
439
|
+
return _class;
|
|
440
|
+
}
|
|
441
|
+
return existingClass;
|
|
442
|
+
};
|
|
443
|
+
|
|
444
|
+
const parseMultiplicty = (text: string): Multiplicity => {
|
|
445
|
+
if (text === '*') {
|
|
446
|
+
return new Multiplicity(0, undefined);
|
|
447
|
+
} else {
|
|
448
|
+
const parts = text.split('..');
|
|
449
|
+
if (parts.length === 1) {
|
|
450
|
+
return new Multiplicity(
|
|
451
|
+
parseInt(guaranteeNonNullable(parts[0]), 10),
|
|
452
|
+
parseInt(guaranteeNonNullable(parts[0]), 10),
|
|
453
|
+
);
|
|
454
|
+
} else if (parts.length === 2) {
|
|
455
|
+
return new Multiplicity(
|
|
456
|
+
parseInt(guaranteeNonNullable(parts[0]), 10),
|
|
457
|
+
parts[1] === '*'
|
|
458
|
+
? undefined
|
|
459
|
+
: parseInt(guaranteeNonNullable(parts[1]), 10),
|
|
460
|
+
);
|
|
461
|
+
}
|
|
462
|
+
throw new Error(`Can't parse multiplicity value '${text}'`);
|
|
463
|
+
}
|
|
464
|
+
};
|
|
465
|
+
|
|
466
|
+
const buildClass = (
|
|
467
|
+
_class: Class,
|
|
468
|
+
classData: PURE__Class,
|
|
469
|
+
graph: PureModel,
|
|
470
|
+
diagramClasses: Map<string, DiagramClassMetadata>,
|
|
471
|
+
): void => {
|
|
472
|
+
classData.taggedValues.forEach((taggedValueData) => {
|
|
473
|
+
addUniqueEntry(
|
|
474
|
+
_class.taggedValues,
|
|
475
|
+
new TaggedValue(
|
|
476
|
+
TagExplicitReference.create(
|
|
477
|
+
getTag(
|
|
478
|
+
graph.getProfile(taggedValueData.tag.profile),
|
|
479
|
+
taggedValueData.tag.value,
|
|
480
|
+
),
|
|
481
|
+
),
|
|
482
|
+
taggedValueData.value,
|
|
483
|
+
),
|
|
484
|
+
);
|
|
485
|
+
});
|
|
486
|
+
classData.stereotypes.forEach((stereotypeData) => {
|
|
487
|
+
addUniqueEntry(
|
|
488
|
+
_class.stereotypes,
|
|
489
|
+
StereotypeExplicitReference.create(
|
|
490
|
+
getStereotype(
|
|
491
|
+
graph.getProfile(stereotypeData.profile),
|
|
492
|
+
stereotypeData.value,
|
|
493
|
+
),
|
|
494
|
+
),
|
|
495
|
+
);
|
|
496
|
+
});
|
|
497
|
+
classData.generalizations
|
|
498
|
+
.filter((superTypeData) => Boolean(superTypeData.rawType))
|
|
499
|
+
.forEach((superTypeData) => {
|
|
500
|
+
const superClass = getOrCreateClass(
|
|
501
|
+
guaranteeNonNullable(superTypeData.rawType),
|
|
502
|
+
graph,
|
|
503
|
+
diagramClasses,
|
|
504
|
+
undefined,
|
|
505
|
+
);
|
|
506
|
+
addUniqueEntry(
|
|
507
|
+
_class.generalizations,
|
|
508
|
+
GenericTypeExplicitReference.create(new GenericType(superClass)),
|
|
509
|
+
);
|
|
510
|
+
addUniqueEntry(superClass._subclasses, _class);
|
|
511
|
+
});
|
|
512
|
+
classData.properties
|
|
513
|
+
.filter((propertyData) => Boolean(propertyData.genericType.rawType))
|
|
514
|
+
.forEach((propertyData) => {
|
|
515
|
+
addUniqueEntry(
|
|
516
|
+
_class.properties,
|
|
517
|
+
new Property(
|
|
518
|
+
propertyData.name,
|
|
519
|
+
parseMultiplicty(propertyData.multiplicity),
|
|
520
|
+
GenericTypeExplicitReference.create(
|
|
521
|
+
new GenericType(
|
|
522
|
+
graph.getOwnNullableEnumeration(
|
|
523
|
+
guaranteeNonNullable(propertyData.genericType.rawType),
|
|
524
|
+
) ??
|
|
525
|
+
getOrCreateClass(
|
|
526
|
+
guaranteeNonNullable(propertyData.genericType.rawType),
|
|
527
|
+
graph,
|
|
528
|
+
diagramClasses,
|
|
529
|
+
undefined,
|
|
530
|
+
),
|
|
531
|
+
),
|
|
532
|
+
),
|
|
533
|
+
_class,
|
|
534
|
+
),
|
|
535
|
+
);
|
|
536
|
+
});
|
|
537
|
+
classData.qualifiedProperties
|
|
538
|
+
.filter((propertyData) => propertyData.genericType.rawType)
|
|
539
|
+
.forEach((propertyData) => {
|
|
540
|
+
addUniqueEntry(
|
|
541
|
+
_class.derivedProperties,
|
|
542
|
+
new DerivedProperty(
|
|
543
|
+
propertyData.name,
|
|
544
|
+
parseMultiplicty(propertyData.multiplicity),
|
|
545
|
+
GenericTypeExplicitReference.create(
|
|
546
|
+
new GenericType(
|
|
547
|
+
graph.getOwnNullableEnumeration(
|
|
548
|
+
guaranteeNonNullable(propertyData.genericType.rawType),
|
|
549
|
+
) ??
|
|
550
|
+
getOrCreateClass(
|
|
551
|
+
guaranteeNonNullable(propertyData.genericType.rawType),
|
|
552
|
+
graph,
|
|
553
|
+
diagramClasses,
|
|
554
|
+
undefined,
|
|
555
|
+
),
|
|
556
|
+
),
|
|
557
|
+
),
|
|
558
|
+
_class,
|
|
559
|
+
),
|
|
560
|
+
);
|
|
561
|
+
});
|
|
562
|
+
};
|
|
563
|
+
|
|
564
|
+
/**
|
|
565
|
+
* Since the diagram renderer uses Studio metamodel, here we build
|
|
566
|
+
* Studio metamodel graph and diagram from the Pure IDE diagram info
|
|
567
|
+
* to make use of the renderer.
|
|
568
|
+
*/
|
|
569
|
+
export const buildGraphFromDiagramInfo = (
|
|
570
|
+
diagramInfo: DiagramInfo,
|
|
571
|
+
): [Diagram, PureModel, Map<string, DiagramClassMetadata>] => {
|
|
572
|
+
const graph = new PureModel(new CoreModel([]), new SystemModel([]), []);
|
|
573
|
+
const diagramClasses = new Map<string, DiagramClassMetadata>();
|
|
574
|
+
|
|
575
|
+
// domain
|
|
576
|
+
if (diagramInfo.domainInfo) {
|
|
577
|
+
const domain = diagramInfo.domainInfo;
|
|
578
|
+
// first pass: add all the listed types and do really basic processing
|
|
579
|
+
domain.classes.forEach((classData) => {
|
|
580
|
+
const _class = new Class(classData.name);
|
|
581
|
+
addElementToPackage(
|
|
582
|
+
getOrCreatePackage(graph.root, classData.package, true, new Map()),
|
|
583
|
+
_class,
|
|
584
|
+
);
|
|
585
|
+
graph.setOwnType(_class.path, _class);
|
|
586
|
+
diagramClasses.set(_class.path, {
|
|
587
|
+
sourceInformation: classData.sourceInformation,
|
|
588
|
+
isStubbed: false,
|
|
589
|
+
});
|
|
590
|
+
});
|
|
591
|
+
domain.profiles.forEach((profileData) => {
|
|
592
|
+
const profile = new Profile(profileData.name);
|
|
593
|
+
addElementToPackage(
|
|
594
|
+
getOrCreatePackage(graph.root, profileData.package, true, new Map()),
|
|
595
|
+
profile,
|
|
596
|
+
);
|
|
597
|
+
graph.setOwnProfile(profile.path, profile);
|
|
598
|
+
profileData.tags.forEach((value) =>
|
|
599
|
+
addUniqueEntry(profile.p_tags, new Tag(profile, value)),
|
|
600
|
+
);
|
|
601
|
+
profileData.stereotypes.forEach((value) =>
|
|
602
|
+
addUniqueEntry(profile.p_stereotypes, new Stereotype(profile, value)),
|
|
603
|
+
);
|
|
604
|
+
});
|
|
605
|
+
domain.enumerations.forEach((enumerationData) => {
|
|
606
|
+
const enumeration = new Enumeration(enumerationData.name);
|
|
607
|
+
addElementToPackage(
|
|
608
|
+
getOrCreatePackage(
|
|
609
|
+
graph.root,
|
|
610
|
+
enumerationData.package,
|
|
611
|
+
true,
|
|
612
|
+
new Map(),
|
|
613
|
+
),
|
|
614
|
+
enumeration,
|
|
615
|
+
);
|
|
616
|
+
graph.setOwnType(enumeration.path, enumeration);
|
|
617
|
+
// NOTE: there is no need to pocess enumeration enum values since diagram does not need them
|
|
618
|
+
});
|
|
619
|
+
// second pass
|
|
620
|
+
domain.classes.forEach((classData) => {
|
|
621
|
+
const fullPath = `${classData.package}${
|
|
622
|
+
classData.package === '' ? '' : ELEMENT_PATH_DELIMITER
|
|
623
|
+
}${classData.name}`;
|
|
624
|
+
const _class = graph.getClass(fullPath);
|
|
625
|
+
buildClass(_class, classData, graph, diagramClasses);
|
|
626
|
+
});
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
// diagram
|
|
630
|
+
const diagramData = diagramInfo.diagram;
|
|
631
|
+
const diagram = new Diagram(diagramData.name);
|
|
632
|
+
addElementToPackage(
|
|
633
|
+
getOrCreatePackage(graph.root, diagramData.package, true, new Map()),
|
|
634
|
+
diagram,
|
|
635
|
+
);
|
|
636
|
+
|
|
637
|
+
diagramData.typeViews.forEach((typeViewData) => {
|
|
638
|
+
const classView = new ClassView(
|
|
639
|
+
diagram,
|
|
640
|
+
typeViewData.id,
|
|
641
|
+
PackageableElementExplicitReference.create(
|
|
642
|
+
graph.getClass(typeViewData.type),
|
|
643
|
+
),
|
|
644
|
+
);
|
|
645
|
+
classView.position = new Point(
|
|
646
|
+
typeViewData.position.x,
|
|
647
|
+
typeViewData.position.y,
|
|
648
|
+
);
|
|
649
|
+
classView.rectangle = new Rectangle(
|
|
650
|
+
typeViewData.rectangleGeometry.width,
|
|
651
|
+
typeViewData.rectangleGeometry.height,
|
|
652
|
+
);
|
|
653
|
+
addUniqueEntry(diagram.classViews, classView);
|
|
654
|
+
});
|
|
655
|
+
|
|
656
|
+
diagramData.propertyViews.forEach((propertyViewData) => {
|
|
657
|
+
const propertyView = new PropertyView(
|
|
658
|
+
diagram,
|
|
659
|
+
PropertyExplicitReference.create(
|
|
660
|
+
getOwnProperty(
|
|
661
|
+
graph.getClass(propertyViewData.property.owningType),
|
|
662
|
+
propertyViewData.property.name,
|
|
663
|
+
),
|
|
664
|
+
),
|
|
665
|
+
guaranteeNonNullable(
|
|
666
|
+
diagram.classViews.find((cv) => cv.id === propertyViewData.source),
|
|
667
|
+
),
|
|
668
|
+
guaranteeNonNullable(
|
|
669
|
+
diagram.classViews.find((cv) => cv.id === propertyViewData.target),
|
|
670
|
+
),
|
|
671
|
+
);
|
|
672
|
+
propertyView.path = propertyViewData.geometry.points.map(
|
|
673
|
+
(pointData) => new Point(pointData.x, pointData.y),
|
|
674
|
+
);
|
|
675
|
+
|
|
676
|
+
_relationshipView_simplifyPath(propertyView); // transform the line because we store only 2 end points that are inside points and we will calculate the offset
|
|
677
|
+
addUniqueEntry(diagram.propertyViews, propertyView);
|
|
678
|
+
});
|
|
679
|
+
|
|
680
|
+
diagramData.generalizationViews.forEach((generationViewData) => {
|
|
681
|
+
const generalizationView = new GeneralizationView(
|
|
682
|
+
diagram,
|
|
683
|
+
guaranteeNonNullable(
|
|
684
|
+
diagram.classViews.find((cv) => cv.id === generationViewData.source),
|
|
685
|
+
),
|
|
686
|
+
guaranteeNonNullable(
|
|
687
|
+
diagram.classViews.find((cv) => cv.id === generationViewData.target),
|
|
688
|
+
),
|
|
689
|
+
);
|
|
690
|
+
generalizationView.path = generationViewData.geometry.points.map(
|
|
691
|
+
(pointData) => new Point(pointData.x, pointData.y),
|
|
692
|
+
);
|
|
693
|
+
_relationshipView_simplifyPath(generalizationView); // transform the line because we store only 2 end points that are inside points and we will calculate the offset
|
|
694
|
+
addUniqueEntry(diagram.generalizationViews, generalizationView);
|
|
695
|
+
});
|
|
696
|
+
|
|
697
|
+
return [diagram, graph, diagramClasses];
|
|
698
|
+
};
|
|
699
|
+
|
|
700
|
+
export const addClassToGraph = (
|
|
701
|
+
diagramClassInfo: DiagramClassInfo,
|
|
702
|
+
graph: PureModel,
|
|
703
|
+
diagramClasses: Map<string, DiagramClassMetadata>,
|
|
704
|
+
): Class => {
|
|
705
|
+
// profiles
|
|
706
|
+
diagramClassInfo.profiles.forEach((profileData) => {
|
|
707
|
+
const fullPath = `${profileData.package}${
|
|
708
|
+
profileData.package === '' ? '' : ELEMENT_PATH_DELIMITER
|
|
709
|
+
}${profileData.name}`;
|
|
710
|
+
if (!graph.getOwnNullableProfile(fullPath)) {
|
|
711
|
+
const profile = new Profile(profileData.name);
|
|
712
|
+
addElementToPackage(
|
|
713
|
+
getOrCreatePackage(graph.root, profileData.package, true, new Map()),
|
|
714
|
+
profile,
|
|
715
|
+
);
|
|
716
|
+
graph.setOwnProfile(profile.path, profile);
|
|
717
|
+
profileData.tags.forEach((value) =>
|
|
718
|
+
addUniqueEntry(profile.p_tags, new Tag(profile, value)),
|
|
719
|
+
);
|
|
720
|
+
profileData.stereotypes.forEach((value) =>
|
|
721
|
+
addUniqueEntry(profile.p_stereotypes, new Stereotype(profile, value)),
|
|
722
|
+
);
|
|
723
|
+
}
|
|
724
|
+
});
|
|
725
|
+
|
|
726
|
+
// enumerations
|
|
727
|
+
diagramClassInfo.enumerations.forEach((enumerationData) => {
|
|
728
|
+
const fullPath = `${enumerationData.package}${
|
|
729
|
+
enumerationData.package === '' ? '' : ELEMENT_PATH_DELIMITER
|
|
730
|
+
}${enumerationData.name}`;
|
|
731
|
+
if (!graph.getOwnNullableEnumeration(fullPath)) {
|
|
732
|
+
const enumeration = new Enumeration(enumerationData.name);
|
|
733
|
+
addElementToPackage(
|
|
734
|
+
getOrCreatePackage(
|
|
735
|
+
graph.root,
|
|
736
|
+
enumerationData.package,
|
|
737
|
+
true,
|
|
738
|
+
new Map(),
|
|
739
|
+
),
|
|
740
|
+
enumeration,
|
|
741
|
+
);
|
|
742
|
+
graph.setOwnType(enumeration.path, enumeration);
|
|
743
|
+
// NOTE: there is no need to pocess enumeration enum values since diagram does not need them
|
|
744
|
+
}
|
|
745
|
+
});
|
|
746
|
+
|
|
747
|
+
const classData = diagramClassInfo.class;
|
|
748
|
+
const fullPath = `${classData.package}${
|
|
749
|
+
classData.package === '' ? '' : ELEMENT_PATH_DELIMITER
|
|
750
|
+
}${classData.name}`;
|
|
751
|
+
let _class = graph.getOwnNullableClass(fullPath);
|
|
752
|
+
if (!_class) {
|
|
753
|
+
_class = new Class(classData.name);
|
|
754
|
+
addElementToPackage(
|
|
755
|
+
getOrCreatePackage(graph.root, classData.package, true, new Map()),
|
|
756
|
+
_class,
|
|
757
|
+
);
|
|
758
|
+
graph.setOwnType(_class.path, _class);
|
|
759
|
+
}
|
|
760
|
+
const isCurrentlyStubbed = diagramClasses.get(_class.path)?.isStubbed ?? true;
|
|
761
|
+
diagramClasses.set(_class.path, {
|
|
762
|
+
sourceInformation: classData.sourceInformation,
|
|
763
|
+
isStubbed: false,
|
|
764
|
+
});
|
|
765
|
+
diagramClassInfo.specializations.forEach((subTypePointer) => {
|
|
766
|
+
const currentClass = guaranteeNonNullable(_class);
|
|
767
|
+
const subClass = getOrCreateClass(
|
|
768
|
+
guaranteeNonNullable(
|
|
769
|
+
`${subTypePointer.package}${
|
|
770
|
+
subTypePointer.package === '' ? '' : ELEMENT_PATH_DELIMITER
|
|
771
|
+
}${subTypePointer.name}`,
|
|
772
|
+
),
|
|
773
|
+
graph,
|
|
774
|
+
diagramClasses,
|
|
775
|
+
subTypePointer.sourceInformation,
|
|
776
|
+
);
|
|
777
|
+
addUniqueEntry(currentClass._subclasses, subClass);
|
|
778
|
+
if (
|
|
779
|
+
!subClass.generalizations
|
|
780
|
+
.map((generalization) => generalization.value.rawType)
|
|
781
|
+
.includes(currentClass)
|
|
782
|
+
) {
|
|
783
|
+
addUniqueEntry(
|
|
784
|
+
subClass.generalizations,
|
|
785
|
+
GenericTypeExplicitReference.create(new GenericType(currentClass)),
|
|
786
|
+
);
|
|
787
|
+
}
|
|
788
|
+
});
|
|
789
|
+
if (isCurrentlyStubbed) {
|
|
790
|
+
buildClass(_class, classData, graph, diagramClasses);
|
|
791
|
+
}
|
|
792
|
+
return _class;
|
|
793
|
+
};
|