@lionweb/validation 0.7.0-beta.18 → 0.7.0-beta.19

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.
Files changed (38) hide show
  1. package/CHANGELOG.md +0 -1
  2. package/package.json +4 -4
  3. package/src/index.ts +4 -0
  4. package/src/issues/LanguageIssues.ts +147 -0
  5. package/src/issues/ReferenceIssues.ts +83 -0
  6. package/src/issues/SyntaxIssues.ts +84 -0
  7. package/src/issues/ValidationIssue.ts +29 -0
  8. package/src/issues/index.ts +4 -0
  9. package/src/languages/CompositeLionWebLanguageWrapper.ts +57 -0
  10. package/src/languages/LanguageRegistry.ts +44 -0
  11. package/src/languages/LanguageUtils.ts +63 -0
  12. package/src/languages/LionCore-M3.json +2356 -0
  13. package/src/languages/LionCore-builtins.json +372 -0
  14. package/src/languages/LionWebLanguageWrapper.ts +91 -0
  15. package/src/languages/MetaPointerMap.ts +41 -0
  16. package/src/languages/index.ts +2 -0
  17. package/src/runners/FileUtils.ts +59 -0
  18. package/src/runners/RunCheckFolder.ts +7 -0
  19. package/src/runners/RunCheckFolderWithLanguage.ts +45 -0
  20. package/src/runners/RunCheckOneFile.ts +7 -0
  21. package/src/runners/RunCheckOneFileWithLanguage.ts +35 -0
  22. package/src/runners/RunLioncoreDiff.ts +23 -0
  23. package/src/runners/Utils.ts +54 -0
  24. package/src/runners/index.ts +2 -0
  25. package/src/validators/LionWebChunkDefinitions.ts +104 -0
  26. package/src/validators/LionWebLanguageReferenceValidator.ts +201 -0
  27. package/src/validators/LionWebLanguageValidator.ts +79 -0
  28. package/src/validators/LionWebReferenceValidator.ts +225 -0
  29. package/src/validators/LionWebSyntaxValidator.ts +14 -0
  30. package/src/validators/LionWebValidator.ts +71 -0
  31. package/src/validators/ValidationFunctions.ts +129 -0
  32. package/src/validators/generic/SyntaxValidator.ts +164 -0
  33. package/src/validators/generic/ValidationResult.ts +17 -0
  34. package/src/validators/generic/index.ts +3 -0
  35. package/src/validators/generic/schema/DefinitionSchema.ts +52 -0
  36. package/src/validators/generic/schema/ValidationTypes.ts +134 -0
  37. package/src/validators/generic/schema/index.ts +2 -0
  38. package/src/validators/index.ts +8 -0
