@lionweb/validation 0.6.1-beta.0 → 0.6.1-beta.1
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/dist/diff/LionWebJsonDiff.d.ts.map +1 -1
- package/dist/diff/LionWebJsonDiff.js +18 -23
- package/dist/diff/LionWebJsonDiff.js.map +1 -1
- package/dist/diff/changes/ContainmentChange.d.ts +2 -2
- package/dist/diff/changes/ContainmentChange.d.ts.map +1 -1
- package/dist/diff/changes/ContainmentChange.js.map +1 -1
- package/dist/diff/changes/ReferenceChange.d.ts +3 -3
- package/dist/diff/changes/ReferenceChange.d.ts.map +1 -1
- package/dist/diff/changes/ReferenceChange.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/issues/LanguageIssues.d.ts +37 -13
- package/dist/issues/LanguageIssues.d.ts.map +1 -1
- package/dist/issues/LanguageIssues.js +49 -13
- package/dist/issues/LanguageIssues.js.map +1 -1
- package/dist/issues/ReferenceIssues.d.ts +6 -6
- package/dist/issues/ReferenceIssues.d.ts.map +1 -1
- package/dist/issues/ReferenceIssues.js +6 -6
- package/dist/issues/ReferenceIssues.js.map +1 -1
- package/dist/issues/SyntaxIssues.d.ts +9 -9
- package/dist/issues/SyntaxIssues.d.ts.map +1 -1
- package/dist/issues/SyntaxIssues.js +9 -9
- package/dist/issues/SyntaxIssues.js.map +1 -1
- package/dist/issues/ValidationIssue.d.ts +7 -1
- package/dist/issues/ValidationIssue.d.ts.map +1 -1
- package/dist/issues/ValidationIssue.js +9 -1
- package/dist/issues/ValidationIssue.js.map +1 -1
- package/dist/json/LionWebJson.d.ts +1 -14
- package/dist/json/LionWebJson.d.ts.map +1 -1
- package/dist/json/LionWebJson.js +4 -14
- package/dist/json/LionWebJson.js.map +1 -1
- package/dist/json/LionWebJsonChunkWrapper.d.ts +20 -8
- package/dist/json/LionWebJsonChunkWrapper.d.ts.map +1 -1
- package/dist/json/LionWebJsonChunkWrapper.js +50 -22
- package/dist/json/LionWebJsonChunkWrapper.js.map +1 -1
- package/dist/json/M3definitions.d.ts +176 -0
- package/dist/json/M3definitions.d.ts.map +1 -0
- package/dist/json/M3definitions.js +174 -0
- package/dist/json/M3definitions.js.map +1 -0
- package/dist/json/NodeUtils.d.ts +3 -9
- package/dist/json/NodeUtils.d.ts.map +1 -1
- package/dist/json/NodeUtils.js +18 -31
- package/dist/json/NodeUtils.js.map +1 -1
- package/dist/json/index.d.ts +1 -2
- package/dist/json/index.d.ts.map +1 -1
- package/dist/json/index.js +1 -2
- package/dist/json/index.js.map +1 -1
- package/dist/languages/CompositeLionWebLanguageWrapper.d.ts +24 -0
- package/dist/languages/CompositeLionWebLanguageWrapper.d.ts.map +1 -0
- package/dist/languages/CompositeLionWebLanguageWrapper.js +56 -0
- package/dist/languages/CompositeLionWebLanguageWrapper.js.map +1 -0
- package/dist/languages/LanguageRegistry.d.ts +19 -0
- package/dist/languages/LanguageRegistry.d.ts.map +1 -0
- package/dist/languages/LanguageRegistry.js +37 -0
- package/dist/languages/LanguageRegistry.js.map +1 -0
- package/dist/languages/LanguageUtils.d.ts +35 -0
- package/dist/languages/LanguageUtils.d.ts.map +1 -0
- package/dist/languages/LanguageUtils.js +52 -0
- package/dist/languages/LanguageUtils.js.map +1 -0
- package/dist/languages/LionCore-M3.json +2356 -0
- package/{src/json/std-builtins-copy.json → dist/languages/LionCore-builtins.json} +57 -52
- package/dist/languages/LionWebLanguageWrapper.d.ts +31 -0
- package/dist/languages/LionWebLanguageWrapper.d.ts.map +1 -0
- package/dist/languages/LionWebLanguageWrapper.js +69 -0
- package/dist/languages/LionWebLanguageWrapper.js.map +1 -0
- package/dist/languages/MetaPointerMap.d.ts +11 -0
- package/dist/languages/MetaPointerMap.d.ts.map +1 -0
- package/dist/languages/MetaPointerMap.js +39 -0
- package/dist/languages/MetaPointerMap.js.map +1 -0
- package/dist/languages/index.d.ts +3 -0
- package/dist/languages/index.d.ts.map +1 -0
- package/dist/languages/index.js +3 -0
- package/dist/languages/index.js.map +1 -0
- package/dist/runners/FileUtils.d.ts +4 -4
- package/dist/runners/FileUtils.d.ts.map +1 -1
- package/dist/runners/FileUtils.js +8 -32
- package/dist/runners/FileUtils.js.map +1 -1
- package/dist/runners/RunCheckFolder.js +3 -1
- package/dist/runners/RunCheckFolder.js.map +1 -1
- package/dist/runners/RunCheckFolderWithLanguage.js +7 -3
- package/dist/runners/RunCheckFolderWithLanguage.js.map +1 -1
- package/dist/runners/RunCheckOneFile.js +3 -1
- package/dist/runners/RunCheckOneFile.js.map +1 -1
- package/dist/runners/RunCheckOneFileWithLanguage.js +12 -3
- package/dist/runners/RunCheckOneFileWithLanguage.js.map +1 -1
- package/dist/runners/Utils.d.ts.map +1 -1
- package/dist/runners/Utils.js +0 -1
- package/dist/runners/Utils.js.map +1 -1
- package/dist/util/graphs.d.ts +18 -0
- package/dist/util/graphs.d.ts.map +1 -0
- package/dist/util/graphs.js +27 -0
- package/dist/util/graphs.js.map +1 -0
- package/dist/validators/LionWebLanguageReferenceValidator.d.ts +5 -4
- package/dist/validators/LionWebLanguageReferenceValidator.d.ts.map +1 -1
- package/dist/validators/LionWebLanguageReferenceValidator.js +96 -34
- package/dist/validators/LionWebLanguageReferenceValidator.js.map +1 -1
- package/dist/validators/LionWebLanguageValidator.d.ts +15 -3
- package/dist/validators/LionWebLanguageValidator.d.ts.map +1 -1
- package/dist/validators/LionWebLanguageValidator.js +54 -21
- package/dist/validators/LionWebLanguageValidator.js.map +1 -1
- package/dist/validators/LionWebReferenceValidator.d.ts.map +1 -1
- package/dist/validators/LionWebReferenceValidator.js +0 -5
- package/dist/validators/LionWebReferenceValidator.js.map +1 -1
- package/dist/validators/LionWebSyntaxValidator.d.ts +1 -1
- package/dist/validators/LionWebSyntaxValidator.js +1 -1
- package/dist/validators/LionWebValidator.d.ts +3 -3
- package/dist/validators/LionWebValidator.d.ts.map +1 -1
- package/dist/validators/LionWebValidator.js +5 -8
- package/dist/validators/LionWebValidator.js.map +1 -1
- package/package.json +5 -5
- package/src/diff/LionWebJsonDiff.ts +18 -23
- package/src/diff/changes/ContainmentChange.ts +1 -1
- package/src/diff/changes/ReferenceChange.ts +2 -2
- package/src/index.ts +2 -0
- package/src/issues/LanguageIssues.ts +49 -14
- package/src/issues/ReferenceIssues.ts +6 -6
- package/src/issues/SyntaxIssues.ts +9 -9
- package/src/issues/ValidationIssue.ts +12 -2
- package/src/json/LionCore_M3.json +2320 -0
- package/src/json/LionCore_builtins.json +231 -0
- package/src/json/LionWebJson.ts +5 -14
- package/src/json/LionWebJsonChunkWrapper.ts +59 -30
- package/src/json/M3definitions.ts +177 -0
- package/src/json/NodeUtils.ts +21 -39
- package/src/json/index.ts +1 -2
- package/src/languages/CompositeLionWebLanguageWrapper.ts +57 -0
- package/src/languages/LanguageRegistry.ts +44 -0
- package/src/languages/LanguageUtils.ts +61 -0
- package/src/languages/LionCore-M3.json +2356 -0
- package/src/languages/LionCore-builtins.json +372 -0
- package/src/languages/LionWebLanguageWrapper.ts +95 -0
- package/src/languages/MetaPointerMap.ts +40 -0
- package/src/languages/index.ts +2 -0
- package/src/runners/FileUtils.ts +9 -36
- package/src/runners/RunCheckFolder.ts +3 -1
- package/src/runners/RunCheckFolderWithLanguage.ts +7 -7
- package/src/runners/RunCheckOneFile.ts +3 -1
- package/src/runners/RunCheckOneFileWithLanguage.ts +12 -7
- package/src/runners/Utils.ts +0 -1
- package/src/tmp.json +574 -0
- package/src/tryout.js +21 -0
- package/src/util/graphs.ts +36 -0
- package/src/validators/LionWebLanguageReferenceValidator.ts +110 -48
- package/src/validators/LionWebLanguageValidator.ts +62 -21
- package/src/validators/LionWebReferenceValidator.ts +0 -5
- package/src/validators/LionWebSyntaxValidator.ts +2 -2
- package/src/validators/LionWebValidator.ts +5 -9
- package/structure.puml +25 -0
- package/dist/json/LanguageUtils.d.ts +0 -9
- package/dist/json/LanguageUtils.d.ts.map +0 -1
- package/dist/json/LanguageUtils.js +0 -30
- package/dist/json/LanguageUtils.js.map +0 -1
- package/dist/json/LionWebLanguageDefinition.d.ts +0 -48
- package/dist/json/LionWebLanguageDefinition.d.ts.map +0 -1
- package/dist/json/LionWebLanguageDefinition.js +0 -126
- package/dist/json/LionWebLanguageDefinition.js.map +0 -1
- package/src/json/LanguageUtils.ts +0 -52
- package/src/json/LionWebLanguageDefinition.ts +0 -144
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
{
|
|
2
|
+
"serializationFormatVersion": "2023.1",
|
|
3
|
+
"languages": [],
|
|
4
|
+
"nodes": [
|
|
5
|
+
{
|
|
6
|
+
"id": "LionCore-builtins",
|
|
7
|
+
"classifier": {
|
|
8
|
+
"language": "LionCore-M3",
|
|
9
|
+
"version": "2023.1",
|
|
10
|
+
"key": "Language"
|
|
11
|
+
},
|
|
12
|
+
"properties": [
|
|
13
|
+
{
|
|
14
|
+
"property": {
|
|
15
|
+
"language": "LionCore-M3",
|
|
16
|
+
"version": "2023.1",
|
|
17
|
+
"key": "Language-version"
|
|
18
|
+
},
|
|
19
|
+
"value": "2023.1"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"property": {
|
|
23
|
+
"language": "LionCore-M3",
|
|
24
|
+
"version": "2023.1",
|
|
25
|
+
"key": "IKeyed-key"
|
|
26
|
+
},
|
|
27
|
+
"value": "LionCore-builtins"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"property": {
|
|
31
|
+
"language": "LionCore-builtins",
|
|
32
|
+
"version": "2023.1",
|
|
33
|
+
"key": "LionCore-builtins-INamed-name"
|
|
34
|
+
},
|
|
35
|
+
"value": "LionCore_builtins"
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
"containments": [
|
|
39
|
+
{
|
|
40
|
+
"containment": {
|
|
41
|
+
"language": "LionCore-M3",
|
|
42
|
+
"version": "2023.1",
|
|
43
|
+
"key": "Language-entities"
|
|
44
|
+
},
|
|
45
|
+
"children": [
|
|
46
|
+
"LionCore-builtins-Node",
|
|
47
|
+
"LionCore-builtins-INamed"
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
],
|
|
51
|
+
"references": [
|
|
52
|
+
{
|
|
53
|
+
"reference": {
|
|
54
|
+
"language": "LionCore-M3",
|
|
55
|
+
"version": "2023.1",
|
|
56
|
+
"key": "Language-dependsOn"
|
|
57
|
+
},
|
|
58
|
+
"targets": []
|
|
59
|
+
}
|
|
60
|
+
],
|
|
61
|
+
"annotations": [],
|
|
62
|
+
"parent": null
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"id": "LionCore-builtins-Node",
|
|
66
|
+
"classifier": {
|
|
67
|
+
"language": "LionCore-M3",
|
|
68
|
+
"version": "2023.1",
|
|
69
|
+
"key": "Concept"
|
|
70
|
+
},
|
|
71
|
+
"properties": [
|
|
72
|
+
{
|
|
73
|
+
"property": {
|
|
74
|
+
"language": "LionCore-M3",
|
|
75
|
+
"version": "2023.1",
|
|
76
|
+
"key": "Concept-abstract"
|
|
77
|
+
},
|
|
78
|
+
"value": "true"
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"property": {
|
|
82
|
+
"language": "LionCore-M3",
|
|
83
|
+
"version": "2023.1",
|
|
84
|
+
"key": "Concept-partition"
|
|
85
|
+
},
|
|
86
|
+
"value": "false"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"property": {
|
|
90
|
+
"language": "LionCore-builtins",
|
|
91
|
+
"version": "2023.1",
|
|
92
|
+
"key": "LionCore-builtins-INamed-name"
|
|
93
|
+
},
|
|
94
|
+
"value": "Node"
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"property": {
|
|
98
|
+
"language": "LionCore-M3",
|
|
99
|
+
"version": "2023.1",
|
|
100
|
+
"key": "IKeyed-key"
|
|
101
|
+
},
|
|
102
|
+
"value": "LionCore-builtins-Node"
|
|
103
|
+
}
|
|
104
|
+
],
|
|
105
|
+
"containments": [
|
|
106
|
+
{
|
|
107
|
+
"containment": {
|
|
108
|
+
"language": "LionCore-M3",
|
|
109
|
+
"version": "2023.1",
|
|
110
|
+
"key": "Classifier-features"
|
|
111
|
+
},
|
|
112
|
+
"children": []
|
|
113
|
+
}
|
|
114
|
+
],
|
|
115
|
+
"references": [
|
|
116
|
+
{
|
|
117
|
+
"reference": {
|
|
118
|
+
"language": "LionCore-M3",
|
|
119
|
+
"version": "2023.1",
|
|
120
|
+
"key": "Concept-implements"
|
|
121
|
+
},
|
|
122
|
+
"targets": []
|
|
123
|
+
}
|
|
124
|
+
],
|
|
125
|
+
"annotations": [],
|
|
126
|
+
"parent": "LionCore-builtins"
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"id": "LionCore-builtins-INamed",
|
|
130
|
+
"classifier": {
|
|
131
|
+
"language": "LionCore-M3",
|
|
132
|
+
"version": "2023.1",
|
|
133
|
+
"key": "Interface"
|
|
134
|
+
},
|
|
135
|
+
"properties": [
|
|
136
|
+
{
|
|
137
|
+
"property": {
|
|
138
|
+
"language": "LionCore-builtins",
|
|
139
|
+
"version": "2023.1",
|
|
140
|
+
"key": "LionCore-builtins-INamed-name"
|
|
141
|
+
},
|
|
142
|
+
"value": "INamed"
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
"property": {
|
|
146
|
+
"language": "LionCore-M3",
|
|
147
|
+
"version": "2023.1",
|
|
148
|
+
"key": "IKeyed-key"
|
|
149
|
+
},
|
|
150
|
+
"value": "LionCore-builtins-INamed"
|
|
151
|
+
}
|
|
152
|
+
],
|
|
153
|
+
"containments": [
|
|
154
|
+
{
|
|
155
|
+
"containment": {
|
|
156
|
+
"language": "LionCore-M3",
|
|
157
|
+
"version": "2023.1",
|
|
158
|
+
"key": "Classifier-features"
|
|
159
|
+
},
|
|
160
|
+
"children": [
|
|
161
|
+
"LionCore-builtins-INamed-name"
|
|
162
|
+
]
|
|
163
|
+
}
|
|
164
|
+
],
|
|
165
|
+
"references": [
|
|
166
|
+
{
|
|
167
|
+
"reference": {
|
|
168
|
+
"language": "LionCore-M3",
|
|
169
|
+
"version": "2023.1",
|
|
170
|
+
"key": "Interface-extends"
|
|
171
|
+
},
|
|
172
|
+
"targets": []
|
|
173
|
+
}
|
|
174
|
+
],
|
|
175
|
+
"annotations": [],
|
|
176
|
+
"parent": "LionCore-builtins"
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
"id": "LionCore-builtins-INamed-name",
|
|
180
|
+
"classifier": {
|
|
181
|
+
"language": "LionCore-M3",
|
|
182
|
+
"version": "2023.1",
|
|
183
|
+
"key": "Property"
|
|
184
|
+
},
|
|
185
|
+
"properties": [
|
|
186
|
+
{
|
|
187
|
+
"property": {
|
|
188
|
+
"language": "LionCore-M3",
|
|
189
|
+
"version": "2023.1",
|
|
190
|
+
"key": "Feature-optional"
|
|
191
|
+
},
|
|
192
|
+
"value": "false"
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
"property": {
|
|
196
|
+
"language": "LionCore-builtins",
|
|
197
|
+
"version": "2023.1",
|
|
198
|
+
"key": "LionCore-builtins-INamed-name"
|
|
199
|
+
},
|
|
200
|
+
"value": "name"
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
"property": {
|
|
204
|
+
"language": "LionCore-M3",
|
|
205
|
+
"version": "2023.1",
|
|
206
|
+
"key": "IKeyed-key"
|
|
207
|
+
},
|
|
208
|
+
"value": "LionCore-builtins-INamed-name"
|
|
209
|
+
}
|
|
210
|
+
],
|
|
211
|
+
"containments": [],
|
|
212
|
+
"references": [
|
|
213
|
+
{
|
|
214
|
+
"reference": {
|
|
215
|
+
"language": "LionCore-M3",
|
|
216
|
+
"version": "2023.1",
|
|
217
|
+
"key": "Property-type"
|
|
218
|
+
},
|
|
219
|
+
"targets": [
|
|
220
|
+
{
|
|
221
|
+
"resolveInfo": "String",
|
|
222
|
+
"reference": "LionCore-builtins-String"
|
|
223
|
+
}
|
|
224
|
+
]
|
|
225
|
+
}
|
|
226
|
+
],
|
|
227
|
+
"annotations": [],
|
|
228
|
+
"parent": "LionCore-builtins-INamed"
|
|
229
|
+
}
|
|
230
|
+
]
|
|
231
|
+
}
|
package/src/json/LionWebJson.ts
CHANGED
|
@@ -1,30 +1,21 @@
|
|
|
1
|
+
import { LION_CORE_M3_KEY, LION_CORE_M3_VERSION } from "./M3definitions.js"
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* The types defining the structure of the LionWeb JSON format.
|
|
3
5
|
* @see https://lionweb-io.github.io/specification/serialization/serialization.html
|
|
4
6
|
* We use types instead of classes, because the purpose is to define the Lionweb JSON to be sent over the line.
|
|
5
7
|
*/
|
|
6
|
-
export const LION_CORE_BUILTINS_KEY = "LionCore-builtins"
|
|
7
|
-
export const LION_CORE_BUILTINS_INAMED_NAME = "LionCore-builtins-INamed-name"
|
|
8
|
-
export const LION_CORE_M3_KEY = "LionCore-M3"
|
|
9
|
-
export const LION_CORE_M3_NAME = "LionCore_M3"
|
|
10
|
-
export const LION_CORE_M3_VERSION = "2023.1"
|
|
11
8
|
|
|
12
|
-
export const LIONWEB_BOOLEAN_TYPE = "LionCore-builtins-Boolean"
|
|
13
|
-
export const LIONWEB_JSON_TYPE = "LionCore-builtins-JSON"
|
|
14
|
-
export const LIONWEB_INTEGER_TYPE = "LionCore-builtins-Integer"
|
|
15
|
-
export const LIONWEB_STRING_TYPE = "LionCore-builtins-String"
|
|
16
9
|
|
|
17
|
-
export
|
|
18
|
-
language
|
|
19
|
-
version: LION_CORE_M3_VERSION,
|
|
20
|
-
key: LION_CORE_BUILTINS_INAMED_NAME
|
|
10
|
+
export function isLionWebM3Language(language: LwJsonUsedLanguage): boolean {
|
|
11
|
+
return language.key === LION_CORE_M3_KEY && language.version === LION_CORE_M3_VERSION
|
|
21
12
|
}
|
|
22
13
|
export type LionWebId = string
|
|
23
14
|
|
|
24
15
|
export type LionWebJsonMetaPointer = {
|
|
25
16
|
language: string
|
|
26
17
|
version: string
|
|
27
|
-
key: string
|
|
18
|
+
key: string // key of concept, property, containment, referenve or property
|
|
28
19
|
}
|
|
29
20
|
|
|
30
21
|
export function isEqualMetaPointer(p1: LionWebJsonMetaPointer, p2: LionWebJsonMetaPointer): boolean {
|
|
@@ -1,36 +1,42 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
isEqualMetaPointer,
|
|
3
3
|
LionWebId,
|
|
4
4
|
LionWebJsonChunk,
|
|
5
|
+
LionWebJsonContainment,
|
|
6
|
+
LionWebJsonMetaPointer,
|
|
5
7
|
LionWebJsonNode,
|
|
6
|
-
|
|
8
|
+
LionWebJsonReference
|
|
7
9
|
} from "./LionWebJson.js"
|
|
8
|
-
import {
|
|
10
|
+
import { MetaPointers } from "./M3definitions.js"
|
|
9
11
|
import { NodeUtils } from "./NodeUtils.js"
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
|
-
* Wraps around a LionWebJsonChunk, providing access to information inside, using caches to improve performance.
|
|
14
|
+
* Wraps around a LionWebJsonChunk, providing access to information inside, might be using caches to improve performance.
|
|
13
15
|
* NB Make sure that the contents of the chunk are not changed after creating the wrapper!
|
|
16
|
+
* NB BE aware that with `pushChunk(...)` the original chunk will be changed.
|
|
14
17
|
*/
|
|
15
18
|
export class LionWebJsonChunkWrapper {
|
|
16
19
|
jsonChunk: LionWebJsonChunk
|
|
17
|
-
language: LionWebLanguageDefinition | null = null
|
|
18
20
|
/**
|
|
19
21
|
* Map to get quick access to nodes by id.
|
|
20
22
|
* @protected
|
|
21
23
|
*/
|
|
22
24
|
protected nodesIdMap: Map<LionWebId, LionWebJsonNode> = new Map<LionWebId, LionWebJsonNode>()
|
|
23
25
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Create a wrapper with `chunk` as its chunk
|
|
28
|
+
* @param chunk
|
|
29
|
+
*/
|
|
30
|
+
constructor(chunk: LionWebJsonChunk) {
|
|
31
|
+
this.jsonChunk = chunk
|
|
32
|
+
this.prepareNodeIds(chunk)
|
|
27
33
|
}
|
|
28
34
|
|
|
29
35
|
/** Put all nodes in a map, validate that there are no two nodes with the same id.
|
|
30
36
|
* The check should logically be in LionWebReferenceValidator, but the created map is needed here.
|
|
31
37
|
*/
|
|
32
|
-
prepareNodeIds() {
|
|
33
|
-
|
|
38
|
+
prepareNodeIds(chunk: LionWebJsonChunk) {
|
|
39
|
+
chunk.nodes.forEach(node => {
|
|
34
40
|
this.nodesIdMap.set(node.id, node)
|
|
35
41
|
})
|
|
36
42
|
}
|
|
@@ -39,23 +45,44 @@ export class LionWebJsonChunkWrapper {
|
|
|
39
45
|
return this.nodesIdMap.get(id)
|
|
40
46
|
}
|
|
41
47
|
|
|
42
|
-
|
|
43
|
-
return this.jsonChunk.nodes.filter(node => node.classifier
|
|
48
|
+
findNodesOfClassifier(concept: LionWebJsonMetaPointer): LionWebJsonNode[] {
|
|
49
|
+
return this.jsonChunk.nodes.filter(node => isEqualMetaPointer(node.classifier, concept))
|
|
44
50
|
}
|
|
45
51
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
// if (this.language !== null) {
|
|
54
|
-
// // const targetNode = this.language.languageChunkWrapper.getNode(target.reference);
|
|
55
|
-
// // TODO etc., but need to cleanup LanguageDefinition first.
|
|
56
|
-
// }
|
|
57
|
-
// });
|
|
52
|
+
/**
|
|
53
|
+
* Return the target nodes inside `reference` as a list of actual nodes (LionWebJsonNode[])
|
|
54
|
+
* @param reference
|
|
55
|
+
*/
|
|
56
|
+
getReferredNodes(reference: LionWebJsonReference | undefined) {
|
|
57
|
+
if (reference === undefined) {
|
|
58
|
+
return []
|
|
58
59
|
}
|
|
60
|
+
const result = reference.targets.flatMap(target => {
|
|
61
|
+
if (target.reference === null) {
|
|
62
|
+
return []
|
|
63
|
+
} else {
|
|
64
|
+
const referredNode = this.getNode(target.reference)
|
|
65
|
+
return referredNode === undefined ? [] : [referredNode]
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
return result
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Return the target nodes inside `reference` as a list of actual nodes (LionWebJsonNode[])
|
|
73
|
+
* @param reference
|
|
74
|
+
*/
|
|
75
|
+
getChildrenAsNodes(containment: LionWebJsonContainment | undefined) {
|
|
76
|
+
if (containment === undefined) {
|
|
77
|
+
return []
|
|
78
|
+
}
|
|
79
|
+
const result: LionWebJsonNode[] = []
|
|
80
|
+
containment.children.forEach(ch => {
|
|
81
|
+
const childNode = this.getNode(ch)
|
|
82
|
+
if (childNode !== undefined) {
|
|
83
|
+
result.push(childNode)
|
|
84
|
+
}
|
|
85
|
+
})
|
|
59
86
|
return result
|
|
60
87
|
}
|
|
61
88
|
|
|
@@ -71,10 +98,10 @@ export class LionWebJsonChunkWrapper {
|
|
|
71
98
|
|
|
72
99
|
private recursiveToString(node: LionWebJsonNode | undefined, depth: number): string {
|
|
73
100
|
if (node === undefined) {
|
|
74
|
-
return ""
|
|
101
|
+
return ""
|
|
75
102
|
}
|
|
76
103
|
let result: string = ""
|
|
77
|
-
const nameProperty = NodeUtils.findProperty(node,
|
|
104
|
+
const nameProperty = NodeUtils.findProperty(node, MetaPointers.INamedName)
|
|
78
105
|
const name = nameProperty === undefined ? "" : " " + nameProperty.value
|
|
79
106
|
result += this.indent(depth) + "(" + node.id + ")" + name + "\n"
|
|
80
107
|
if (node.annotations !== undefined && node.annotations.length !== 0) {
|
|
@@ -84,9 +111,11 @@ export class LionWebJsonChunkWrapper {
|
|
|
84
111
|
// result += this.indent(depth) + "[[" + JSON.stringify(ann) + "]]\n"
|
|
85
112
|
})
|
|
86
113
|
}
|
|
87
|
-
node.properties
|
|
88
|
-
|
|
89
|
-
|
|
114
|
+
node.properties
|
|
115
|
+
.filter(p => p !== nameProperty)
|
|
116
|
+
.forEach(property => {
|
|
117
|
+
result += this.indent(depth + 1) + "*property* " + property.property.key + ": " + property.value + "\n"
|
|
118
|
+
})
|
|
90
119
|
node.references.forEach(ref => {
|
|
91
120
|
result += this.indent(depth + 1) + "*" + ref.reference.key + "*: " + JSON.stringify(ref.targets) + "\n"
|
|
92
121
|
})
|
|
@@ -100,7 +129,7 @@ export class LionWebJsonChunkWrapper {
|
|
|
100
129
|
})
|
|
101
130
|
return result
|
|
102
131
|
}
|
|
103
|
-
|
|
132
|
+
|
|
104
133
|
private indent(depth: number): string {
|
|
105
134
|
return Array(depth).join(" ")
|
|
106
135
|
}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file contains LionWeb defined M3 keys and identifications.
|
|
3
|
+
*/
|
|
4
|
+
export const LION_CORE_BUILTINS_INAMED_NAME = "LionCore-builtins-INamed-name"
|
|
5
|
+
export const LION_CORE_BUILTINS_KEY = "LionCore-builtins"
|
|
6
|
+
|
|
7
|
+
export const LION_CORE_M3_KEY = "LionCore-M3"
|
|
8
|
+
export const LION_CORE_M3_NAME = "LionCore_M3"
|
|
9
|
+
|
|
10
|
+
export const LION_CORE_M3_VERSION = "2023.1"
|
|
11
|
+
// Builtin datatypes
|
|
12
|
+
export const LIONWEB_BOOLEAN_TYPE = "LionCore-builtins-Boolean"
|
|
13
|
+
export const LIONWEB_JSON_TYPE = "LionCore-builtins-JSON"
|
|
14
|
+
export const LIONWEB_INTEGER_TYPE = "LionCore-builtins-Integer"
|
|
15
|
+
export const LIONWEB_STRING_TYPE = "LionCore-builtins-String"
|
|
16
|
+
|
|
17
|
+
export const M3_Keys = {
|
|
18
|
+
Property: "Property",
|
|
19
|
+
Reference: "Reference",
|
|
20
|
+
Concept: "Concept",
|
|
21
|
+
conceptExtends: "Concept-extends",
|
|
22
|
+
conceptImplements: "Concept-implements",
|
|
23
|
+
concept2: {
|
|
24
|
+
key: "Concept",
|
|
25
|
+
extends: { key: "Concept-extends" },
|
|
26
|
+
implements: { key: "Concept-implements" }
|
|
27
|
+
},
|
|
28
|
+
conceptAbstract: "Concept-abstract",
|
|
29
|
+
conceptPartition: "Concept-partition",
|
|
30
|
+
classifierFeatures: "Classifier-features",
|
|
31
|
+
Interface: "Interface",
|
|
32
|
+
InterfaceExtends: "Interface-extends",
|
|
33
|
+
Containment: "Containment",
|
|
34
|
+
Language: "Language",
|
|
35
|
+
languageVersion: "Language-version",
|
|
36
|
+
IKeyedKey: "IKeyed-key",
|
|
37
|
+
PropertyType: "Property-type",
|
|
38
|
+
Enumeration: "Enumeration",
|
|
39
|
+
EnumerationLiterals: "Enumeration-literals",
|
|
40
|
+
EnumerationLiteral: "EnumerationLiteral",
|
|
41
|
+
INamed: "LionCore-builtins-INamed",
|
|
42
|
+
INamedName: "LionCore-builtins-INamed-name",
|
|
43
|
+
Annotation: "Annotation",
|
|
44
|
+
AnnotationAnnotates: "Annotation-annotates",
|
|
45
|
+
AnnotationExtends: "Annotation-extends",
|
|
46
|
+
AnnotationImplements: "Annotation-implements",
|
|
47
|
+
Node: "LionCore-builtins-Node"
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export const MetaPointers = {
|
|
51
|
+
Language: {
|
|
52
|
+
version: LION_CORE_M3_VERSION,
|
|
53
|
+
language: LION_CORE_M3_KEY,
|
|
54
|
+
key: M3_Keys.Language
|
|
55
|
+
},
|
|
56
|
+
LanguageVersion: {
|
|
57
|
+
version: LION_CORE_M3_VERSION,
|
|
58
|
+
language: LION_CORE_M3_KEY,
|
|
59
|
+
key: M3_Keys.languageVersion
|
|
60
|
+
},
|
|
61
|
+
ClassifierFeatures: {
|
|
62
|
+
version: LION_CORE_M3_VERSION,
|
|
63
|
+
language: LION_CORE_M3_KEY,
|
|
64
|
+
key: M3_Keys.classifierFeatures
|
|
65
|
+
},
|
|
66
|
+
Concept: {
|
|
67
|
+
version: LION_CORE_M3_VERSION,
|
|
68
|
+
language: LION_CORE_M3_KEY,
|
|
69
|
+
key: M3_Keys.concept2.key
|
|
70
|
+
},
|
|
71
|
+
ConceptAbstract: {
|
|
72
|
+
version: LION_CORE_M3_VERSION,
|
|
73
|
+
language: LION_CORE_M3_KEY,
|
|
74
|
+
key: M3_Keys.conceptAbstract
|
|
75
|
+
},
|
|
76
|
+
ConceptPartition: {
|
|
77
|
+
version: LION_CORE_M3_VERSION,
|
|
78
|
+
language: LION_CORE_M3_KEY,
|
|
79
|
+
key: M3_Keys.conceptPartition
|
|
80
|
+
},
|
|
81
|
+
ConceptExtends: {
|
|
82
|
+
version: LION_CORE_M3_VERSION,
|
|
83
|
+
language: LION_CORE_M3_KEY,
|
|
84
|
+
key: M3_Keys.concept2.extends.key
|
|
85
|
+
},
|
|
86
|
+
ConceptImplements: {
|
|
87
|
+
version: LION_CORE_M3_VERSION,
|
|
88
|
+
language: LION_CORE_M3_KEY,
|
|
89
|
+
key: M3_Keys.concept2.implements.key
|
|
90
|
+
},
|
|
91
|
+
Annotation: {
|
|
92
|
+
version: LION_CORE_M3_VERSION,
|
|
93
|
+
language: LION_CORE_M3_KEY,
|
|
94
|
+
key: M3_Keys.Annotation
|
|
95
|
+
},
|
|
96
|
+
AnnotationAnnotates: {
|
|
97
|
+
version: LION_CORE_M3_VERSION,
|
|
98
|
+
language: LION_CORE_M3_KEY,
|
|
99
|
+
key: M3_Keys.AnnotationAnnotates
|
|
100
|
+
},
|
|
101
|
+
AnnotationExtends: {
|
|
102
|
+
version: LION_CORE_M3_VERSION,
|
|
103
|
+
language: LION_CORE_M3_KEY,
|
|
104
|
+
key: M3_Keys.AnnotationExtends
|
|
105
|
+
},
|
|
106
|
+
AnnotationImplements: {
|
|
107
|
+
version: LION_CORE_M3_VERSION,
|
|
108
|
+
language: LION_CORE_M3_KEY,
|
|
109
|
+
key: M3_Keys.AnnotationImplements
|
|
110
|
+
},
|
|
111
|
+
Interface: {
|
|
112
|
+
version: LION_CORE_M3_VERSION,
|
|
113
|
+
language: LION_CORE_M3_KEY,
|
|
114
|
+
key: M3_Keys.Interface
|
|
115
|
+
},
|
|
116
|
+
InterfaceExtends: {
|
|
117
|
+
version: LION_CORE_M3_VERSION,
|
|
118
|
+
language: LION_CORE_M3_KEY,
|
|
119
|
+
key: M3_Keys.InterfaceExtends
|
|
120
|
+
},
|
|
121
|
+
Enumeration: {
|
|
122
|
+
version: LION_CORE_M3_VERSION,
|
|
123
|
+
language: LION_CORE_M3_KEY,
|
|
124
|
+
key: M3_Keys.Enumeration
|
|
125
|
+
},
|
|
126
|
+
EnumerationLiteral: {
|
|
127
|
+
version: LION_CORE_M3_VERSION,
|
|
128
|
+
language: LION_CORE_M3_KEY,
|
|
129
|
+
key: M3_Keys.EnumerationLiteral
|
|
130
|
+
},
|
|
131
|
+
EnumerationLiterals: {
|
|
132
|
+
version: LION_CORE_M3_VERSION,
|
|
133
|
+
language: LION_CORE_M3_KEY,
|
|
134
|
+
key: M3_Keys.EnumerationLiterals
|
|
135
|
+
},
|
|
136
|
+
Containment: {
|
|
137
|
+
version: LION_CORE_M3_VERSION,
|
|
138
|
+
language: LION_CORE_M3_KEY,
|
|
139
|
+
key: M3_Keys.Containment
|
|
140
|
+
},
|
|
141
|
+
Property: {
|
|
142
|
+
version: LION_CORE_M3_VERSION,
|
|
143
|
+
language: LION_CORE_M3_KEY,
|
|
144
|
+
key: M3_Keys.Property
|
|
145
|
+
},
|
|
146
|
+
PropertyType: {
|
|
147
|
+
version: LION_CORE_M3_VERSION,
|
|
148
|
+
language: LION_CORE_M3_KEY,
|
|
149
|
+
key: M3_Keys.PropertyType
|
|
150
|
+
},
|
|
151
|
+
Reference: {
|
|
152
|
+
version: LION_CORE_M3_VERSION,
|
|
153
|
+
language: LION_CORE_M3_KEY,
|
|
154
|
+
key: M3_Keys.Reference
|
|
155
|
+
},
|
|
156
|
+
IKeyedKey: {
|
|
157
|
+
language: LION_CORE_M3_KEY,
|
|
158
|
+
version: LION_CORE_M3_VERSION,
|
|
159
|
+
key: M3_Keys.IKeyedKey
|
|
160
|
+
},
|
|
161
|
+
// Builtins:
|
|
162
|
+
Node: {
|
|
163
|
+
language: LION_CORE_BUILTINS_KEY,
|
|
164
|
+
version: LION_CORE_M3_VERSION,
|
|
165
|
+
key: M3_Keys.Node
|
|
166
|
+
},
|
|
167
|
+
INamed: {
|
|
168
|
+
language: LION_CORE_BUILTINS_KEY,
|
|
169
|
+
version: LION_CORE_M3_VERSION,
|
|
170
|
+
key: M3_Keys.INamed
|
|
171
|
+
},
|
|
172
|
+
INamedName: {
|
|
173
|
+
language: LION_CORE_BUILTINS_KEY,
|
|
174
|
+
version: LION_CORE_M3_VERSION,
|
|
175
|
+
key: M3_Keys.INamedName
|
|
176
|
+
}
|
|
177
|
+
}
|
package/src/json/NodeUtils.ts
CHANGED
|
@@ -17,16 +17,10 @@ export class NodeUtils {
|
|
|
17
17
|
* @param node
|
|
18
18
|
* @param key
|
|
19
19
|
*/
|
|
20
|
-
static findLwProperty(node: LionWebJsonNode, key: string): LionWebJsonProperty | null {
|
|
21
|
-
for (const property of node.properties) {
|
|
22
|
-
if (property.property.key === key) {
|
|
23
|
-
return property
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return null
|
|
27
|
-
}
|
|
28
|
-
|
|
29
20
|
static findProperty(node: LionWebJsonNode, property: LionWebJsonMetaPointer): LionWebJsonProperty | undefined {
|
|
21
|
+
if (node === undefined) {
|
|
22
|
+
return undefined
|
|
23
|
+
}
|
|
30
24
|
return node.properties.find(
|
|
31
25
|
prop => isEqualMetaPointer(prop.property, property)
|
|
32
26
|
)
|
|
@@ -37,56 +31,44 @@ export class NodeUtils {
|
|
|
37
31
|
* @param node
|
|
38
32
|
* @param key
|
|
39
33
|
*/
|
|
40
|
-
static
|
|
34
|
+
static findChild(node: LionWebJsonNode, key: string): LionWebJsonContainment | undefined {
|
|
35
|
+
if (node === undefined) {
|
|
36
|
+
return undefined
|
|
37
|
+
}
|
|
41
38
|
for (const containment of node.containments) {
|
|
42
39
|
if (containment.containment.key === key) {
|
|
43
40
|
return containment
|
|
44
41
|
}
|
|
45
42
|
}
|
|
46
|
-
return
|
|
43
|
+
return undefined
|
|
47
44
|
}
|
|
48
45
|
|
|
49
46
|
static findContainment(node: LionWebJsonNode, containment: LionWebJsonMetaPointer): LionWebJsonContainment | undefined {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
if (node === undefined) {
|
|
48
|
+
return undefined
|
|
49
|
+
}
|
|
50
|
+
return node.containments.find(cont => isEqualMetaPointer(cont.containment, containment))
|
|
53
51
|
}
|
|
54
52
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if (reference.reference.key === key) {
|
|
59
|
-
return reference
|
|
60
|
-
}
|
|
53
|
+
static findReference(node: LionWebJsonNode, reference: LionWebJsonMetaPointer): LionWebJsonReference | undefined {
|
|
54
|
+
if (node === undefined) {
|
|
55
|
+
return undefined
|
|
61
56
|
}
|
|
62
|
-
return
|
|
57
|
+
return node.references.find(ref => isEqualMetaPointer(ref.reference, reference))
|
|
63
58
|
}
|
|
64
59
|
|
|
65
|
-
static
|
|
66
|
-
|
|
60
|
+
static findReferenceTarget(
|
|
61
|
+
referenceTargets: LionWebJsonReferenceTarget[],
|
|
67
62
|
target: LionWebJsonReferenceTarget,
|
|
68
|
-
): LionWebJsonReferenceTarget |
|
|
69
|
-
for (const refTarget of
|
|
63
|
+
): LionWebJsonReferenceTarget | undefined {
|
|
64
|
+
for (const refTarget of referenceTargets) {
|
|
70
65
|
if (isEqualReferenceTarget(refTarget, target)) {
|
|
71
66
|
return refTarget
|
|
72
67
|
}
|
|
73
68
|
}
|
|
74
|
-
return
|
|
69
|
+
return undefined
|
|
75
70
|
}
|
|
76
71
|
|
|
77
|
-
/**
|
|
78
|
-
* Get all nodes that are children for _node_: both the containment and annotation children
|
|
79
|
-
* @param node
|
|
80
|
-
*/
|
|
81
|
-
static allDirectChildren(node: LionWebJsonNode): string[] {
|
|
82
|
-
const result: string[] = []
|
|
83
|
-
for (const containment of node.containments) {
|
|
84
|
-
result.push(...containment.children)
|
|
85
|
-
}
|
|
86
|
-
result.push(...node.annotations)
|
|
87
|
-
return result
|
|
88
|
-
}
|
|
89
|
-
|
|
90
72
|
static findContainmentContainingChild(containments: LionWebJsonContainment[], childId: string): LionWebJsonContainment | undefined {
|
|
91
73
|
return containments.find(cont => cont.children.includes(childId))
|
|
92
74
|
}
|
package/src/json/index.ts
CHANGED