@lionweb/validation 0.6.13-beta.2 → 0.6.13-beta.5
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/index.d.ts +0 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -3
- package/dist/index.js.map +1 -1
- package/dist/issues/LanguageIssues.d.ts +4 -4
- package/dist/issues/LanguageIssues.d.ts.map +1 -1
- package/dist/issues/LanguageIssues.js +1 -1
- 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 +3 -3
- package/dist/issues/ReferenceIssues.js.map +1 -1
- package/dist/issues/SyntaxIssues.d.ts +1 -1
- package/dist/issues/SyntaxIssues.d.ts.map +1 -1
- package/dist/issues/ValidationIssue.d.ts +1 -1
- package/dist/issues/ValidationIssue.d.ts.map +1 -1
- package/dist/issues/ValidationIssue.js.map +1 -1
- package/dist/issues/index.d.ts +0 -1
- package/dist/issues/index.d.ts.map +1 -1
- package/dist/issues/index.js +0 -1
- package/dist/issues/index.js.map +1 -1
- package/dist/languages/CompositeLionWebLanguageWrapper.d.ts +1 -1
- package/dist/languages/CompositeLionWebLanguageWrapper.d.ts.map +1 -1
- package/dist/languages/LanguageRegistry.d.ts +1 -1
- package/dist/languages/LanguageRegistry.d.ts.map +1 -1
- package/dist/languages/LanguageUtils.d.ts +1 -1
- package/dist/languages/LanguageUtils.d.ts.map +1 -1
- package/dist/languages/LanguageUtils.js +5 -5
- package/dist/languages/LanguageUtils.js.map +1 -1
- package/dist/languages/LionWebLanguageWrapper.d.ts +3 -3
- package/dist/languages/LionWebLanguageWrapper.d.ts.map +1 -1
- package/dist/languages/LionWebLanguageWrapper.js +2 -2
- package/dist/languages/LionWebLanguageWrapper.js.map +1 -1
- package/dist/languages/MetaPointerMap.d.ts +2 -2
- package/dist/languages/MetaPointerMap.d.ts.map +1 -1
- package/dist/languages/MetaPointerMap.js +1 -1
- package/dist/languages/MetaPointerMap.js.map +1 -1
- package/dist/runners/FileUtils.d.ts.map +1 -1
- package/dist/runners/FileUtils.js +1 -1
- package/dist/runners/FileUtils.js.map +1 -1
- package/dist/runners/RunCheckFolderWithLanguage.js.map +1 -1
- package/dist/runners/RunLioncoreDiff.js +1 -1
- package/dist/runners/RunLioncoreDiff.js.map +1 -1
- package/dist/validators/LionWebChunkDefinitions.d.ts.map +1 -1
- package/dist/validators/LionWebChunkDefinitions.js +1 -1
- package/dist/validators/LionWebChunkDefinitions.js.map +1 -1
- package/dist/validators/LionWebLanguageReferenceValidator.d.ts +2 -4
- package/dist/validators/LionWebLanguageReferenceValidator.d.ts.map +1 -1
- package/dist/validators/LionWebLanguageReferenceValidator.js +2 -6
- package/dist/validators/LionWebLanguageReferenceValidator.js.map +1 -1
- package/dist/validators/LionWebLanguageValidator.d.ts +2 -3
- package/dist/validators/LionWebLanguageValidator.d.ts.map +1 -1
- package/dist/validators/LionWebLanguageValidator.js +2 -4
- package/dist/validators/LionWebLanguageValidator.js.map +1 -1
- package/dist/validators/LionWebReferenceValidator.d.ts +3 -4
- package/dist/validators/LionWebReferenceValidator.d.ts.map +1 -1
- package/dist/validators/LionWebReferenceValidator.js +2 -3
- package/dist/validators/LionWebReferenceValidator.js.map +1 -1
- package/dist/validators/LionWebSyntaxValidator.d.ts.map +1 -1
- package/dist/validators/LionWebSyntaxValidator.js +1 -1
- package/dist/validators/LionWebSyntaxValidator.js.map +1 -1
- package/dist/validators/LionWebValidator.d.ts +1 -1
- package/dist/validators/LionWebValidator.d.ts.map +1 -1
- package/dist/validators/LionWebValidator.js +2 -2
- package/dist/validators/LionWebValidator.js.map +1 -1
- package/dist/validators/ValidationFunctions.d.ts +5 -1
- package/dist/validators/ValidationFunctions.d.ts.map +1 -1
- package/dist/validators/ValidationFunctions.js +0 -4
- package/dist/validators/ValidationFunctions.js.map +1 -1
- package/dist/validators/generic/SyntaxValidator.d.ts +1 -1
- package/dist/validators/generic/SyntaxValidator.d.ts.map +1 -1
- package/dist/validators/generic/SyntaxValidator.js +1 -1
- package/dist/validators/generic/SyntaxValidator.js.map +1 -1
- package/dist/validators/generic/ValidationTypes.d.ts +1 -1
- package/dist/validators/generic/ValidationTypes.d.ts.map +1 -1
- package/dist/validators/generic/ValidationTypes.js.map +1 -1
- package/package.json +6 -1
- package/src/index.ts +0 -3
- package/src/issues/LanguageIssues.ts +12 -14
- package/src/issues/ReferenceIssues.ts +9 -9
- package/src/issues/SyntaxIssues.ts +5 -5
- package/src/issues/ValidationIssue.ts +7 -4
- package/src/issues/index.ts +0 -1
- package/src/languages/CompositeLionWebLanguageWrapper.ts +1 -1
- package/src/languages/LanguageRegistry.ts +1 -1
- package/src/languages/LanguageUtils.ts +6 -6
- package/src/languages/LionWebLanguageWrapper.ts +5 -9
- package/src/languages/MetaPointerMap.ts +7 -6
- package/src/runners/FileUtils.ts +1 -1
- package/src/runners/RunCheckFolderWithLanguage.ts +1 -1
- package/src/runners/RunLioncoreDiff.ts +2 -2
- package/src/validators/LionWebChunkDefinitions.ts +1 -6
- package/src/validators/LionWebLanguageReferenceValidator.ts +17 -20
- package/src/validators/LionWebLanguageValidator.ts +2 -4
- package/src/validators/LionWebReferenceValidator.ts +6 -14
- package/src/validators/LionWebSyntaxValidator.ts +1 -1
- package/src/validators/LionWebValidator.ts +3 -3
- package/src/validators/ValidationFunctions.ts +1 -1
- package/src/validators/generic/SyntaxValidator.ts +1 -1
- package/src/validators/generic/ValidationTypes.ts +4 -5
- package/dist/diff/DiffResult.d.ts +0 -9
- package/dist/diff/DiffResult.d.ts.map +0 -1
- package/dist/diff/DiffResult.js +0 -18
- package/dist/diff/DiffResult.js.map +0 -1
- package/dist/diff/LionWebJsonDiff.d.ts +0 -25
- package/dist/diff/LionWebJsonDiff.d.ts.map +0 -1
- package/dist/diff/LionWebJsonDiff.js +0 -249
- package/dist/diff/LionWebJsonDiff.js.map +0 -1
- package/dist/diff/changes/Change.d.ts +0 -34
- package/dist/diff/changes/Change.d.ts.map +0 -1
- package/dist/diff/changes/Change.js +0 -38
- package/dist/diff/changes/Change.js.map +0 -1
- package/dist/diff/changes/ChunkChange.d.ts +0 -43
- package/dist/diff/changes/ChunkChange.d.ts.map +0 -1
- package/dist/diff/changes/ChunkChange.js +0 -57
- package/dist/diff/changes/ChunkChange.js.map +0 -1
- package/dist/diff/changes/ContainmentChange.d.ts +0 -25
- package/dist/diff/changes/ContainmentChange.d.ts.map +0 -1
- package/dist/diff/changes/ContainmentChange.js +0 -34
- package/dist/diff/changes/ContainmentChange.js.map +0 -1
- package/dist/diff/changes/NodeChange.d.ts +0 -41
- package/dist/diff/changes/NodeChange.d.ts.map +0 -1
- package/dist/diff/changes/NodeChange.js +0 -54
- package/dist/diff/changes/NodeChange.js.map +0 -1
- package/dist/diff/changes/PropertyChange.d.ts +0 -24
- package/dist/diff/changes/PropertyChange.d.ts.map +0 -1
- package/dist/diff/changes/PropertyChange.js +0 -29
- package/dist/diff/changes/PropertyChange.js.map +0 -1
- package/dist/diff/changes/ReferenceChange.d.ts +0 -25
- package/dist/diff/changes/ReferenceChange.d.ts.map +0 -1
- package/dist/diff/changes/ReferenceChange.js +0 -34
- package/dist/diff/changes/ReferenceChange.js.map +0 -1
- package/dist/diff/changes/index.d.ts +0 -7
- package/dist/diff/changes/index.d.ts.map +0 -1
- package/dist/diff/changes/index.js +0 -7
- package/dist/diff/changes/index.js.map +0 -1
- package/dist/diff/index.d.ts +0 -4
- package/dist/diff/index.d.ts.map +0 -1
- package/dist/diff/index.js +0 -4
- package/dist/diff/index.js.map +0 -1
- package/dist/json/ChunkUtils.d.ts +0 -26
- package/dist/json/ChunkUtils.d.ts.map +0 -1
- package/dist/json/ChunkUtils.js +0 -46
- package/dist/json/ChunkUtils.js.map +0 -1
- package/dist/json/JsonContext.d.ts +0 -11
- package/dist/json/JsonContext.d.ts.map +0 -1
- package/dist/json/JsonContext.js +0 -25
- package/dist/json/JsonContext.js.map +0 -1
- package/dist/json/LionWebJson.d.ts +0 -50
- package/dist/json/LionWebJson.d.ts.map +0 -1
- package/dist/json/LionWebJson.js +0 -27
- package/dist/json/LionWebJson.js.map +0 -1
- package/dist/json/LionWebJsonChunkWrapper.d.ts +0 -39
- package/dist/json/LionWebJsonChunkWrapper.d.ts.map +0 -1
- package/dist/json/LionWebJsonChunkWrapper.js +0 -119
- package/dist/json/LionWebJsonChunkWrapper.js.map +0 -1
- package/dist/json/M3definitions.d.ts +0 -176
- package/dist/json/M3definitions.d.ts.map +0 -1
- package/dist/json/M3definitions.js +0 -174
- package/dist/json/M3definitions.js.map +0 -1
- package/dist/json/NodeUtils.d.ts +0 -23
- package/dist/json/NodeUtils.d.ts.map +0 -1
- package/dist/json/NodeUtils.js +0 -57
- package/dist/json/NodeUtils.js.map +0 -1
- package/dist/json/index.d.ts +0 -7
- package/dist/json/index.d.ts.map +0 -1
- package/dist/json/index.js +0 -7
- package/dist/json/index.js.map +0 -1
- package/dist/util/graphs.d.ts +0 -18
- package/dist/util/graphs.d.ts.map +0 -1
- package/dist/util/graphs.js +0 -27
- package/dist/util/graphs.js.map +0 -1
- package/src/diff/DiffResult.ts +0 -21
- package/src/diff/LionWebJsonDiff.ts +0 -309
- package/src/diff/changes/Change.ts +0 -76
- package/src/diff/changes/ChunkChange.ts +0 -68
- package/src/diff/changes/ContainmentChange.ts +0 -32
- package/src/diff/changes/NodeChange.ts +0 -63
- package/src/diff/changes/PropertyChange.ts +0 -31
- package/src/diff/changes/ReferenceChange.ts +0 -34
- package/src/diff/changes/index.ts +0 -6
- package/src/diff/index.ts +0 -3
- package/src/json/ChunkUtils.ts +0 -49
- package/src/json/JsonContext.ts +0 -31
- package/src/json/LionWebJson.ts +0 -80
- package/src/json/LionWebJsonChunkWrapper.ts +0 -136
- package/src/json/M3definitions.ts +0 -177
- package/src/json/NodeUtils.ts +0 -75
- package/src/json/index.ts +0 -6
- package/src/util/graphs.ts +0 -36
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { JsonContext } from "../../issues/index.js"
|
|
2
|
-
import { LionWebJsonContainment, LionWebJsonMetaPointer, LionWebJsonNode } from "../../json/index.js"
|
|
3
|
-
import { Change, Missing } from "./Change.js"
|
|
4
|
-
|
|
5
|
-
export abstract class ContainmentChange extends Change {
|
|
6
|
-
constructor(
|
|
7
|
-
public context: JsonContext,
|
|
8
|
-
public parentNode: LionWebJsonNode,
|
|
9
|
-
public containment: LionWebJsonMetaPointer,
|
|
10
|
-
public afterContainment: LionWebJsonContainment | undefined,
|
|
11
|
-
public childId: string,
|
|
12
|
-
public missing = Missing.NotMissing
|
|
13
|
-
) {
|
|
14
|
-
super(context)
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export class ChildAdded extends ContainmentChange {
|
|
19
|
-
readonly changeType = "ChildAdded"
|
|
20
|
-
protected msg = () => `Node "${this.parentNode.id}" added child "${this.childId}" to containment ${this.containment.key}`
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export class ChildRemoved extends ContainmentChange {
|
|
24
|
-
readonly changeType = "ChildRemoved"
|
|
25
|
-
protected msg = () => `Node "${this.parentNode.id}" removed child "${this.childId}" from containment "${this.containment.key}"`
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export class ChildOrderChanged extends ContainmentChange {
|
|
29
|
-
readonly changeType = "ChildOrderChanged"
|
|
30
|
-
protected msg = () => `Node "${this.parentNode.id}" changed order of children in containment "${this.containment.key}"`
|
|
31
|
-
}
|
|
32
|
-
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { JsonContext } from "../../issues/index.js"
|
|
2
|
-
import { LionWebJsonMetaPointer, LionWebJsonNode } from "../../json/index.js"
|
|
3
|
-
import { Change, ChangeType } from "./Change.js"
|
|
4
|
-
|
|
5
|
-
export class NodeClassifierChanged extends Change {
|
|
6
|
-
readonly changeType: ChangeType = "NodeClassifierChanged"
|
|
7
|
-
|
|
8
|
-
constructor(
|
|
9
|
-
public context: JsonContext,
|
|
10
|
-
public node: LionWebJsonNode,
|
|
11
|
-
public oldClassifier: LionWebJsonMetaPointer,
|
|
12
|
-
public newClassifier: LionWebJsonMetaPointer,
|
|
13
|
-
) {
|
|
14
|
-
super(context)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
protected msg = () => `Object ${this.node.id} has classifier changed from ${this.oldClassifier.key} to ${this.newClassifier.key}`
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export class ParentChanged extends Change {
|
|
21
|
-
readonly changeType = "ParentChanged"
|
|
22
|
-
|
|
23
|
-
constructor(
|
|
24
|
-
public context: JsonContext,
|
|
25
|
-
public node: LionWebJsonNode,
|
|
26
|
-
public beforeParentId: string | null,
|
|
27
|
-
public afterParentId: string | null,
|
|
28
|
-
) {
|
|
29
|
-
super(context)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
protected msg = () => `Node "${this.node.id}" changed parent from "${this.beforeParentId}" to "${this.afterParentId}`
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export abstract class AnnotationChange extends Change {
|
|
36
|
-
constructor(
|
|
37
|
-
ctx: JsonContext,
|
|
38
|
-
public nodeBefore: LionWebJsonNode,
|
|
39
|
-
public nodeAfter: LionWebJsonNode,
|
|
40
|
-
public annotationId: string,
|
|
41
|
-
public index: number
|
|
42
|
-
) {
|
|
43
|
-
super(ctx)
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export class AnnotationRemoved extends AnnotationChange {
|
|
48
|
-
readonly changeType = "AnnotationRemoved"
|
|
49
|
-
|
|
50
|
-
protected msg = () => `Node "${this.nodeBefore.id}" removed annotation "${this.annotationId}"`
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export class AnnotationAdded extends AnnotationChange {
|
|
54
|
-
readonly changeType = "AnnotationAdded"
|
|
55
|
-
|
|
56
|
-
protected msg = () => `Node "${this.nodeAfter.id}" added annotation "${this.annotationId}"`
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
export class AnnotationOrderChanged extends AnnotationChange {
|
|
61
|
-
readonly changeType = "AnnotationOrderChanged"
|
|
62
|
-
protected msg = () => `Node "${this.nodeAfter.id}" changed order of annotations`
|
|
63
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { JsonContext } from "../../issues/index.js"
|
|
2
|
-
import { LionWebJsonMetaPointer, LionWebJsonNode } from "../../json/index.js"
|
|
3
|
-
import { Change, Missing } from "./Change.js"
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export abstract class PropertyChange extends Change {
|
|
7
|
-
constructor(
|
|
8
|
-
public context: JsonContext,
|
|
9
|
-
public nodeId: string,
|
|
10
|
-
public property: LionWebJsonMetaPointer,
|
|
11
|
-
public oldValue: string | null,
|
|
12
|
-
public newValue: string | null,
|
|
13
|
-
public missing: Missing = Missing.NotMissing
|
|
14
|
-
) {
|
|
15
|
-
super(context)
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export class PropertyValueChanged extends PropertyChange {
|
|
20
|
-
readonly changeType = "PropertyValueChanged"
|
|
21
|
-
protected msg = () => `Node "${this.nodeId} changed value of property "${this.property.key}" from "${this.oldValue}" to "${this.newValue}"`
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export class PropertyAdded extends Change {
|
|
25
|
-
readonly changeType = "PropertyAdded";
|
|
26
|
-
constructor(ctx: JsonContext, public node: LionWebJsonNode, public property: LionWebJsonMetaPointer) {
|
|
27
|
-
super(ctx)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
protected msg = () => `Node "${this.node.id}" containment added: "${JSON.stringify(this.property)}"`
|
|
31
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { JsonContext } from "../../issues/index.js"
|
|
2
|
-
import { LionWebJsonNode, LionWebJsonReference, LionWebJsonReferenceTarget } from "../../json/index.js"
|
|
3
|
-
import { Change, Missing } from "./Change.js"
|
|
4
|
-
|
|
5
|
-
export abstract class ReferenceChange extends Change {
|
|
6
|
-
constructor(
|
|
7
|
-
public context: JsonContext,
|
|
8
|
-
public node: LionWebJsonNode,
|
|
9
|
-
public beforeReference: LionWebJsonReference | undefined,
|
|
10
|
-
public afterReference: LionWebJsonReference | undefined,
|
|
11
|
-
public target: LionWebJsonReferenceTarget,
|
|
12
|
-
public missing = Missing.NotMissing
|
|
13
|
-
) {
|
|
14
|
-
super(context)
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export class TargetAdded extends ReferenceChange {
|
|
19
|
-
readonly changeType = "TargetAdded"
|
|
20
|
-
protected msg = () =>
|
|
21
|
-
`Node "${this.node.id}" added target "${this.target.reference}" to reference "${this?.afterReference?.reference?.key}"`
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export class TargetRemoved extends ReferenceChange {
|
|
25
|
-
readonly changeType = "TargetRemoved"
|
|
26
|
-
protected msg = () =>
|
|
27
|
-
`Node "${this.node.id}" removed target "${this.target.reference}" from reference "${this?.beforeReference?.reference?.key}"`
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export class TargetOrderChanged extends ReferenceChange {
|
|
31
|
-
readonly changeType = "TargetOrderChanged"
|
|
32
|
-
protected msg = () => `Node "${this.node.id}" changed order of targets in reference "${this.afterReference?.reference?.key}"`
|
|
33
|
-
}
|
|
34
|
-
|
package/src/diff/index.ts
DELETED
package/src/json/ChunkUtils.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { LionWebJsonChunk, LionWebJsonNode, LwJsonUsedLanguage } from "./LionWebJson.js"
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Utility functions for LionWeb chunks
|
|
5
|
-
*/
|
|
6
|
-
export class ChunkUtils {
|
|
7
|
-
/**
|
|
8
|
-
* Find a used language in `chunk` with `key`.
|
|
9
|
-
* @param chunk
|
|
10
|
-
* @param key
|
|
11
|
-
*/
|
|
12
|
-
static findLwUsedLanguage(chunk: LionWebJsonChunk, key: string): LwJsonUsedLanguage | null {
|
|
13
|
-
for (const language of chunk.languages) {
|
|
14
|
-
if (language.key === key) {
|
|
15
|
-
return language
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
return null
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Find a used language in `chunk` with `key` and 'version'.
|
|
23
|
-
* @param chunk
|
|
24
|
-
* @param key
|
|
25
|
-
* @param version
|
|
26
|
-
*/
|
|
27
|
-
static findLwUsedLanguageWithVersion(chunk: LionWebJsonChunk, key: string, version: string): LwJsonUsedLanguage | null {
|
|
28
|
-
for (const language of chunk.languages) {
|
|
29
|
-
if (language.key === key && language.version === version) {
|
|
30
|
-
return language
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return null
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Find node with id equals `id` in `chunk`.
|
|
38
|
-
* @param chunk
|
|
39
|
-
* @param id
|
|
40
|
-
*/
|
|
41
|
-
static findNode(chunk: LionWebJsonChunk, id: string): LionWebJsonNode | null {
|
|
42
|
-
for (const node of chunk.nodes) {
|
|
43
|
-
if (node.id === id) {
|
|
44
|
-
return node
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
return null
|
|
48
|
-
}
|
|
49
|
-
}
|
package/src/json/JsonContext.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
type JsonPath = (string | number)[]
|
|
2
|
-
|
|
3
|
-
export class JsonContext {
|
|
4
|
-
private parent: JsonContext | null
|
|
5
|
-
private local_path: JsonPath
|
|
6
|
-
|
|
7
|
-
concat(...items: JsonPath): JsonContext {
|
|
8
|
-
return new JsonContext(this, items)
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
path(): JsonPath {
|
|
12
|
-
return this.parent === null ? this.local_path : this.parent.path().concat(this.local_path)
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
constructor(parent: JsonContext | null, path: JsonPath) {
|
|
16
|
-
this.parent = parent
|
|
17
|
-
this.local_path = path
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
toString(): string {
|
|
21
|
-
let result = ""
|
|
22
|
-
this.path().forEach((part, index) => {
|
|
23
|
-
if (typeof part === "string") {
|
|
24
|
-
result += (index === 0 ? "" : ".") + part
|
|
25
|
-
} else if (typeof part === "number") {
|
|
26
|
-
result += "[" + part + "]"
|
|
27
|
-
}
|
|
28
|
-
})
|
|
29
|
-
return result
|
|
30
|
-
}
|
|
31
|
-
}
|
package/src/json/LionWebJson.ts
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { LION_CORE_M3_KEY, LION_CORE_M3_VERSION } from "./M3definitions.js"
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* The types defining the structure of the LionWeb JSON format.
|
|
5
|
-
* @see https://lionweb-io.github.io/specification/serialization/serialization.html
|
|
6
|
-
* We use types instead of classes, because the purpose is to define the Lionweb JSON to be sent over the line.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export function isLionWebM3Language(language: LwJsonUsedLanguage): boolean {
|
|
11
|
-
return language.key === LION_CORE_M3_KEY && language.version === LION_CORE_M3_VERSION
|
|
12
|
-
}
|
|
13
|
-
export type LionWebId = string
|
|
14
|
-
|
|
15
|
-
export type LionWebJsonMetaPointer = {
|
|
16
|
-
language: string
|
|
17
|
-
version: string
|
|
18
|
-
key: string // key of concept, property, containment, referenve or property
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function isEqualMetaPointer(p1: LionWebJsonMetaPointer, p2: LionWebJsonMetaPointer): boolean {
|
|
22
|
-
return p1.key === p2.key && p1.version === p2.version && p1.language === p2.language
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function isEqualReferenceTarget(first: LionWebJsonReferenceTarget, second: LionWebJsonReferenceTarget): boolean {
|
|
26
|
-
return first.reference === second.reference && first.resolveInfo === second.resolveInfo
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export type LionWebJsonChunk = {
|
|
30
|
-
serializationFormatVersion: string
|
|
31
|
-
languages: LwJsonUsedLanguage[]
|
|
32
|
-
nodes: LionWebJsonNode[]
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export type LwJsonUsedLanguage = {
|
|
36
|
-
key: string
|
|
37
|
-
version: string
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export type LionWebJsonNode = {
|
|
41
|
-
id: LionWebId
|
|
42
|
-
classifier: LionWebJsonMetaPointer
|
|
43
|
-
properties: LionWebJsonProperty[]
|
|
44
|
-
containments: LionWebJsonContainment[]
|
|
45
|
-
references: LionWebJsonReference[]
|
|
46
|
-
annotations: LionWebId[]
|
|
47
|
-
parent: (LionWebId | null)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export function createLwNode(): LionWebJsonNode {
|
|
51
|
-
return {
|
|
52
|
-
id: "",
|
|
53
|
-
classifier: { language: "", version: "", key: "" },
|
|
54
|
-
properties: [],
|
|
55
|
-
containments: [],
|
|
56
|
-
references: [],
|
|
57
|
-
annotations: [],
|
|
58
|
-
parent: null,
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export type LionWebJsonProperty = {
|
|
63
|
-
property: LionWebJsonMetaPointer
|
|
64
|
-
value: (string | null)
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export type LionWebJsonContainment = {
|
|
68
|
-
containment: LionWebJsonMetaPointer
|
|
69
|
-
children: LionWebId[]
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export type LionWebJsonReference = {
|
|
73
|
-
reference: LionWebJsonMetaPointer
|
|
74
|
-
targets: LionWebJsonReferenceTarget[]
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export type LionWebJsonReferenceTarget = {
|
|
78
|
-
resolveInfo: (string | null)
|
|
79
|
-
reference: LionWebId
|
|
80
|
-
}
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isEqualMetaPointer,
|
|
3
|
-
LionWebId,
|
|
4
|
-
LionWebJsonChunk,
|
|
5
|
-
LionWebJsonContainment,
|
|
6
|
-
LionWebJsonMetaPointer,
|
|
7
|
-
LionWebJsonNode,
|
|
8
|
-
LionWebJsonReference
|
|
9
|
-
} from "./LionWebJson.js"
|
|
10
|
-
import { MetaPointers } from "./M3definitions.js"
|
|
11
|
-
import { NodeUtils } from "./NodeUtils.js"
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Wraps around a LionWebJsonChunk, providing access to information inside, might be using caches to improve performance.
|
|
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.
|
|
17
|
-
*/
|
|
18
|
-
export class LionWebJsonChunkWrapper {
|
|
19
|
-
jsonChunk: LionWebJsonChunk
|
|
20
|
-
/**
|
|
21
|
-
* Map to get quick access to nodes by id.
|
|
22
|
-
* @protected
|
|
23
|
-
*/
|
|
24
|
-
protected nodesIdMap: Map<LionWebId, LionWebJsonNode> = new Map<LionWebId, LionWebJsonNode>()
|
|
25
|
-
|
|
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)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/** Put all nodes in a map, validate that there are no two nodes with the same id.
|
|
36
|
-
* The check should logically be in LionWebReferenceValidator, but the created map is needed here.
|
|
37
|
-
*/
|
|
38
|
-
prepareNodeIds(chunk: LionWebJsonChunk) {
|
|
39
|
-
chunk.nodes.forEach(node => {
|
|
40
|
-
this.nodesIdMap.set(node.id, node)
|
|
41
|
-
})
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
getNode(id: string): LionWebJsonNode | undefined {
|
|
45
|
-
return this.nodesIdMap.get(id)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
findNodesOfClassifier(concept: LionWebJsonMetaPointer): LionWebJsonNode[] {
|
|
49
|
-
return this.jsonChunk.nodes.filter(node => isEqualMetaPointer(node.classifier, concept))
|
|
50
|
-
}
|
|
51
|
-
|
|
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 []
|
|
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
|
-
})
|
|
86
|
-
return result
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
asString(): string {
|
|
90
|
-
let result = ""
|
|
91
|
-
const partitions = this.jsonChunk.nodes.filter(n => n.parent === null)
|
|
92
|
-
partitions.forEach(partition => {
|
|
93
|
-
const pString = this.recursiveToString(partition, 1)
|
|
94
|
-
result += pString
|
|
95
|
-
})
|
|
96
|
-
return result
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
private recursiveToString(node: LionWebJsonNode | undefined, depth: number): string {
|
|
100
|
-
if (node === undefined) {
|
|
101
|
-
return ""
|
|
102
|
-
}
|
|
103
|
-
let result: string = ""
|
|
104
|
-
const nameProperty = NodeUtils.findProperty(node, MetaPointers.INamedName)
|
|
105
|
-
const name = nameProperty === undefined ? "" : " " + nameProperty.value
|
|
106
|
-
result += this.indent(depth) + "(" + node.id + ")" + name + "\n"
|
|
107
|
-
if (node.annotations !== undefined && node.annotations.length !== 0) {
|
|
108
|
-
result += this.indent(depth + 1) + "*Annotations*" + "\n"
|
|
109
|
-
node.annotations.forEach(ann => {
|
|
110
|
-
result += this.recursiveToString(this.getNode(ann), depth + 1)
|
|
111
|
-
// result += this.indent(depth) + "[[" + JSON.stringify(ann) + "]]\n"
|
|
112
|
-
})
|
|
113
|
-
}
|
|
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
|
-
})
|
|
119
|
-
node.references.forEach(ref => {
|
|
120
|
-
result += this.indent(depth + 1) + "*" + ref.reference.key + "*: " + JSON.stringify(ref.targets) + "\n"
|
|
121
|
-
})
|
|
122
|
-
node.containments.forEach(cont => {
|
|
123
|
-
if (cont.children.length !== 0) {
|
|
124
|
-
result += this.indent(depth + 1) + "*" + cont.containment.key + "*" + "\n"
|
|
125
|
-
cont.children.forEach(ch => {
|
|
126
|
-
result += this.recursiveToString(this.getNode(ch), depth + 1)
|
|
127
|
-
})
|
|
128
|
-
}
|
|
129
|
-
})
|
|
130
|
-
return result
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
private indent(depth: number): string {
|
|
134
|
-
return Array(depth).join(" ")
|
|
135
|
-
}
|
|
136
|
-
}
|
|
@@ -1,177 +0,0 @@
|
|
|
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
|
-
}
|