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