@lionweb/class-core-generator 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/api/entity-types.templates.d.ts +3 -2
- package/dist/api/entity-types.templates.d.ts.map +1 -1
- package/dist/api/entity-types.templates.js +2 -2
- package/dist/api/entity-types.templates.js.map +1 -1
- package/dist/api/generation-headers.js.map +1 -1
- package/dist/api/generator.d.ts.map +1 -1
- package/dist/api/generator.js.map +1 -1
- package/dist/api/helpers/classifiers.d.ts.map +1 -1
- package/dist/api/helpers/classifiers.js +1 -1
- package/dist/api/helpers/classifiers.js.map +1 -1
- package/dist/api/helpers/dependencies.d.ts.map +1 -1
- package/dist/api/helpers/dependencies.js +2 -2
- package/dist/api/helpers/dependencies.js.map +1 -1
- package/dist/api/helpers/entities.d.ts.map +1 -1
- package/dist/api/helpers/entities.js.map +1 -1
- package/dist/api/helpers/features.d.ts.map +1 -1
- package/dist/api/helpers/features.js.map +1 -1
- package/dist/api/helpers/imports-tracking.d.ts +3 -0
- package/dist/api/helpers/imports-tracking.d.ts.map +1 -1
- package/dist/api/helpers/imports-tracking.js +8 -0
- package/dist/api/helpers/imports-tracking.js.map +1 -1
- package/dist/api/helpers/mps-annotations.d.ts +6 -6
- package/dist/api/helpers/mps-annotations.d.ts.map +1 -1
- package/dist/api/helpers/mps-annotations.js.map +1 -1
- package/dist/api/helpers/types.d.ts.map +1 -1
- package/dist/api/helpers/types.js +8 -4
- package/dist/api/helpers/types.js.map +1 -1
- package/dist/api/index-ts.d.ts.map +1 -1
- package/dist/api/index-ts.js +4 -5
- package/dist/api/index-ts.js.map +1 -1
- package/dist/api/language-file.templates.d.ts.map +1 -1
- package/dist/api/language-file.templates.js +7 -10
- package/dist/api/language-file.templates.js.map +1 -1
- package/dist/api/mega-factory.templates.d.ts.map +1 -1
- package/dist/api/mega-factory.templates.js +4 -7
- package/dist/api/mega-factory.templates.js.map +1 -1
- package/dist/api/reflective-layer.templates.d.ts.map +1 -1
- package/dist/api/reflective-layer.templates.js +19 -34
- package/dist/api/reflective-layer.templates.js.map +1 -1
- package/dist/utils/textgen.d.ts.map +1 -1
- package/dist/utils/textgen.js.map +1 -1
- package/package.json +5 -3
- package/src/api/entity-types.templates.ts +6 -7
- package/src/api/generation-headers.ts +1 -1
- package/src/api/generator.ts +10 -10
- package/src/api/helpers/classifiers.ts +3 -15
- package/src/api/helpers/dependencies.ts +4 -4
- package/src/api/helpers/entities.ts +2 -8
- package/src/api/helpers/features.ts +1 -2
- package/src/api/helpers/imports-tracking.ts +12 -5
- package/src/api/helpers/mps-annotations.ts +6 -8
- package/src/api/helpers/types.ts +9 -6
- package/src/api/index-ts.ts +26 -16
- package/src/api/language-file.templates.ts +12 -16
- package/src/api/mega-factory.templates.ts +20 -26
- package/src/api/reflective-layer.templates.ts +46 -69
- package/src/utils/textgen.ts +1 -1
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
//
|
|
15
15
|
// SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
|
|
16
16
|
// SPDX-License-Identifier: Apache-2.0
|
|
17
|
-
import { Annotation,
|
|
17
|
+
import { Annotation, Classifier, Concept, Enumeration, featureMetaType, Interface, isConcrete, isEnumeration, isMultiple, Link, nameOf, PrimitiveType, Property } from "@lionweb/core";
|
|
18
|
+
import { asArray } from "@lionweb/ts-utils";
|
|
18
19
|
import { when, withNewlineAppended } from "littoral-templates";
|
|
19
20
|
import { indent, switchOrIf } from "../utils/textgen.js";
|
|
20
21
|
import { entityMetaType, extendsFrom, nameOfBaseClassForLanguage } from "./helpers/index.js";
|
|
@@ -28,10 +29,7 @@ export const reflectiveClassFor = (imports) => {
|
|
|
28
29
|
`private readonly _${qName} = new ${imports.core(metaType)}(this._${classifier.name}, "${name}", "${key}", "${id}")${optional ? ".isOptional()" : ""}${isMultiple(feature) ? ".isMultiple()" : ""};`,
|
|
29
30
|
// | core (2nd x) |
|
|
30
31
|
`get ${qName}(): ${metaType} {`,
|
|
31
|
-
indent([
|
|
32
|
-
`this.ensureWiredUp();`,
|
|
33
|
-
`return this._${qName};`
|
|
34
|
-
]),
|
|
32
|
+
indent([`this.ensureWiredUp();`, `return this._${qName};`]),
|
|
35
33
|
`}`
|
|
36
34
|
];
|
|
37
35
|
};
|
|
@@ -39,13 +37,10 @@ export const reflectiveClassFor = (imports) => {
|
|
|
39
37
|
const { name, key, id, features } = classifier;
|
|
40
38
|
const metaType = entityMetaType(classifier);
|
|
41
39
|
return [
|
|
42
|
-
`public readonly _${name} = new ${imports.core(metaType)}(this._language, "${name}", "${key}", "${id}"${classifier instanceof Concept ?
|
|
40
|
+
`public readonly _${name} = new ${imports.core(metaType)}(this._language, "${name}", "${key}", "${id}"${classifier instanceof Concept ? ", " + classifier.abstract : ""});`,
|
|
43
41
|
// | core (2nd x) |
|
|
44
42
|
`get ${name}(): ${metaType} {`,
|
|
45
|
-
indent([
|
|
46
|
-
`this.ensureWiredUp();`,
|
|
47
|
-
`return this._${name};`
|
|
48
|
-
]),
|
|
43
|
+
indent([`this.ensureWiredUp();`, `return this._${name};`]),
|
|
49
44
|
`}`,
|
|
50
45
|
features.map(reflectiveMembersForFeature)
|
|
51
46
|
];
|
|
@@ -57,10 +52,7 @@ export const reflectiveClassFor = (imports) => {
|
|
|
57
52
|
`private readonly _${qName} = new ${imports.core("EnumerationLiteral")}(this._${enumeration.name}, "${name}", "${key}", "${id}");`,
|
|
58
53
|
// | core (2nd x) |
|
|
59
54
|
`get ${qName}(): EnumerationLiteral {`,
|
|
60
|
-
indent([
|
|
61
|
-
`this.ensureWiredUp();`,
|
|
62
|
-
`return this._${qName};`
|
|
63
|
-
]),
|
|
55
|
+
indent([`this.ensureWiredUp();`, `return this._${qName};`]),
|
|
64
56
|
`}`
|
|
65
57
|
];
|
|
66
58
|
};
|
|
@@ -68,10 +60,7 @@ export const reflectiveClassFor = (imports) => {
|
|
|
68
60
|
`public readonly _${name} = new ${imports.core("Enumeration")}(this._language, "${name}", "${key}", "${id}");`,
|
|
69
61
|
// | core (2nd x) |
|
|
70
62
|
`get ${name}(): Enumeration {`,
|
|
71
|
-
indent([
|
|
72
|
-
`this.ensureWiredUp();`,
|
|
73
|
-
`return this._${name};`
|
|
74
|
-
]),
|
|
63
|
+
indent([`this.ensureWiredUp();`, `return this._${name};`]),
|
|
75
64
|
`}`,
|
|
76
65
|
literals.map(reflectiveMemberForEnumerationLiteral)
|
|
77
66
|
];
|
|
@@ -79,10 +68,7 @@ export const reflectiveClassFor = (imports) => {
|
|
|
79
68
|
`public readonly _${name} = new ${imports.core("PrimitiveType")}(this._language, "${name}", "${key}", "${id}");`,
|
|
80
69
|
// | core (2nd x) |
|
|
81
70
|
`get ${name}(): PrimitiveType {`,
|
|
82
|
-
indent([
|
|
83
|
-
`this.ensureWiredUp();`,
|
|
84
|
-
`return this._${name};`
|
|
85
|
-
]),
|
|
71
|
+
indent([`this.ensureWiredUp();`, `return this._${name};`]),
|
|
86
72
|
`}`
|
|
87
73
|
];
|
|
88
74
|
const reflectiveMembersForEntity = (entity) => {
|
|
@@ -130,11 +116,11 @@ export const reflectiveClassFor = (imports) => {
|
|
|
130
116
|
if (entity instanceof Classifier) {
|
|
131
117
|
const extends_ = extendsFrom(entity);
|
|
132
118
|
return [
|
|
133
|
-
extends_ instanceof Classifier
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
119
|
+
extends_ instanceof Classifier ? `this._${name}.extends = ${refForType(extends_)};` : [],
|
|
120
|
+
when(entity instanceof Interface && entity.extends.length > 0)(() => `this._${name}.extending(${entity.extends.map(interface_ => refForType(interface_)).join(", ")});`),
|
|
121
|
+
when(isConcreteClassifier(entity) && entity.implements.length > 0)(() => `this._${name}.implementing(${asArray(entity.implements)
|
|
122
|
+
.map(interface_ => refForType(interface_))
|
|
123
|
+
.join(", ")});`),
|
|
138
124
|
when(entity.features.length > 0)(`this._${name}.havingFeatures(${entity.features.map(nameOf).map(thisLocalName).join(", ")});`),
|
|
139
125
|
entity.features.map(wireUpStatementsForFeature)
|
|
140
126
|
];
|
|
@@ -161,10 +147,7 @@ export const reflectiveClassFor = (imports) => {
|
|
|
161
147
|
`private readonly _language: ${imports.core("Language")} = new Language("${imports.thisLanguageNameAsJsIdentifier}", "${version}", "${id}", "${key}");`,
|
|
162
148
|
// | core | (3rd x)
|
|
163
149
|
`get language(): Language {`,
|
|
164
|
-
indent([
|
|
165
|
-
`this.ensureWiredUp();`,
|
|
166
|
-
`return this._language;`
|
|
167
|
-
]),
|
|
150
|
+
indent([`this.ensureWiredUp();`, `return this._language;`]),
|
|
168
151
|
`}`,
|
|
169
152
|
``,
|
|
170
153
|
entities.map(withNewlineAppended(reflectiveMembersForEntity)),
|
|
@@ -182,8 +165,10 @@ export const reflectiveClassFor = (imports) => {
|
|
|
182
165
|
``,
|
|
183
166
|
`factory(${parameterPrefix}handleDelta?: ${imports.generic("DeltaHandler")}): ${imports.generic("NodeBaseFactory")} {`,
|
|
184
167
|
indent([
|
|
185
|
-
`return (classifier: ${imports.core("Classifier")}, ${parameterPrefix}id: ${imports.
|
|
186
|
-
indent(switchOrIf("classifier.key", concreteClassifiers
|
|
168
|
+
`return (classifier: ${imports.core("Classifier")}, ${parameterPrefix}id: ${imports.json("LionWebId")}) => {`,
|
|
169
|
+
indent(switchOrIf("classifier.key", concreteClassifiers
|
|
170
|
+
.map(nameOf)
|
|
171
|
+
.map(name => [`this._${name}.key`, `${name}.create(id, ${parameterPrefix}handleDelta)`]), [
|
|
187
172
|
`const {language} = classifier;`,
|
|
188
173
|
`throw new Error(\`can't instantiate \${classifier.name} (key=\${classifier.key}): classifier is not known in language \${language.name} (key=\${language.key}, version=\${language.version})\`);`
|
|
189
174
|
])),
|
|
@@ -195,7 +180,7 @@ export const reflectiveClassFor = (imports) => {
|
|
|
195
180
|
// (Why can this work?! EnumType is an unsatisfied generic parameter!)
|
|
196
181
|
indent([
|
|
197
182
|
`const {enumeration} = enumerationLiteral;`,
|
|
198
|
-
switchOrIf("enumeration.key", enumerations.map(nameOf).map(
|
|
183
|
+
switchOrIf("enumeration.key", enumerations.map(nameOf).map(name => [`this._${name}.key`, "enumerationLiteral.key as EnumType"]), [
|
|
199
184
|
`const {language} = enumeration;`,
|
|
200
185
|
`throw new Error(\`enumeration with key \${enumeration.key} is not known in language \${language.name} (key=\${language.key}, version=\${language.version})\`);`
|
|
201
186
|
])
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reflective-layer.templates.js","sourceRoot":"","sources":["../../src/api/reflective-layer.templates.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,EAAE;AACF,iEAAiE;AACjE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC,EAAE;AACF,sEAAsE;AACtE,sCAAsC;AAEtC,OAAO,EACH,UAAU,EACV,
|
|
1
|
+
{"version":3,"file":"reflective-layer.templates.js","sourceRoot":"","sources":["../../src/api/reflective-layer.templates.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,EAAE;AACF,iEAAiE;AACjE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC,EAAE;AACF,sEAAsE;AACtE,sCAAsC;AAEtC,OAAO,EACH,UAAU,EACV,UAAU,EACV,OAAO,EACP,WAAW,EAGX,eAAe,EACf,SAAS,EACT,UAAU,EACV,aAAa,EACb,UAAU,EAGV,IAAI,EACJ,MAAM,EACN,aAAa,EACb,QAAQ,EAEX,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAC3C,OAAO,EAAE,IAAI,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,C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AuBA,OAAO,
|
|
1
|
+
{"version":3,"file":"textgen.d.ts","sourceRoot":"","sources":["../../src/utils/textgen.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAwB,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAGnE;;GAEG;AACH,eAAO,MAAM,MAAM,2BAAwB,CAAA;AAY3C;;GAEG;AACH,eAAO,MAAM,cAAc,QAXjB,MAAM,WAWsD,CAAA;AAEtE;;GAEG;AACH,eAAO,MAAM,cAAc,QAhBjB,MAAM,WAgBsD,CAAA;AAGtE;;GAEG;AACH,eAAO,MAAM,cAAc,QAAS,MAAM,KAAG,MAGhB,CAAA;AAG7B,eAAO,MAAM,QAAQ,cAAe,OAAO,QAAQ,MAAM,MAAM,SAAS,MAAM,YACnE,MAAM,WAGC,CAAA;AAGlB,MAAM,MAAM,SAAS,GAAG,CAAC,cAAc,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,CAAC,CAAA;AAErE,eAAO,MAAM,UAAU,eAAgB,MAAM,SAAS,SAAS,EAAE,gBAAgB,QAAQ,eAiBhF,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textgen.js","sourceRoot":"","sources":["../../src/utils/textgen.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,EAAE;AACF,iEAAiE;AACjE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC,EAAE;AACF,sEAAsE;AACtE,sCAAsC;AAEtC;;;GAGG;AAGH,OAAO,
|
|
1
|
+
{"version":3,"file":"textgen.js","sourceRoot":"","sources":["../../src/utils/textgen.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,EAAE;AACF,iEAAiE;AACjE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE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AAI,EAAE,GAAG,IAAI,GAAG,KAAK,EAAE;IAC5B,CAAC,CAAC,IAAI,CAAA;AAKlB,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,UAAkB,EAAE,KAAkB,EAAE,YAAsB,EAAE,EAAE,CACzF,KAAK,CAAC,MAAM,GAAG,CAAC;IACZ,CAAC,CAAC;QACE,WAAW,UAAU,KAAK;QAC1B,MAAM,CAAC;YACH,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,cAAc,EAAE,WAAW,CAAC,EAAE,EAAE,CAAC,QAAQ,cAAc,YAAY,WAAW,GAAG,CAAC;YAC9F,YAAY,OAAO,YAAY,KAAK,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,GAAG,EAAE,MAAM,CAAC,YAAY,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE;SAC7G,CAAC;QACF,GAAG;KACN;IACD,CAAC,CAAC;QACE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,cAAc,EAAE,WAAW,CAAC,EAAE,EAAE,CAAC;YACzC,OAAO,UAAU,QAAQ,cAAc,KAAK;YAC5C,MAAM,CAAC,UAAU,WAAW,GAAG,CAAC;YAChC,GAAG;SACN,CAAC;QACF,YAAY;KACf,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lionweb/class-core-generator",
|
|
3
|
-
"version": "0.6.13-beta.
|
|
3
|
+
"version": "0.6.13-beta.5",
|
|
4
4
|
"description": "Generator for implementations of languages based on the class-core package",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -25,8 +25,10 @@
|
|
|
25
25
|
"release-beta": "npm publish --tag beta"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@lionweb/core": "0.6.13-beta.
|
|
29
|
-
"@lionweb/
|
|
28
|
+
"@lionweb/core": "0.6.13-beta.5",
|
|
29
|
+
"@lionweb/json": "0.6.13-beta.5",
|
|
30
|
+
"@lionweb/ts-utils": "0.6.13-beta.5",
|
|
31
|
+
"@lionweb/utilities": "0.6.13-beta.5",
|
|
30
32
|
"@types/node": "20.17.30",
|
|
31
33
|
"littoral-templates": "0.3.0",
|
|
32
34
|
"typescript": "5.3.3"
|
|
@@ -21,7 +21,6 @@ import {
|
|
|
21
21
|
Enumeration,
|
|
22
22
|
Feature,
|
|
23
23
|
featureMetaType,
|
|
24
|
-
Id,
|
|
25
24
|
Interface,
|
|
26
25
|
isContainment,
|
|
27
26
|
isProperty,
|
|
@@ -34,9 +33,10 @@ import {
|
|
|
34
33
|
Reference,
|
|
35
34
|
SingleRef
|
|
36
35
|
} from "@lionweb/core"
|
|
37
|
-
import {
|
|
36
|
+
import { LionWebId } from "@lionweb/json"
|
|
37
|
+
import { commaSeparated, when, withNewlineAppended } from "littoral-templates"
|
|
38
38
|
|
|
39
|
-
import {indent, switchOrIf, withFirstUpper, wrapInIf} from "../utils/textgen.js"
|
|
39
|
+
import { indent, switchOrIf, withFirstUpper, wrapInIf } from "../utils/textgen.js"
|
|
40
40
|
import {
|
|
41
41
|
ConceptDescription,
|
|
42
42
|
Deprecated,
|
|
@@ -55,7 +55,6 @@ import {
|
|
|
55
55
|
tsTypeForValueManager
|
|
56
56
|
} from "./helpers/index.js"
|
|
57
57
|
|
|
58
|
-
|
|
59
58
|
const cardinalityPrefix = (feature: Feature) => {
|
|
60
59
|
if (feature instanceof Property) {
|
|
61
60
|
return feature.optional ? "Optional" : "Required"
|
|
@@ -68,7 +67,7 @@ const cardinalityPrefix = (feature: Feature) => {
|
|
|
68
67
|
const valueManagerFor = (feature: Feature) =>
|
|
69
68
|
`${cardinalityPrefix(feature)}${featureMetaType(feature)}ValueManager`
|
|
70
69
|
|
|
71
|
-
export const typeForLanguageEntity = (imports: Imports, mpsAnnotationsPerId: Record<
|
|
70
|
+
export const typeForLanguageEntity = (imports: Imports, mpsAnnotationsPerId: Record<LionWebId, MpsAnnotation[]>) => {
|
|
72
71
|
|
|
73
72
|
const sortedSuperTypesCond = <T extends Classifier>(ts: T[], prefix: string): string =>
|
|
74
73
|
ts.length === 0 ? `` : `${prefix}${nameSorted(ts).map((t) => imports.entity(t)).join(", ")}`
|
|
@@ -163,7 +162,7 @@ export const typeForLanguageEntity = (imports: Imports, mpsAnnotationsPerId: Rec
|
|
|
163
162
|
when(!isAbstract(classifier))(
|
|
164
163
|
() =>
|
|
165
164
|
[
|
|
166
|
-
`static create(id:
|
|
165
|
+
`static create(id: ${imports.json("LionWebId")}, handleDelta?: ${imports.generic("DeltaHandler")}, parentInfo?: ${imports.generic("Parentage")}): ${classifier.name} {`,
|
|
167
166
|
indent([
|
|
168
167
|
`return new ${classifier.name}(${imports.language(classifier.language)}.INSTANCE.${classifier.name}, id, handleDelta, parentInfo);`
|
|
169
168
|
]),
|
|
@@ -175,7 +174,7 @@ export const typeForLanguageEntity = (imports: Imports, mpsAnnotationsPerId: Rec
|
|
|
175
174
|
[
|
|
176
175
|
``,
|
|
177
176
|
features.map(withNewlineAppended(classMembersForFeature)),
|
|
178
|
-
`public constructor(classifier: ${imports.core("Classifier")}, id: ${imports.
|
|
177
|
+
`public constructor(classifier: ${imports.core("Classifier")}, id: ${imports.json("LionWebId")}, handleDelta?: ${imports.generic("DeltaHandler")}, parentInfo?: ${imports.generic("Parentage")}) {`,
|
|
179
178
|
indent([
|
|
180
179
|
`super(classifier, id, handleDelta, parentInfo);`,
|
|
181
180
|
features.map((feature) => `this._${feature.name} = new ${imports.generic(valueManagerFor(feature))}<${tsTypeForValueManager(feature, imports)}>(${imports.language(feature.classifier.language)}.INSTANCE.${feature.classifier.name}_${feature.name}, this);`)
|
package/src/api/generator.ts
CHANGED
|
@@ -15,16 +15,16 @@
|
|
|
15
15
|
// SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
|
|
16
16
|
// SPDX-License-Identifier: Apache-2.0
|
|
17
17
|
|
|
18
|
-
import {deserializeLanguages, Language, lioncore
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
|
|
24
|
-
import {
|
|
25
|
-
import {languageFileFor} from "./language-file.templates.js"
|
|
26
|
-
import {MpsAnnotation} from "./helpers/index.js"
|
|
18
|
+
import { deserializeLanguages, Language, lioncore } from "@lionweb/core"
|
|
19
|
+
import { LionWebJsonChunk } from "@lionweb/json"
|
|
20
|
+
import { readFileAsJson } from "@lionweb/utilities"
|
|
21
|
+
import { writeFileSync } from "fs"
|
|
22
|
+
import { join } from "path"
|
|
23
|
+
import { cwd } from "process"
|
|
24
|
+
import { MpsAnnotation } from "./helpers/index.js"
|
|
27
25
|
|
|
26
|
+
import { indexTsFor } from "./index-ts.js"
|
|
27
|
+
import { languageFileFor } from "./language-file.templates.js"
|
|
28
28
|
|
|
29
29
|
const properGenericImportLocation = "@lionweb/class-core"
|
|
30
30
|
|
|
@@ -56,7 +56,7 @@ export const generateApiFromLanguagesJson = (languagesJsonPath: string, generati
|
|
|
56
56
|
console.log(` Path to languages: ${languagesJsonPath}`)
|
|
57
57
|
console.log(` Generation path: ${generationPath}`)
|
|
58
58
|
|
|
59
|
-
const languagesJson = readFileAsJson(languagesJsonPath) as
|
|
59
|
+
const languagesJson = readFileAsJson(languagesJsonPath) as LionWebJsonChunk
|
|
60
60
|
const languages = deserializeLanguages(languagesJson, lioncore)
|
|
61
61
|
generateApiFromLanguages(languages, generationPath, options)
|
|
62
62
|
}
|
|
@@ -15,22 +15,10 @@
|
|
|
15
15
|
// SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
|
|
16
16
|
// SPDX-License-Identifier: Apache-2.0
|
|
17
17
|
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
allSuperTypesOf,
|
|
21
|
-
Annotation,
|
|
22
|
-
Classifier,
|
|
23
|
-
Concept,
|
|
24
|
-
Feature,
|
|
25
|
-
Interface,
|
|
26
|
-
MultiRef,
|
|
27
|
-
SingleRef
|
|
28
|
-
} from "@lionweb/core"
|
|
29
|
-
import {uniquesAmong} from "@lionweb/utilities/dist/utils/array.js"
|
|
18
|
+
import { allFeaturesOf, allSuperTypesOf, Annotation, Classifier, Concept, Feature, Interface, MultiRef, SingleRef } from "@lionweb/core"
|
|
19
|
+
import { uniquesAmong } from "@lionweb/ts-utils"
|
|
30
20
|
|
|
31
|
-
|
|
32
|
-
export const isAbstract = (classifier: Classifier): boolean =>
|
|
33
|
-
classifier instanceof Concept && classifier.abstract
|
|
21
|
+
export const isAbstract = (classifier: Classifier): boolean => classifier instanceof Concept && classifier.abstract
|
|
34
22
|
/*
|
|
35
23
|
* The logical inverse is: classifier instanceof Annotation || (classifier instanceof Concept && !classifier.abstract)
|
|
36
24
|
*/
|
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
// SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
|
|
16
16
|
// SPDX-License-Identifier: Apache-2.0
|
|
17
17
|
|
|
18
|
-
import {Classifier,
|
|
19
|
-
import {uniquesAmong} from "@lionweb/
|
|
20
|
-
import {asString, when} from "littoral-templates"
|
|
21
|
-
import {indent} from "../../utils/index.js"
|
|
18
|
+
import { Classifier, inheritsFrom, Language, nameOf, nameSorted } from "@lionweb/core"
|
|
19
|
+
import { cycleWith, uniquesAmong } from "@lionweb/ts-utils"
|
|
20
|
+
import { asString, when } from "littoral-templates"
|
|
21
|
+
import { indent } from "../../utils/index.js"
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
/**
|
|
@@ -15,15 +15,9 @@
|
|
|
15
15
|
// SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
|
|
16
16
|
// SPDX-License-Identifier: Apache-2.0
|
|
17
17
|
|
|
18
|
-
import {Annotation, Concept, Interface, LanguageEntity, PrimitiveType} from "@lionweb/core"
|
|
18
|
+
import { Annotation, Concept, Interface, LanguageEntity, PrimitiveType } from "@lionweb/core"
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
type EntityMetaType =
|
|
22
|
-
| "Annotation"
|
|
23
|
-
| "Concept"
|
|
24
|
-
| "Enumeration"
|
|
25
|
-
| "Interface"
|
|
26
|
-
| "PrimitiveType"
|
|
20
|
+
type EntityMetaType = "Annotation" | "Concept" | "Enumeration" | "Interface" | "PrimitiveType"
|
|
27
21
|
|
|
28
22
|
export const entityMetaType = (entity: LanguageEntity): EntityMetaType => {
|
|
29
23
|
if (entity instanceof Annotation) {
|
|
@@ -30,8 +30,7 @@ import {
|
|
|
30
30
|
Property,
|
|
31
31
|
SingleRef
|
|
32
32
|
} from "@lionweb/core"
|
|
33
|
-
import {Imports, tsTypeForPrimitiveType} from "./index.js"
|
|
34
|
-
|
|
33
|
+
import { Imports, tsTypeForPrimitiveType } from "./index.js"
|
|
35
34
|
|
|
36
35
|
export const typeOf = (feature: Feature): SingleRef<LanguageEntity> => {
|
|
37
36
|
if (feature instanceof Property) {
|
|
@@ -15,12 +15,10 @@
|
|
|
15
15
|
// SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
|
|
16
16
|
// SPDX-License-Identifier: Apache-2.0
|
|
17
17
|
|
|
18
|
-
import {Language, LanguageEntity, lioncoreBuiltins} from "@lionweb/core"
|
|
19
|
-
import {asJSIdentifier} from "../../utils/textgen.js"
|
|
18
|
+
import { Language, LanguageEntity, lioncoreBuiltins } from "@lionweb/core"
|
|
19
|
+
import { asJSIdentifier } from "../../utils/textgen.js"
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
export const importRenamingForLanguage = (language: Language) =>
|
|
23
|
-
asJSIdentifier(language.name)
|
|
21
|
+
export const importRenamingForLanguage = (language: Language) => asJSIdentifier(language.name)
|
|
24
22
|
|
|
25
23
|
export const nameOfBaseClassForLanguage = (language: Language) =>
|
|
26
24
|
asJSIdentifier(language.name) + "Base"
|
|
@@ -42,6 +40,15 @@ export class Imports {
|
|
|
42
40
|
return this.thisLanguageNameAsJsIdentifier + "Base"
|
|
43
41
|
}
|
|
44
42
|
|
|
43
|
+
private readonly _jsonImports = new Set<string>()
|
|
44
|
+
get jsonImports() {
|
|
45
|
+
return [...this._jsonImports]
|
|
46
|
+
}
|
|
47
|
+
json(identifier: string) {
|
|
48
|
+
this._jsonImports.add(identifier)
|
|
49
|
+
return identifier
|
|
50
|
+
}
|
|
51
|
+
|
|
45
52
|
private readonly _coreImports = new Set<string>()
|
|
46
53
|
get coreImports() {
|
|
47
54
|
return [...this._coreImports]
|
|
@@ -15,16 +15,14 @@
|
|
|
15
15
|
// SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
|
|
16
16
|
// SPDX-License-Identifier: Apache-2.0
|
|
17
17
|
|
|
18
|
-
import {
|
|
19
|
-
|
|
18
|
+
import { LionWebId, LionWebJsonChunk, LionWebKey } from "@lionweb/json"
|
|
20
19
|
|
|
21
20
|
export abstract class MpsAnnotation {
|
|
22
|
-
constructor(public readonly annotatedNodeId:
|
|
23
|
-
}
|
|
21
|
+
constructor(public readonly annotatedNodeId: LionWebId) {}
|
|
24
22
|
}
|
|
25
23
|
|
|
26
24
|
export class ConceptDescription extends MpsAnnotation {
|
|
27
|
-
constructor(annotatedNodeId:
|
|
25
|
+
constructor(annotatedNodeId: LionWebId, public readonly shortDescription: string | null, public readonly alias: string | null) {
|
|
28
26
|
super(annotatedNodeId)
|
|
29
27
|
}
|
|
30
28
|
toString() {
|
|
@@ -33,7 +31,7 @@ export class ConceptDescription extends MpsAnnotation {
|
|
|
33
31
|
}
|
|
34
32
|
|
|
35
33
|
export class Deprecated extends MpsAnnotation {
|
|
36
|
-
constructor(annotatedNodeId:
|
|
34
|
+
constructor(annotatedNodeId: LionWebId, public readonly comment: string | null, public readonly build: string | null) {
|
|
37
35
|
super(annotatedNodeId)
|
|
38
36
|
}
|
|
39
37
|
toString() {
|
|
@@ -42,9 +40,9 @@ export class Deprecated extends MpsAnnotation {
|
|
|
42
40
|
}
|
|
43
41
|
|
|
44
42
|
|
|
45
|
-
export const extractedMpsAnnotations = ({nodes}:
|
|
43
|
+
export const extractedMpsAnnotations = ({nodes}: LionWebJsonChunk): MpsAnnotation[] =>
|
|
46
44
|
nodes.flatMap<MpsAnnotation>(({classifier, properties, parent}) => {
|
|
47
|
-
const propertyValue = (key:
|
|
45
|
+
const propertyValue = (key: LionWebKey): string | null => {
|
|
48
46
|
const property = properties.find(({property}) => property.key === key)
|
|
49
47
|
return property === undefined
|
|
50
48
|
? null
|
package/src/api/helpers/types.ts
CHANGED
|
@@ -15,15 +15,18 @@
|
|
|
15
15
|
// SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
|
|
16
16
|
// SPDX-License-Identifier: Apache-2.0
|
|
17
17
|
|
|
18
|
-
import {builtinPrimitives, PrimitiveType} from "@lionweb/core"
|
|
19
|
-
|
|
18
|
+
import { builtinPrimitives, PrimitiveType } from "@lionweb/core"
|
|
20
19
|
|
|
21
20
|
export const tsTypeForPrimitiveType = (primitiveType: PrimitiveType): string => {
|
|
22
21
|
switch (primitiveType) {
|
|
23
|
-
case builtinPrimitives.booleanDatatype:
|
|
24
|
-
|
|
25
|
-
case builtinPrimitives.
|
|
26
|
-
|
|
22
|
+
case builtinPrimitives.booleanDatatype:
|
|
23
|
+
return `boolean`
|
|
24
|
+
case builtinPrimitives.stringDatatype:
|
|
25
|
+
return `string`
|
|
26
|
+
case builtinPrimitives.integerDatatype:
|
|
27
|
+
return `number`
|
|
28
|
+
case builtinPrimitives.jsonDatatype:
|
|
29
|
+
return `unknown`
|
|
27
30
|
default:
|
|
28
31
|
return `string`
|
|
29
32
|
}
|
package/src/api/index-ts.ts
CHANGED
|
@@ -15,39 +15,49 @@
|
|
|
15
15
|
// SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
|
|
16
16
|
// SPDX-License-Identifier: Apache-2.0
|
|
17
17
|
|
|
18
|
-
import {Language} from "@lionweb/core"
|
|
19
|
-
import {asString, commaSeparated} from "littoral-templates"
|
|
20
|
-
|
|
21
|
-
import {indent} from "../utils/textgen.js"
|
|
22
|
-
import {dependencyOrderOf} from "../utils/toposort.js"
|
|
23
|
-
import {dependenciesThroughDirectInheritanceOf, importRenamingForLanguage, nameOfBaseClassForLanguage} from "./helpers/index.js"
|
|
24
|
-
import {GeneratorOptions} from "./generator.js"
|
|
18
|
+
import { Language } from "@lionweb/core"
|
|
19
|
+
import { asString, commaSeparated } from "littoral-templates"
|
|
25
20
|
|
|
21
|
+
import { indent } from "../utils/textgen.js"
|
|
22
|
+
import { dependencyOrderOf } from "../utils/toposort.js"
|
|
23
|
+
import { GeneratorOptions } from "./generator.js"
|
|
24
|
+
import { dependenciesThroughDirectInheritanceOf, importRenamingForLanguage, nameOfBaseClassForLanguage } from "./helpers/index.js"
|
|
26
25
|
|
|
27
26
|
export const indexTsFor = (languages: Language[], options: GeneratorOptions) => {
|
|
28
27
|
const dependenciesInOrderOfDirectInheritance = dependencyOrderOf(languages, dependenciesThroughDirectInheritanceOf)
|
|
29
28
|
if (dependenciesInOrderOfDirectInheritance === false) {
|
|
30
|
-
console.error(
|
|
29
|
+
console.error(
|
|
30
|
+
`⚠ CYCLE detected! Proceeding with order of languages as-is, instead of in type-wise (through direct inheritance) dependency order ⇒ generated code might not initialize!`
|
|
31
|
+
)
|
|
31
32
|
}
|
|
32
|
-
const languagesForImports =
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
const languagesForImports =
|
|
34
|
+
dependenciesInOrderOfDirectInheritance === false
|
|
35
|
+
? languages
|
|
36
|
+
: dependenciesInOrderOfDirectInheritance.filter(language => languages.indexOf(language) > -1)
|
|
36
37
|
|
|
37
38
|
return asString([
|
|
38
39
|
options.header === undefined ? [] : [options.header, ``],
|
|
39
40
|
`import {ILanguageBase, LionCore_builtinsBase} from "${options.genericImportLocation}";`,
|
|
40
41
|
``,
|
|
41
|
-
languagesForImports.map(
|
|
42
|
+
languagesForImports.map(language => `import * as ${importRenamingForLanguage(language)} from "./${language.name}.g.js";`),
|
|
42
43
|
``,
|
|
43
44
|
`// ensure that all languages get wired up by triggering that through their first entity:`,
|
|
44
45
|
`LionCore_builtinsBase.INSTANCE.String;`,
|
|
45
46
|
languages
|
|
46
|
-
.filter(({entities}) => entities.length > 0)
|
|
47
|
-
.map(
|
|
47
|
+
.filter(({ entities }) => entities.length > 0)
|
|
48
|
+
.map(
|
|
49
|
+
language =>
|
|
50
|
+
`${importRenamingForLanguage(language)}.${nameOfBaseClassForLanguage(language)}.INSTANCE.${language.entities[0].name};`
|
|
51
|
+
),
|
|
48
52
|
``,
|
|
49
53
|
`export const allLanguageBases: ILanguageBase[] = [`,
|
|
50
|
-
indent(
|
|
54
|
+
indent(
|
|
55
|
+
commaSeparated(
|
|
56
|
+
languagesForImports.map(
|
|
57
|
+
language => `${importRenamingForLanguage(language)}.${nameOfBaseClassForLanguage(language)}.INSTANCE`
|
|
58
|
+
)
|
|
59
|
+
)
|
|
60
|
+
),
|
|
51
61
|
`];`,
|
|
52
62
|
``,
|
|
53
63
|
`export {`,
|
|
@@ -15,25 +15,20 @@
|
|
|
15
15
|
// SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
|
|
16
16
|
// SPDX-License-Identifier: Apache-2.0
|
|
17
17
|
|
|
18
|
-
import {Concept,
|
|
19
|
-
import {
|
|
20
|
-
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {sortedStringsByUppercase} from "../utils/string-sorting.js"
|
|
25
|
-
import {dependencyOrderOf} from "../utils/toposort.js"
|
|
26
|
-
import {Imports} from "./helpers/index.js"
|
|
27
|
-
import {GeneratorOptions} from "./generator.js"
|
|
18
|
+
import { Concept, Language } from "@lionweb/core"
|
|
19
|
+
import { groupBy } from "@lionweb/ts-utils"
|
|
20
|
+
import { asString, commaSeparated, when, withNewlineAppended } from "littoral-templates"
|
|
21
|
+
import { sortedStringsByUppercase } from "../utils/string-sorting.js"
|
|
22
|
+
import { indent } from "../utils/textgen.js"
|
|
23
|
+
import { dependencyOrderOf } from "../utils/toposort.js"
|
|
28
24
|
|
|
25
|
+
import { typeForLanguageEntity } from "./entity-types.templates.js"
|
|
26
|
+
import { GeneratorOptions } from "./generator.js"
|
|
27
|
+
import { Imports } from "./helpers/index.js"
|
|
28
|
+
import { reflectiveClassFor } from "./reflective-layer.templates.js"
|
|
29
29
|
|
|
30
30
|
const importStatement = (dep: string, items: string[]) =>
|
|
31
|
-
when(items.length > 0)([
|
|
32
|
-
`import {`,
|
|
33
|
-
indent(commaSeparated(sortedStringsByUppercase(items))),
|
|
34
|
-
`} from "${dep}";`,
|
|
35
|
-
``
|
|
36
|
-
])
|
|
31
|
+
when(items.length > 0)([`import {`, indent(commaSeparated(sortedStringsByUppercase(items))), `} from "${dep}";`, ``])
|
|
37
32
|
|
|
38
33
|
|
|
39
34
|
export const languageFileFor = (language: Language, options: GeneratorOptions) => {
|
|
@@ -71,6 +66,7 @@ export const languageFileFor = (language: Language, options: GeneratorOptions) =
|
|
|
71
66
|
``,
|
|
72
67
|
``,
|
|
73
68
|
importStatement(`@lionweb/core`, imports.coreImports),
|
|
69
|
+
importStatement(`@lionweb/json`, imports.jsonImports),
|
|
74
70
|
importStatement(options.genericImportLocation, imports.genericImports),
|
|
75
71
|
importStatement(`./index.g.js`, imports.languageImports),
|
|
76
72
|
postImportsPart
|