@@ -0,0 +1,372 @@
1
+ {
2
+ "serializationFormatVersion": "2023.1",
3
+ "languages" : [
4
+ {
5
+ "key" : "LionCore-M3",
6
+ "version": "2023.1"
7
+ },
8
+ {
9
+ "key" : "LionCore-builtins",
10
+ "version": "2023.1"
11
+ }
12
+ ],
13
+ "nodes" : [
14
+ {
15
+ "id" : "LionCore-builtins",
16
+ "classifier" : {
17
+ "language": "LionCore-M3",
18
+ "version" : "2023.1",
19
+ "key" : "Language"
20
+ },
21
+ "properties" : [
22
+ {
23
+ "property": {
24
+ "language": "LionCore-builtins",
25
+ "version" : "2023.1",
26
+ "key" : "LionCore-builtins-INamed-name"
27
+ },
28
+ "value" : "LionCore_builtins"
29
+ },
30
+ {
31
+ "property": {
32
+ "language": "LionCore-M3",
33
+ "version" : "2023.1",
34
+ "key" : "Language-version"
35
+ },
36
+ "value" : "2023.1"
37
+ },
38
+ {
39
+ "property": {
40
+ "language": "LionCore-M3",
41
+ "version" : "2023.1",
42
+ "key" : "IKeyed-key"
43
+ },
44
+ "value" : "LionCore-builtins"
45
+ }
46
+ ],
47
+ "containments": [
48
+ {
49
+ "containment": {
50
+ "language": "LionCore-M3",
51
+ "version" : "2023.1",
52
+ "key" : "Language-entities"
53
+ },
54
+ "children" : [
55
+ "LionCore-builtins-String",
56
+ "LionCore-builtins-Boolean",
57
+ "LionCore-builtins-Integer",
58
+ "LionCore-builtins-JSON",
59
+ "LionCore-builtins-Node",
60
+ "LionCore-builtins-INamed"
61
+ ]
62
+ }
63
+ ],
64
+ "references" : [
65
+ {
66
+ "reference": {
67
+ "language": "LionCore-M3",
68
+ "version" : "2023.1",
69
+ "key" : "Language-dependsOn"
70
+ },
71
+ "targets" : []
72
+ }
73
+ ],
74
+ "annotations" : [],
75
+ "parent" : null
76
+ },
77
+ {
78
+ "id" : "LionCore-builtins-String",
79
+ "classifier" : {
80
+ "language": "LionCore-M3",
81
+ "version" : "2023.1",
82
+ "key" : "PrimitiveType"
83
+ },
84
+ "properties" : [
85
+ {
86
+ "property": {
87
+ "language": "LionCore-builtins",
88
+ "version" : "2023.1",
89
+ "key" : "LionCore-builtins-INamed-name"
90
+ },
91
+ "value" : "String"
92
+ },
93
+ {
94
+ "property": {
95
+ "language": "LionCore-M3",
96
+ "version" : "2023.1",
97
+ "key" : "IKeyed-key"
98
+ },
99
+ "value" : "LionCore-builtins-String"
100
+ }
101
+ ],
102
+ "containments": [],
103
+ "references" : [],
104
+ "annotations" : [],
105
+ "parent" : "LionCore-builtins"
106
+ },
107
+ {
108
+ "id" : "LionCore-builtins-Boolean",
109
+ "classifier" : {
110
+ "language": "LionCore-M3",
111
+ "version" : "2023.1",
112
+ "key" : "PrimitiveType"
113
+ },
114
+ "properties" : [
115
+ {
116
+ "property": {
117
+ "language": "LionCore-builtins",
118
+ "version" : "2023.1",
119
+ "key" : "LionCore-builtins-INamed-name"
120
+ },
121
+ "value" : "Boolean"
122
+ },
123
+ {
124
+ "property": {
125
+ "language": "LionCore-M3",
126
+ "version" : "2023.1",
127
+ "key" : "IKeyed-key"
128
+ },
129
+ "value" : "LionCore-builtins-Boolean"
130
+ }
131
+ ],
132
+ "containments": [],
133
+ "references" : [],
134
+ "annotations" : [],
135
+ "parent" : "LionCore-builtins"
136
+ },
137
+ {
138
+ "id" : "LionCore-builtins-Integer",
139
+ "classifier" : {
140
+ "language": "LionCore-M3",
141
+ "version" : "2023.1",
142
+ "key" : "PrimitiveType"
143
+ },
144
+ "properties" : [
145
+ {
146
+ "property": {
147
+ "language": "LionCore-builtins",
148
+ "version" : "2023.1",
149
+ "key" : "LionCore-builtins-INamed-name"
150
+ },
151
+ "value" : "Integer"
152
+ },
153
+ {
154
+ "property": {
155
+ "language": "LionCore-M3",
156
+ "version" : "2023.1",
157
+ "key" : "IKeyed-key"
158
+ },
159
+ "value" : "LionCore-builtins-Integer"
160
+ }
161
+ ],
162
+ "containments": [],
163
+ "references" : [],
164
+ "annotations" : [],
165
+ "parent" : "LionCore-builtins"
166
+ },
167
+ {
168
+ "id" : "LionCore-builtins-JSON",
169
+ "classifier" : {
170
+ "language": "LionCore-M3",
171
+ "version" : "2023.1",
172
+ "key" : "PrimitiveType"
173
+ },
174
+ "properties" : [
175
+ {
176
+ "property": {
177
+ "language": "LionCore-builtins",
178
+ "version" : "2023.1",
179
+ "key" : "LionCore-builtins-INamed-name"
180
+ },
181
+ "value" : "JSON"
182
+ },
183
+ {
184
+ "property": {
185
+ "language": "LionCore-M3",
186
+ "version" : "2023.1",
187
+ "key" : "IKeyed-key"
188
+ },
189
+ "value" : "LionCore-builtins-JSON"
190
+ }
191
+ ],
192
+ "containments": [],
193
+ "references" : [],
194
+ "annotations" : [],
195
+ "parent" : "LionCore-builtins"
196
+ },
197
+ {
198
+ "id" : "LionCore-builtins-Node",
199
+ "classifier" : {
200
+ "language": "LionCore-M3",
201
+ "version" : "2023.1",
202
+ "key" : "Concept"
203
+ },
204
+ "properties" : [
205
+ {
206
+ "property": {
207
+ "language": "LionCore-M3",
208
+ "version" : "2023.1",
209
+ "key" : "Concept-abstract"
210
+ },
211
+ "value" : "true"
212
+ },
213
+ {
214
+ "property": {
215
+ "language": "LionCore-M3",
216
+ "version" : "2023.1",
217
+ "key" : "Concept-partition"
218
+ },
219
+ "value" : "false"
220
+ },
221
+ {
222
+ "property": {
223
+ "language": "LionCore-builtins",
224
+ "version" : "2023.1",
225
+ "key" : "LionCore-builtins-INamed-name"
226
+ },
227
+ "value" : "Node"
228
+ },
229
+ {
230
+ "property": {
231
+ "language": "LionCore-M3",
232
+ "version" : "2023.1",
233
+ "key" : "IKeyed-key"
234
+ },
235
+ "value" : "LionCore-builtins-Node"
236
+ }
237
+ ],
238
+ "containments": [
239
+ {
240
+ "containment": {
241
+ "language": "LionCore-M3",
242
+ "version" : "2023.1",
243
+ "key" : "Classifier-features"
244
+ },
245
+ "children" : []
246
+ }
247
+ ],
248
+ "references" : [
249
+ {
250
+ "reference": {
251
+ "language": "LionCore-M3",
252
+ "version" : "2023.1",
253
+ "key" : "Concept-extends"
254
+ },
255
+ "targets" : []
256
+ },
257
+ {
258
+ "reference": {
259
+ "language": "LionCore-M3",
260
+ "version" : "2023.1",
261
+ "key" : "Concept-implements"
262
+ },
263
+ "targets" : []
264
+ }
265
+ ],
266
+ "annotations" : [],
267
+ "parent" : "LionCore-builtins"
268
+ },
269
+ {
270
+ "id" : "LionCore-builtins-INamed",
271
+ "classifier" : {
272
+ "language": "LionCore-M3",
273
+ "version" : "2023.1",
274
+ "key" : "Interface"
275
+ },
276
+ "properties" : [
277
+ {
278
+ "property": {
279
+ "language": "LionCore-builtins",
280
+ "version" : "2023.1",
281
+ "key" : "LionCore-builtins-INamed-name"
282
+ },
283
+ "value" : "INamed"
284
+ },
285
+ {
286
+ "property": {
287
+ "language": "LionCore-M3",
288
+ "version" : "2023.1",
289
+ "key" : "IKeyed-key"
290
+ },
291
+ "value" : "LionCore-builtins-INamed"
292
+ }
293
+ ],
294
+ "containments": [
295
+ {
296
+ "containment": {
297
+ "language": "LionCore-M3",
298
+ "version" : "2023.1",
299
+ "key" : "Classifier-features"
300
+ },
301
+ "children" : [
302
+ "LionCore-builtins-INamed-name"
303
+ ]
304
+ }
305
+ ],
306
+ "references" : [
307
+ {
308
+ "reference": {
309
+ "language": "LionCore-M3",
310
+ "version" : "2023.1",
311
+ "key" : "Interface-extends"
312
+ },
313
+ "targets" : []
314
+ }
315
+ ],
316
+ "annotations" : [],
317
+ "parent" : "LionCore-builtins"
318
+ },
319
+ {
320
+ "id" : "LionCore-builtins-INamed-name",
321
+ "classifier" : {
322
+ "language": "LionCore-M3",
323
+ "version" : "2023.1",
324
+ "key" : "Property"
325
+ },
326
+ "properties" : [
327
+ {
328
+ "property": {
329
+ "language": "LionCore-M3",
330
+ "version" : "2023.1",
331
+ "key" : "Feature-optional"
332
+ },
333
+ "value" : "false"
334
+ },
335
+ {
336
+ "property": {
337
+ "language": "LionCore-builtins",
338
+ "version" : "2023.1",
339
+ "key" : "LionCore-builtins-INamed-name"
340
+ },
341
+ "value" : "name"
342
+ },
343
+ {
344
+ "property": {
345
+ "language": "LionCore-M3",
346
+ "version" : "2023.1",
347
+ "key" : "IKeyed-key"
348
+ },
349
+ "value" : "LionCore-builtins-INamed-name"
350
+ }
351
+ ],
352
+ "containments": [],
353
+ "references" : [
354
+ {
355
+ "reference": {
356
+ "language": "LionCore-M3",
357
+ "version" : "2023.1",
358
+ "key" : "Property-type"
359
+ },
360
+ "targets" : [
361
+ {
362
+ "resolveInfo": "String",
363
+ "reference" : "LionCore-builtins-String"
364
+ }
365
+ ]
366
+ }
367
+ ],
368
+ "annotations" : [],
369
+ "parent" : "LionCore-builtins-INamed"
370
+ }
371
+ ]
372
+ }
@@ -0,0 +1,91 @@
1
+ import { LionWebJsonChunk, LionWebJsonNode, LionWebKey } from "@lionweb/json"
2
+ import { LionWebJsonChunkWrapper, MetaPointers, NodeUtils } from "@lionweb/json-utils"
3
+ import { visitAndMap } from "@lionweb/ts-utils"
4
+ import { isAnnotation, isConcept, isContainment, isInterface, isProperty, isReference } from "./LanguageUtils.js"
5
+
6
+ interface LionWebLanguageWrapperInterface {
7
+ superClassifiers: (classifier: LionWebJsonNode) => LionWebJsonNode[]
8
+ allClassifiers: (classifier: LionWebJsonNode) => LionWebJsonNode[]
9
+ propertyDefinitions: (classifier: LionWebJsonNode) => LionWebJsonNode[]
10
+ allProperties: (classifier: LionWebJsonNode) => LionWebJsonNode[]
11
+ referenceDefinitions: (classifier: LionWebJsonNode) => LionWebJsonNode[]
12
+ allReferenceDefinitions: (classifier: LionWebJsonNode) => LionWebJsonNode[]
13
+ containmentDefinitions: (classifier: LionWebJsonNode) => LionWebJsonNode[]
14
+ allContainments: (classifier: LionWebJsonNode) => LionWebJsonNode[]
15
+ }
16
+
17
+ /**
18
+ * Class encapsulating a chunk that represent a language.
19
+ */
20
+ export class LionWebLanguageWrapper extends LionWebJsonChunkWrapper implements LionWebLanguageWrapperInterface {
21
+ name: string
22
+ version: string
23
+ key: LionWebKey
24
+
25
+ constructor(chunk: LionWebJsonChunk) {
26
+ super(chunk)
27
+ const languageNode: LionWebJsonNode = this.findNodesOfClassifier(MetaPointers.Language)[0]
28
+ const versionProp = NodeUtils.findProperty(languageNode, MetaPointers.LanguageVersion)
29
+ const keyProp = NodeUtils.findProperty(languageNode, MetaPointers.IKeyedKey)
30
+ const nameProp = NodeUtils.findProperty(languageNode, MetaPointers.INamedName)
31
+ this.version = versionProp?.value || "unknown"
32
+ this.key = keyProp?.value || "unknown"
33
+ this.name = nameProp?.value || "unknown"
34
+ }
35
+
36
+ superClassifiers = (classifier: LionWebJsonNode): LionWebJsonNode[] => {
37
+ const result: LionWebJsonNode[] = []
38
+
39
+ if (isConcept(classifier)) {
40
+ const extnds = NodeUtils.findReference(classifier, MetaPointers.ConceptExtends)
41
+ const implments = NodeUtils.findReference(classifier, MetaPointers.ConceptImplements)
42
+ result.push(...this.getReferredNodes(extnds))
43
+ result.push(...this.getReferredNodes(implments))
44
+ } else if (isAnnotation(classifier)) {
45
+ const extnds = NodeUtils.findReference(classifier, MetaPointers.AnnotationExtends)
46
+ const implments = NodeUtils.findReference(classifier, MetaPointers.AnnotationImplements)
47
+ result.push(...this.getReferredNodes(extnds))
48
+ result.push(...this.getReferredNodes(implments))
49
+ } else if (isInterface(classifier)) {
50
+ const extnds = NodeUtils.findReference(classifier, MetaPointers.InterfaceExtends)
51
+ result.push(...this.getReferredNodes(extnds))
52
+ } else {
53
+ throw new Error(`concept type ${typeof classifier} not handled`)
54
+ }
55
+ return result
56
+ }
57
+
58
+ allClassifiers = (classifier: LionWebJsonNode): LionWebJsonNode[] => {
59
+ return visitAndMap(this.superClassifiers, this.superClassifiers)(classifier)
60
+ }
61
+
62
+ propertyDefinitions = (classifier: LionWebJsonNode): LionWebJsonNode[] => {
63
+ const features = NodeUtils.findContainment(classifier, MetaPointers.ClassifierFeatures)
64
+ const properties = this.getChildrenAsNodes(features).filter(f => isProperty(f))
65
+ return properties
66
+ }
67
+
68
+ allProperties = (classifier: LionWebJsonNode): LionWebJsonNode[] => {
69
+ return visitAndMap(this.propertyDefinitions, this.superClassifiers)(classifier)
70
+ }
71
+
72
+ referenceDefinitions = (classifier: LionWebJsonNode): LionWebJsonNode[] => {
73
+ const features = NodeUtils.findContainment(classifier, MetaPointers.ClassifierFeatures)
74
+ const references = this.getChildrenAsNodes(features).filter(f => isReference(f))
75
+ return references
76
+ }
77
+
78
+ allReferenceDefinitions = (classifier: LionWebJsonNode): LionWebJsonNode[] => {
79
+ return visitAndMap(this.referenceDefinitions, this.superClassifiers)(classifier)
80
+ }
81
+
82
+ containmentDefinitions = (classifier: LionWebJsonNode): LionWebJsonNode[] => {
83
+ const features = NodeUtils.findContainment(classifier, MetaPointers.ClassifierFeatures)
84
+ const properties = this.getChildrenAsNodes(features).filter(f => isContainment(f))
85
+ return properties
86
+ }
87
+
88
+ allContainments = (classifier: LionWebJsonNode): LionWebJsonNode[] => {
89
+ return visitAndMap(this.containmentDefinitions, this.superClassifiers)(classifier)
90
+ }
91
+ }
@@ -0,0 +1,41 @@
1
+ import { LionWebJsonMetaPointer, LionWebJsonNode, LionWebKey } from "@lionweb/json"
2
+ import { MetaPointers, NodeUtils } from "@lionweb/json-utils"
3
+
4
+ export class MetaPointerMap {
5
+ /**
6
+ * Map from languageKey => languageVersion => key => LionWebJsonNode
7
+ */
8
+ map: Map<string, Map<string, Map<string, LionWebJsonNode>>> = new Map<string, Map<string, Map<string, LionWebJsonNode>>>()
9
+
10
+ add(languageKey: LionWebKey, languageVersion: string, node: LionWebJsonNode): void {
11
+ const keyProperty = NodeUtils.findProperty(node, MetaPointers.IKeyedKey)
12
+ if (keyProperty === undefined) {
13
+ console.log("MetaPointerMap.add: trying to add node without key property.")
14
+ return
15
+ }
16
+ const key = keyProperty.value
17
+ if (key === undefined || key == null || key === "") {
18
+ console.log("MetaPointerMap.add: trying to add node without key property being empty or null.")
19
+ return
20
+ }
21
+ this.set({ language: languageKey, version: languageVersion, key: key }, node)
22
+ }
23
+
24
+ set(mp: LionWebJsonMetaPointer, node: LionWebJsonNode): void {
25
+ let language = this.map.get(mp.language)
26
+ if (language === undefined) {
27
+ language = new Map<string, Map<string, LionWebJsonNode>>()
28
+ this.map.set(mp.language, language)
29
+ }
30
+ let version = language.get(mp.version)
31
+ if (version === undefined) {
32
+ version = new Map<string, LionWebJsonNode>()
33
+ language.set(mp.version, version)
34
+ }
35
+ version.set(mp.key, node)
36
+ }
37
+
38
+ get(mp: LionWebJsonMetaPointer): LionWebJsonNode | undefined {
39
+ return this.map.get(mp.language)?.get(mp.version)?.get(mp.key)
40
+ }
41
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./LanguageRegistry.js"
2
+ export * from "../languages/LanguageUtils.js"
@@ -0,0 +1,59 @@
1
+ import fs from "fs"
2
+ import { LanguageRegistry } from "../languages/index.js"
3
+ import { ValidationResult } from "../validators/generic/ValidationResult.js"
4
+ import { LionWebValidator } from "../validators/LionWebValidator.js"
5
+ import { getFilesRecursive, printIssues } from "./Utils.js"
6
+
7
+ export function validateFile(file: string, registry: LanguageRegistry): void {
8
+ const result = validateFileResult(file, false, registry)
9
+ printIssues(result)
10
+ }
11
+
12
+ export function validateFileResult(file: string, validateAgainstLanguage: boolean, registry: LanguageRegistry): ValidationResult {
13
+ if (file !== null) {
14
+ const jsonString1 = fs.readFileSync(file, "utf-8")
15
+ const json1 = JSON.parse(jsonString1)
16
+ const validator = new LionWebValidator(json1, registry)
17
+
18
+ validator.validateSyntax()
19
+ validator.validateReferences()
20
+ if (validateAgainstLanguage) {
21
+ validator.validateForLanguage()
22
+ }
23
+ return validator.validationResult
24
+ }
25
+ return new ValidationResult()
26
+ }
27
+
28
+ export function validateFolder(folder: string, registry: LanguageRegistry): void {
29
+ let totalErrors = 0
30
+ let totalSucceed = 0
31
+ let totalFailed = 0
32
+
33
+ for (const f of getFilesRecursive(folder, [])) {
34
+ const jsonString1 = fs.readFileSync(f, "utf-8")
35
+ const json1 = JSON.parse(jsonString1)
36
+ const validator = new LionWebValidator(json1, registry)
37
+
38
+ try {
39
+ validator.validateAll()
40
+
41
+ if (!validator.validationResult.hasErrors()) {
42
+ totalSucceed += 1
43
+ console.log("V PASSED " + f)
44
+ printIssues(validator.validationResult, f)
45
+ } else {
46
+ printIssues(validator.validationResult, f)
47
+ totalFailed += 1
48
+ totalErrors += validator.validationResult.issues.length
49
+ }
50
+ } catch (e: unknown) {
51
+ console.log("EXCEPTION in file: " + f)
52
+ console.log("EXCEPTION " + (e as Error)?.stack)
53
+ }
54
+ }
55
+
56
+ console.log("Total without errors: " + totalSucceed)
57
+ console.log("Total with errors: " + totalFailed)
58
+ console.log("Total number of errors: " + totalErrors)
59
+ }
@@ -0,0 +1,7 @@
1
+ import { LanguageRegistry } from "../languages/index.js"
2
+ import { validateFolder } from "./FileUtils.js"
3
+
4
+ const folder = process.argv[2]
5
+
6
+ const registry = new LanguageRegistry()
7
+ validateFolder(folder, registry)
@@ -0,0 +1,45 @@
1
+ import fs from "fs"
2
+ import { LanguageRegistry } from "../languages/index.js"
3
+ import { LionWebLanguageWrapper } from "../languages/LionWebLanguageWrapper.js"
4
+ import { LionWebValidator } from "../validators/LionWebValidator.js"
5
+ import { getFilesRecursive, printIssues } from "./Utils.js"
6
+
7
+ const folder = process.argv[2]
8
+ const language = process.argv[3]
9
+
10
+ let totalSucceed = 0
11
+ let totalFailed = 0
12
+
13
+ const registry = new LanguageRegistry()
14
+ const languageString = fs.readFileSync(language, "utf-8")
15
+ const languageJson = JSON.parse(languageString)
16
+ const languageValidator = new LionWebValidator(languageJson, registry)
17
+ registry.addLanguage(new LionWebLanguageWrapper(languageJson))
18
+
19
+ console.log("Language is " + language)
20
+ languageValidator.validateSyntax()
21
+ languageValidator.validateReferences()
22
+ if (languageValidator.validationResult.hasErrors()) {
23
+ console.log("===== Language errors, ignoring folder ======")
24
+ printIssues(languageValidator.validationResult)
25
+ process.exit(1)
26
+ }
27
+
28
+ for (const modelFile of getFilesRecursive(folder, [])) {
29
+ const jsonString1 = fs.readFileSync(modelFile, "utf-8")
30
+ const jsonModel = JSON.parse(jsonString1)
31
+ const modelValidator = new LionWebValidator(jsonModel, registry)
32
+
33
+ modelValidator.validateAll()
34
+ if (modelValidator.validationResult.hasErrors()) {
35
+ totalFailed++
36
+ // console.log("FAILED: " + modelFile)
37
+ printIssues(modelValidator.validationResult, modelFile)
38
+ } else {
39
+ console.log("SUCCEEDED: " + modelFile)
40
+ totalSucceed++
41
+ }
42
+ }
43
+
44
+ console.log("Total without errors: " + totalSucceed)
45
+ console.log("Total with errors: " + totalFailed)
@@ -0,0 +1,7 @@
1
+ import { LanguageRegistry } from "../languages/index.js"
2
+ import { validateFile } from "./FileUtils.js"
3
+
4
+ const file1 = process.argv[2]
5
+
6
+ const registry = new LanguageRegistry()
7
+ validateFile(file1, registry)
@@ -0,0 +1,35 @@
1
+ import fs from "fs"
2
+ import { LanguageRegistry } from "../languages/index.js"
3
+ import { LionWebLanguageWrapper } from "../languages/LionWebLanguageWrapper.js"
4
+ import { LionWebValidator } from "../validators/LionWebValidator.js"
5
+ import { printIssues } from "./Utils.js"
6
+
7
+ const modelFile = process.argv[2]
8
+ const language = process.argv[3]
9
+
10
+ if (modelFile !== null) {
11
+ const jsonString1 = fs.readFileSync(modelFile, "utf-8")
12
+ const jsonModel = JSON.parse(jsonString1)
13
+ const languageString = fs.readFileSync(language, "utf-8")
14
+ const languageJson = JSON.parse(languageString)
15
+ const m3String = fs.readFileSync("src/json/LionCore_M3.json", "utf-8")
16
+ const m3Json = JSON.parse(m3String)
17
+ const builtinString = fs.readFileSync("src/json/LionCore_builtins.json", "utf-8")
18
+ const builtinJson = JSON.parse(builtinString)
19
+ const registry = new LanguageRegistry()
20
+ registry.addLanguage(new LionWebLanguageWrapper(m3Json))
21
+ registry.addLanguage(new LionWebLanguageWrapper(builtinJson))
22
+ registry.addLanguage(new LionWebLanguageWrapper(languageJson))
23
+
24
+ const languageValidator = new LionWebValidator(languageJson, registry)
25
+
26
+ languageValidator.validateSyntax()
27
+ languageValidator.validateReferences()
28
+ console.log("===== Language errors ======")
29
+ printIssues(languageValidator.validationResult)
30
+
31
+ const modelValidator = new LionWebValidator(jsonModel, registry)
32
+ modelValidator.validateAll()
33
+ console.log("===== Model errors ======")
34
+ printIssues(modelValidator.validationResult)
35
+ }