@lionweb/validation 0.5.0 → 0.6.0-beta.2

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 (177) hide show
  1. package/README.md +2 -0
  2. package/dist/diff/DiffResult.d.ts +9 -0
  3. package/dist/diff/DiffResult.d.ts.map +1 -0
  4. package/dist/diff/DiffResult.js +18 -0
  5. package/dist/diff/DiffResult.js.map +1 -0
  6. package/dist/diff/LionWebJsonDiff.d.ts +25 -0
  7. package/dist/diff/LionWebJsonDiff.d.ts.map +1 -0
  8. package/dist/diff/LionWebJsonDiff.js +205 -0
  9. package/dist/diff/LionWebJsonDiff.js.map +1 -0
  10. package/dist/diff/changes/Change.d.ts +16 -0
  11. package/dist/diff/changes/Change.d.ts.map +1 -0
  12. package/dist/diff/changes/Change.js +19 -0
  13. package/dist/diff/changes/Change.js.map +1 -0
  14. package/dist/diff/changes/ChunkChange.d.ts +43 -0
  15. package/dist/diff/changes/ChunkChange.d.ts.map +1 -0
  16. package/dist/diff/changes/ChunkChange.js +57 -0
  17. package/dist/diff/changes/ChunkChange.js.map +1 -0
  18. package/dist/diff/changes/ContainmentChange.d.ts +26 -0
  19. package/dist/diff/changes/ContainmentChange.d.ts.map +1 -0
  20. package/dist/diff/changes/ContainmentChange.js +34 -0
  21. package/dist/diff/changes/ContainmentChange.js.map +1 -0
  22. package/dist/diff/changes/NodeChange.d.ts +22 -0
  23. package/dist/diff/changes/NodeChange.d.ts.map +1 -0
  24. package/dist/diff/changes/NodeChange.js +24 -0
  25. package/dist/diff/changes/NodeChange.js.map +1 -0
  26. package/dist/diff/changes/PropertyChange.d.ts +23 -0
  27. package/dist/diff/changes/PropertyChange.d.ts.map +1 -0
  28. package/dist/diff/changes/PropertyChange.js +28 -0
  29. package/dist/diff/changes/PropertyChange.js.map +1 -0
  30. package/dist/diff/changes/ReferenceChange.d.ts +19 -0
  31. package/dist/diff/changes/ReferenceChange.d.ts.map +1 -0
  32. package/dist/diff/changes/ReferenceChange.js +25 -0
  33. package/dist/diff/changes/ReferenceChange.js.map +1 -0
  34. package/dist/diff/changes/index.d.ts +7 -0
  35. package/dist/diff/changes/index.d.ts.map +1 -0
  36. package/dist/diff/changes/index.js +7 -0
  37. package/dist/diff/changes/index.js.map +1 -0
  38. package/dist/diff/index.d.ts +4 -0
  39. package/dist/diff/index.d.ts.map +1 -0
  40. package/dist/diff/index.js +4 -0
  41. package/dist/diff/index.js.map +1 -0
  42. package/dist/index.d.ts +1 -0
  43. package/dist/index.d.ts.map +1 -1
  44. package/dist/index.js +1 -0
  45. package/dist/index.js.map +1 -1
  46. package/dist/issues/LanguageIssues.d.ts +1 -1
  47. package/dist/issues/LanguageIssues.d.ts.map +1 -1
  48. package/dist/issues/LanguageIssues.js.map +1 -1
  49. package/dist/issues/ReferenceIssues.d.ts +1 -1
  50. package/dist/issues/ReferenceIssues.d.ts.map +1 -1
  51. package/dist/issues/ReferenceIssues.js.map +1 -1
  52. package/dist/issues/SyntaxIssues.d.ts +1 -1
  53. package/dist/issues/SyntaxIssues.d.ts.map +1 -1
  54. package/dist/issues/SyntaxIssues.js +4 -4
  55. package/dist/issues/SyntaxIssues.js.map +1 -1
  56. package/dist/issues/ValidationIssue.d.ts +1 -1
  57. package/dist/issues/ValidationIssue.d.ts.map +1 -1
  58. package/dist/issues/ValidationIssue.js.map +1 -1
  59. package/dist/issues/index.d.ts +1 -1
  60. package/dist/issues/index.d.ts.map +1 -1
  61. package/dist/issues/index.js +1 -1
  62. package/dist/issues/index.js.map +1 -1
  63. package/dist/json/ChunkUtils.d.ts.map +1 -1
  64. package/dist/json/ChunkUtils.js.map +1 -1
  65. package/dist/json/JsonContext.d.ts.map +1 -0
  66. package/dist/json/JsonContext.js.map +1 -0
  67. package/dist/json/LanguageUtils.d.ts.map +1 -1
  68. package/dist/json/LanguageUtils.js.map +1 -1
  69. package/dist/json/LionWebJson.d.ts +10 -9
  70. package/dist/json/LionWebJson.d.ts.map +1 -1
  71. package/dist/json/LionWebJson.js +1 -0
  72. package/dist/json/LionWebJson.js.map +1 -1
  73. package/dist/json/LionWebJsonChunkWrapper.d.ts +7 -4
  74. package/dist/json/LionWebJsonChunkWrapper.d.ts.map +1 -1
  75. package/dist/json/LionWebJsonChunkWrapper.js +48 -10
  76. package/dist/json/LionWebJsonChunkWrapper.js.map +1 -1
  77. package/dist/json/LionWebLanguageDefinition.d.ts.map +1 -1
  78. package/dist/json/LionWebLanguageDefinition.js +3 -3
  79. package/dist/json/LionWebLanguageDefinition.js.map +1 -1
  80. package/dist/json/NodeUtils.d.ts +5 -4
  81. package/dist/json/NodeUtils.d.ts.map +1 -1
  82. package/dist/json/NodeUtils.js +5 -2
  83. package/dist/json/NodeUtils.js.map +1 -1
  84. package/dist/json/index.d.ts +1 -0
  85. package/dist/json/index.d.ts.map +1 -1
  86. package/dist/json/index.js +1 -0
  87. package/dist/json/index.js.map +1 -1
  88. package/dist/runners/FileUtils.d.ts.map +1 -1
  89. package/dist/runners/FileUtils.js.map +1 -1
  90. package/dist/runners/RunCheckFolder.js.map +1 -1
  91. package/dist/runners/RunCheckFolderWithLanguage.js.map +1 -1
  92. package/dist/runners/RunCheckOneFile.js.map +1 -1
  93. package/dist/runners/RunCheckOneFileWithLanguage.js.map +1 -1
  94. package/dist/runners/RunLioncoreDiff.js +5 -5
  95. package/dist/runners/RunLioncoreDiff.js.map +1 -1
  96. package/dist/runners/Utils.d.ts.map +1 -1
  97. package/dist/runners/Utils.js +1 -1
  98. package/dist/runners/Utils.js.map +1 -1
  99. package/dist/runners/index.d.ts.map +1 -1
  100. package/dist/runners/index.js.map +1 -1
  101. package/dist/validators/LionWebLanguageReferenceValidator.d.ts +1 -1
  102. package/dist/validators/LionWebLanguageReferenceValidator.d.ts.map +1 -1
  103. package/dist/validators/LionWebLanguageReferenceValidator.js +6 -6
  104. package/dist/validators/LionWebLanguageReferenceValidator.js.map +1 -1
  105. package/dist/validators/LionWebLanguageValidator.d.ts.map +1 -1
  106. package/dist/validators/LionWebLanguageValidator.js +1 -1
  107. package/dist/validators/LionWebLanguageValidator.js.map +1 -1
  108. package/dist/validators/LionWebReferenceValidator.d.ts +1 -1
  109. package/dist/validators/LionWebReferenceValidator.d.ts.map +1 -1
  110. package/dist/validators/LionWebReferenceValidator.js +6 -6
  111. package/dist/validators/LionWebReferenceValidator.js.map +1 -1
  112. package/dist/validators/LionWebSyntaxValidator.d.ts +1 -1
  113. package/dist/validators/LionWebSyntaxValidator.d.ts.map +1 -1
  114. package/dist/validators/LionWebSyntaxValidator.js +21 -11
  115. package/dist/validators/LionWebSyntaxValidator.js.map +1 -1
  116. package/dist/validators/LionWebValidator.d.ts.map +1 -1
  117. package/dist/validators/LionWebValidator.js.map +1 -1
  118. package/dist/validators/SimpleFieldValidator.d.ts +1 -1
  119. package/dist/validators/SimpleFieldValidator.d.ts.map +1 -1
  120. package/dist/validators/SimpleFieldValidator.js +1 -1
  121. package/dist/validators/SimpleFieldValidator.js.map +1 -1
  122. package/dist/validators/ValidationResult.d.ts.map +1 -1
  123. package/dist/validators/ValidationResult.js.map +1 -1
  124. package/dist/validators/index.d.ts.map +1 -1
  125. package/dist/validators/index.js.map +1 -1
  126. package/package.json +5 -2
  127. package/src/diff/DiffResult.ts +21 -0
  128. package/src/diff/LionWebJsonDiff.ts +259 -0
  129. package/src/diff/changes/Change.ts +52 -0
  130. package/src/diff/changes/ChunkChange.ts +68 -0
  131. package/src/diff/changes/ContainmentChange.ts +34 -0
  132. package/src/diff/changes/NodeChange.ts +32 -0
  133. package/src/diff/changes/PropertyChange.ts +29 -0
  134. package/src/diff/changes/ReferenceChange.ts +24 -0
  135. package/src/diff/changes/index.ts +6 -0
  136. package/src/diff/index.ts +3 -0
  137. package/src/index.ts +5 -4
  138. package/src/issues/LanguageIssues.ts +61 -39
  139. package/src/issues/ReferenceIssues.ts +51 -29
  140. package/src/issues/SyntaxIssues.ts +38 -23
  141. package/src/issues/ValidationIssue.ts +7 -7
  142. package/src/issues/index.ts +5 -5
  143. package/src/json/ChunkUtils.ts +7 -11
  144. package/src/json/JsonContext.ts +31 -0
  145. package/src/json/LanguageUtils.ts +5 -6
  146. package/src/json/LionWebJson.ts +44 -43
  147. package/src/json/LionWebJsonChunkWrapper.ts +76 -29
  148. package/src/json/LionWebLanguageDefinition.ts +44 -49
  149. package/src/json/NodeUtils.ts +25 -19
  150. package/src/json/index.ts +7 -6
  151. package/src/json/std-builtins-copy.json +347 -349
  152. package/src/runners/FileUtils.ts +48 -49
  153. package/src/runners/RunCheckFolder.ts +3 -3
  154. package/src/runners/RunCheckFolderWithLanguage.ts +31 -30
  155. package/src/runners/RunCheckOneFile.ts +3 -3
  156. package/src/runners/RunCheckOneFileWithLanguage.ts +21 -19
  157. package/src/runners/RunLioncoreDiff.ts +15 -15
  158. package/src/runners/Utils.ts +24 -24
  159. package/src/runners/index.ts +2 -2
  160. package/src/validators/LionWebLanguageReferenceValidator.ts +63 -55
  161. package/src/validators/LionWebLanguageValidator.ts +11 -12
  162. package/src/validators/LionWebReferenceValidator.ts +90 -76
  163. package/src/validators/LionWebSyntaxValidator.ts +108 -99
  164. package/src/validators/LionWebValidator.ts +33 -33
  165. package/src/validators/SimpleFieldValidator.ts +33 -28
  166. package/src/validators/ValidationResult.ts +5 -6
  167. package/src/validators/index.ts +7 -7
  168. package/dist/diff/LionwebDiff.d.ts +0 -40
  169. package/dist/diff/LionwebDiff.d.ts.map +0 -1
  170. package/dist/diff/LionwebDiff.js +0 -158
  171. package/dist/diff/LionwebDiff.js.map +0 -1
  172. package/dist/issues/JsonContext.d.ts.map +0 -1
  173. package/dist/issues/JsonContext.js.map +0 -1
  174. package/src/diff/LionwebDiff.ts +0 -193
  175. package/src/issues/JsonContext.ts +0 -31
  176. /package/dist/{issues → json}/JsonContext.d.ts +0 -0
  177. /package/dist/{issues → json}/JsonContext.js +0 -0
@@ -1,14 +1,14 @@
1
- import { IncorrectLionCoreVersion_Issue, NotLionCoreLanguageKey_Issue, NumberOfLanguagesUsed_Issue } from "../issues/LanguageIssues.js";
2
- import { JsonContext } from "./../issues/JsonContext.js";
3
- import { LionWebJsonChunk } from "../json/LionWebJson.js";
4
- import { LionWebJsonChunkWrapper } from "../json/LionWebJsonChunkWrapper.js";
5
- import { ValidationResult } from "./ValidationResult.js";
1
+ import { IncorrectLionCoreVersion_Issue, NotLionCoreLanguageKey_Issue, NumberOfLanguagesUsed_Issue } from "../issues/LanguageIssues.js"
2
+ import { JsonContext } from "../json/JsonContext.js"
3
+ import { LionWebJsonChunk } from "../json/LionWebJson.js"
4
+ import { LionWebJsonChunkWrapper } from "../json/LionWebJsonChunkWrapper.js"
5
+ import { ValidationResult } from "./ValidationResult.js"
6
6
 
7
7
  export class LionWebLanguageValidator {
8
- validationResult: ValidationResult;
8
+ validationResult: ValidationResult
9
9
 
10
10
  constructor() {
11
- this.validationResult = new ValidationResult();
11
+ this.validationResult = new ValidationResult()
12
12
  }
13
13
 
14
14
  /**
@@ -22,19 +22,18 @@ export class LionWebLanguageValidator {
22
22
  this.validationResult.issue(new NumberOfLanguagesUsed_Issue(new JsonContext(null, ["languages"]), chunk.languages.length))
23
23
  return
24
24
  }
25
- const usedLanguage = chunk.languages[0];
25
+ const usedLanguage = chunk.languages[0]
26
26
  if (usedLanguage.key !== "LionCore-M3") {
27
27
  this.validationResult.issue(new NotLionCoreLanguageKey_Issue(new JsonContext(null, ["languages", 0]), usedLanguage.key))
28
28
  }
29
29
  if (usedLanguage.version !== "1") {
30
30
  this.validationResult.issue(new IncorrectLionCoreVersion_Issue(new JsonContext(null, ["languages", 0]), usedLanguage.version))
31
31
  }
32
- const chunkWrapper = new LionWebJsonChunkWrapper(chunk);
33
- const languageNodes = chunkWrapper.findNodesOfConcept("Language");
32
+ const chunkWrapper = new LionWebJsonChunkWrapper(chunk)
33
+ const languageNodes = chunkWrapper.findNodesOfConcept("Language")
34
34
  if (languageNodes.length !== 1) {
35
35
  // TODO Better error handling.
36
- console.error("Expected exactly one Language node, found " + languageNodes.length + " => " + JSON.stringify(languageNodes));
37
-
36
+ console.error("Expected exactly one Language node, found " + languageNodes.length + " => " + JSON.stringify(languageNodes))
38
37
  }
39
38
  }
40
39
  }
@@ -2,63 +2,71 @@ import {
2
2
  Duplicates_Issue,
3
3
  Reference_ChildMissingInParent_Issue,
4
4
  Reference_CirculairParent_Issue,
5
- Reference_DuplicateNodeId_Issue, Reference_LanguageUnknown_Issue,
6
- Reference_ParentMissingInChild_Issue
7
- } from "../issues/ReferenceIssues.js";
8
- import { JsonContext } from "./../issues/JsonContext.js";
9
- import { ChunkUtils } from "../json/ChunkUtils.js";
10
- import { LION_CORE_BUILTINS_KEY, LionWebJsonChild, LionWebJsonChunk, LionWebJsonMetaPointer, LionWebJsonNode, LwJsonUsedLanguage } from "../json/LionWebJson.js";
11
- import { LionWebJsonChunkWrapper } from "../json/LionWebJsonChunkWrapper.js";
12
- import { SimpleFieldValidator } from "./SimpleFieldValidator.js";
13
- import { ValidationResult } from "./ValidationResult.js";
5
+ Reference_DuplicateNodeId_Issue,
6
+ Reference_LanguageUnknown_Issue,
7
+ Reference_ParentMissingInChild_Issue,
8
+ } from "../issues/ReferenceIssues.js"
9
+ import { JsonContext } from "../json/JsonContext.js"
10
+ import { ChunkUtils } from "../json/ChunkUtils.js"
11
+ import {
12
+ LION_CORE_BUILTINS_KEY,
13
+ LionWebJsonContainment,
14
+ LionWebJsonChunk,
15
+ LionWebJsonMetaPointer,
16
+ LionWebJsonNode,
17
+ LwJsonUsedLanguage,
18
+ } from "../json/LionWebJson.js"
19
+ import { LionWebJsonChunkWrapper } from "../json/LionWebJsonChunkWrapper.js"
20
+ import { SimpleFieldValidator } from "./SimpleFieldValidator.js"
21
+ import { ValidationResult } from "./ValidationResult.js"
14
22
 
15
23
  /**
16
24
  * Assuming that the syntax is correct, check whether all LionWeb references are correct,
17
25
  * as far as they do not need the used language definition.
18
26
  */
19
27
  export class LionWebReferenceValidator {
20
- validationResult: ValidationResult;
21
- nodesIdMap: Map<string, LionWebJsonNode> = new Map<string, LionWebJsonNode>();
22
- simpleFieldValidator: SimpleFieldValidator;
28
+ validationResult: ValidationResult
29
+ nodesIdMap: Map<string, LionWebJsonNode> = new Map<string, LionWebJsonNode>()
30
+ simpleFieldValidator: SimpleFieldValidator
23
31
 
24
32
  constructor(validationResult: ValidationResult) {
25
- this.validationResult = validationResult;
26
- this.simpleFieldValidator = new SimpleFieldValidator(this.validationResult);
33
+ this.validationResult = validationResult
34
+ this.simpleFieldValidator = new SimpleFieldValidator(this.validationResult)
27
35
  }
28
36
 
29
37
  validateNodeIds(obj: LionWebJsonChunk, ctx: JsonContext): void {
30
38
  // put all nodes in a map, validate that there are no two nodes with the same id.
31
39
  obj.nodes.forEach((node, index) => {
32
40
  // this.validationResult.check(this.nodesIdMap.get(node.id) === undefined, `Node number ${index} has duplicate id "${node.id}"`);
33
- if (! (this.nodesIdMap.get(node.id) === undefined)) {
34
- this.validationResult.issue(new Reference_DuplicateNodeId_Issue(ctx.concat("nodes", index), node.id));
41
+ if (!(this.nodesIdMap.get(node.id) === undefined)) {
42
+ this.validationResult.issue(new Reference_DuplicateNodeId_Issue(ctx.concat("nodes", index), node.id))
35
43
  }
36
- this.nodesIdMap.set(node.id, node);
37
- });
44
+ this.nodesIdMap.set(node.id, node)
45
+ })
38
46
  }
39
47
 
40
48
  validate(obj: LionWebJsonChunkWrapper): void {
41
- const rootCtx = new JsonContext(null, ["$"]);
42
- this.checkDuplicateUsedLanguage(obj.jsonChunk.languages, rootCtx);
43
- this.validateNodeIds(obj.jsonChunk, rootCtx);
49
+ const rootCtx = new JsonContext(null, ["$"])
50
+ this.checkDuplicateUsedLanguage(obj.jsonChunk.languages, rootCtx)
51
+ this.validateNodeIds(obj.jsonChunk, rootCtx)
44
52
  obj.jsonChunk.nodes.forEach((node, nodeIndex) => {
45
- const context = rootCtx.concat(`node`, nodeIndex);
46
- const parentNode = node.parent;
53
+ const context = rootCtx.concat(`node`, nodeIndex)
54
+ const parentNode = node.parent
47
55
  if (parentNode !== null) {
48
- this.validateExistsAsChild(context, this.nodesIdMap.get(parentNode), node);
56
+ this.validateExistsAsChild(context, this.nodesIdMap.get(parentNode), node)
49
57
  }
50
- this.validateLanguageReference(obj, node.classifier, context);
51
- this.checkParentCircular(node, context);
52
- this.checkDuplicate(node.annotations, rootCtx.concat("node", nodeIndex, "annotations"));
53
- this.validateChildrenHaveCorrectParent(node, rootCtx.concat("node", nodeIndex));
58
+ this.validateLanguageReference(obj, node.classifier, context)
59
+ this.checkParentCircular(node, context)
60
+ this.checkDuplicate(node.annotations, rootCtx.concat("node", nodeIndex, "annotations"))
61
+ this.validateChildrenHaveCorrectParent(node, rootCtx.concat("node", nodeIndex))
54
62
  node.properties.forEach((prop, propertyIndex) => {
55
- this.validateLanguageReference(obj, prop.property, rootCtx.concat("node", nodeIndex, "property", propertyIndex));
56
- });
63
+ this.validateLanguageReference(obj, prop.property, rootCtx.concat("node", nodeIndex, "property", propertyIndex))
64
+ })
57
65
  node.containments.forEach((containment, childIndex) => {
58
- this.validateLanguageReference(obj, containment.containment, rootCtx.concat("node", nodeIndex, "containments", childIndex));
59
- this.checkDuplicate(containment.children, rootCtx.concat("node", nodeIndex, "containments", childIndex));
60
- containment.children.forEach((childId) => {
61
- const childNode = this.nodesIdMap.get(childId);
66
+ this.validateLanguageReference(obj, containment.containment, rootCtx.concat("node", nodeIndex, "containments", childIndex))
67
+ this.checkDuplicate(containment.children, rootCtx.concat("node", nodeIndex, "containments", childIndex))
68
+ containment.children.forEach(childId => {
69
+ const childNode = this.nodesIdMap.get(childId)
62
70
  if (childNode !== undefined) {
63
71
  if (childNode.parent !== null && childNode.parent !== undefined && childNode.parent !== node.id) {
64
72
  this.validationResult.issue(new Reference_ChildMissingInParent_Issue(context, childNode, node))
@@ -68,10 +76,10 @@ export class LionWebReferenceValidator {
68
76
  // TODO this.validationResult.error(`Child "${childId}" of node "${node.id}" has different parent "${childNode.parent}"`);
69
77
  }
70
78
  }
71
- });
72
- });
73
- node.annotations.forEach((annotationId) => {
74
- const annotation = this.nodesIdMap.get(annotationId);
79
+ })
80
+ })
81
+ node.annotations.forEach(annotationId => {
82
+ const annotation = this.nodesIdMap.get(annotationId)
75
83
  if (annotation !== undefined) {
76
84
  if (annotation.parent !== null && annotation.parent !== undefined && annotation.parent !== node.id) {
77
85
  this.validationResult.issue(new Reference_ChildMissingInParent_Issue(context, annotation, node))
@@ -81,13 +89,13 @@ export class LionWebReferenceValidator {
81
89
  // TODO this.validationResult.error(`Child "${annotationId}" of node "${node.id}" has different parent "${childNode.parent}"`);
82
90
  }
83
91
  }
84
- });
92
+ })
85
93
  node.references.forEach((ref, refIndex) => {
86
- this.validateLanguageReference(obj, ref.reference, rootCtx.concat("node", nodeIndex, "references", refIndex));
94
+ this.validateLanguageReference(obj, ref.reference, rootCtx.concat("node", nodeIndex, "references", refIndex))
87
95
  // TODO Check for duplicate targets?
88
96
  // If so, what to check because there can be either or both a `resolveInfo` and a `reference`
89
- });
90
- });
97
+ })
98
+ })
91
99
  }
92
100
 
93
101
  /**
@@ -97,10 +105,10 @@ export class LionWebReferenceValidator {
97
105
  * @param context
98
106
  */
99
107
  validateLanguageReference(chunk: LionWebJsonChunkWrapper, metaPointer: LionWebJsonMetaPointer, context: JsonContext) {
100
- const lang = ChunkUtils.findLwUsedLanguageWithVersion(chunk.jsonChunk, metaPointer.language, metaPointer.version);
108
+ const lang = ChunkUtils.findLwUsedLanguageWithVersion(chunk.jsonChunk, metaPointer.language, metaPointer.version)
101
109
  if (metaPointer.language === LION_CORE_BUILTINS_KEY) {
102
110
  // Ok, builtin
103
- return;
111
+ return
104
112
  }
105
113
  if (lang === undefined || lang === null) {
106
114
  this.validationResult.issue(new Reference_LanguageUnknown_Issue(context, metaPointer))
@@ -118,16 +126,16 @@ export class LionWebReferenceValidator {
118
126
  */
119
127
  checkDuplicate(strings: string[], context: JsonContext) {
120
128
  if (strings === null || strings === undefined) {
121
- return;
129
+ return
122
130
  }
123
- const alreadySeen: Record<string, boolean> = {};
124
- strings.forEach((str) => {
131
+ const alreadySeen: Record<string, boolean> = {}
132
+ strings.forEach(str => {
125
133
  if (alreadySeen[str]) {
126
134
  this.validationResult.issue(new Duplicates_Issue(context, str))
127
135
  } else {
128
- alreadySeen[str] = true;
136
+ alreadySeen[str] = true
129
137
  }
130
- });
138
+ })
131
139
  }
132
140
 
133
141
  /**
@@ -138,19 +146,19 @@ export class LionWebReferenceValidator {
138
146
  */
139
147
  checkDuplicateUsedLanguage(usedLanguages: LwJsonUsedLanguage[], context: JsonContext) {
140
148
  if (usedLanguages === null || usedLanguages === undefined) {
141
- return;
149
+ return
142
150
  }
143
- const alreadySeen = new Map<string, string[]>();
151
+ const alreadySeen = new Map<string, string[]>()
144
152
  usedLanguages.forEach((usedLanguage, index) => {
145
- const seenKeys = alreadySeen.get(usedLanguage.key);
153
+ const seenKeys = alreadySeen.get(usedLanguage.key)
146
154
  if (seenKeys !== null && seenKeys !== undefined) {
147
155
  if (seenKeys.includes(usedLanguage.version)) {
148
- this.validationResult.issue(new Duplicates_Issue(context.concat("language", index, "version"), usedLanguage.version));
156
+ this.validationResult.issue(new Duplicates_Issue(context.concat("language", index, "version"), usedLanguage.version))
149
157
  }
150
158
  } else {
151
- alreadySeen.set(usedLanguage.key, [usedLanguage.version]);
159
+ alreadySeen.set(usedLanguage.key, [usedLanguage.version])
152
160
  }
153
- });
161
+ })
154
162
  }
155
163
 
156
164
  /**
@@ -159,61 +167,67 @@ export class LionWebReferenceValidator {
159
167
  */
160
168
  checkParentCircular(node: LionWebJsonNode, context: JsonContext) {
161
169
  if (node === null || node === undefined) {
162
- return;
170
+ return
163
171
  }
164
172
  if (node.parent === null || node.parent === undefined) {
165
- return;
173
+ return
166
174
  }
167
- let current: LionWebJsonNode | undefined = node;
168
- const seenParents = [node.id];
175
+ let current: LionWebJsonNode | undefined = node
176
+ const seenParents = [node.id]
169
177
  while (current !== null && current !== undefined && current.parent !== null && current.parent !== undefined) {
170
- const nextParent = current.parent;
178
+ const nextParent = current.parent
171
179
  if (nextParent !== null && nextParent !== undefined && seenParents.includes(nextParent)) {
172
- this.validationResult.issue(new Reference_CirculairParent_Issue(context.concat("???"), this.nodesIdMap.get(nextParent), seenParents));
173
- return;
180
+ this.validationResult.issue(
181
+ new Reference_CirculairParent_Issue(context.concat("???"), this.nodesIdMap.get(nextParent), seenParents),
182
+ )
183
+ return
174
184
  }
175
- seenParents.push(nextParent);
176
- current = this.nodesIdMap.get(nextParent);
185
+ seenParents.push(nextParent)
186
+ current = this.nodesIdMap.get(nextParent)
177
187
  }
178
188
  }
179
189
 
180
190
  validateExistsAsChild(context: JsonContext, parent: LionWebJsonNode | undefined, child: LionWebJsonNode) {
181
191
  if (parent === undefined || parent === null) {
182
- return;
192
+ return
183
193
  }
184
194
  for (const containment of parent.containments) {
185
195
  if (containment.children.includes(child.id)) {
186
- return;
196
+ return
187
197
  }
188
198
  }
189
199
  if (parent.annotations.includes(child.id)) {
190
- return;
200
+ return
191
201
  }
192
- this.validationResult.issue(new Reference_ChildMissingInParent_Issue(context, child, parent));
202
+ this.validationResult.issue(new Reference_ChildMissingInParent_Issue(context, child, parent))
193
203
  }
194
204
 
195
205
  validateChildrenHaveCorrectParent(node: LionWebJsonNode, context: JsonContext) {
196
- node.containments.forEach((child: LionWebJsonChild) => {
206
+ node.containments.forEach((child: LionWebJsonContainment) => {
197
207
  child.children.forEach((childId: string, index: number) => {
198
- const childNode = this.nodesIdMap.get(childId);
208
+ const childNode = this.nodesIdMap.get(childId)
199
209
  if (childNode !== undefined) {
200
210
  if (childNode.parent !== node.id) {
201
211
  // TODO Check that this is already tested from the child in vaidateExistsAsChild().
202
212
  }
203
213
  if (childNode.parent === null || childNode.parent === undefined) {
204
- this.validationResult.issue(new Reference_ParentMissingInChild_Issue(context.concat("child", "containment", "key", index), node, childNode));
214
+ this.validationResult.issue(
215
+ new Reference_ParentMissingInChild_Issue(context.concat("child", "containment", "key", index), node, childNode),
216
+ )
205
217
  }
206
218
  }
207
- });
208
- });
219
+ })
220
+ })
209
221
  node.annotations.forEach((annotationId: string, annotationIndex: number) => {
210
- const childNode = this.nodesIdMap.get(annotationId);
222
+ const childNode = this.nodesIdMap.get(annotationId)
211
223
  if (childNode !== undefined) {
212
224
  if (childNode.parent === null || childNode.parent === undefined) {
213
- this.validationResult.issue(new Reference_ParentMissingInChild_Issue(context.concat("annotations", annotationIndex), node, childNode));
225
+ this.validationResult.issue(
226
+ new Reference_ParentMissingInChild_Issue(context.concat("annotations", annotationIndex), node, childNode),
227
+ )
214
228
  }
215
229
  }
216
- });
230
+ })
217
231
  // for (const childId of NodeUtils.allChildren(node)) {
218
232
  // const childNode = this.nodesIdMap.get(childId);
219
233
  // if (childNode !== undefined) {