@lionweb/class-core-generator 0.7.0-alpha.1 → 0.7.0-alpha.11
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/CHANGELOG.md +7 -0
- package/dist/entity-types.templates.d.ts +4 -0
- package/dist/entity-types.templates.d.ts.map +1 -0
- package/dist/{api/entity-types.templates.js → entity-types.templates.js} +59 -26
- package/dist/entity-types.templates.js.map +1 -0
- package/dist/{api/generation-headers.d.ts → generation-headers.d.ts} +1 -1
- package/dist/generation-headers.d.ts.map +1 -0
- package/dist/{api/generation-headers.js → generation-headers.js} +19 -13
- package/dist/generation-headers.js.map +1 -0
- package/dist/{api/generator.d.ts → generator.d.ts} +3 -4
- package/dist/generator.d.ts.map +1 -0
- package/dist/{api/generator.js → generator.js} +19 -14
- package/dist/generator.js.map +1 -0
- package/dist/helpers/classifiers.d.ts.map +1 -0
- package/dist/helpers/classifiers.js.map +1 -0
- package/dist/helpers/entities.d.ts.map +1 -0
- package/dist/helpers/entities.js.map +1 -0
- package/dist/{api/helpers → helpers}/features.d.ts +3 -3
- package/dist/helpers/features.d.ts.map +1 -0
- package/dist/{api/helpers → helpers}/features.js +8 -8
- package/dist/helpers/features.js.map +1 -0
- package/dist/helpers/imports-tracking.d.ts.map +1 -0
- package/dist/{api/helpers → helpers}/imports-tracking.js +1 -1
- package/dist/helpers/imports-tracking.js.map +1 -0
- package/dist/{api/helpers → helpers}/index.d.ts +0 -2
- package/dist/helpers/index.d.ts.map +1 -0
- package/dist/{api/helpers → helpers}/index.js +0 -2
- package/dist/helpers/index.js.map +1 -0
- package/dist/helpers/primitive-types.d.ts.map +1 -0
- package/dist/{api/helpers → helpers}/primitive-types.js +4 -4
- package/dist/helpers/primitive-types.js.map +1 -0
- package/dist/index-ts.d.ts.map +1 -0
- package/dist/{api/index-ts.js → index-ts.js} +3 -2
- package/dist/index-ts.js.map +1 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/language-file.templates.d.ts.map +1 -0
- package/dist/{api/language-file.templates.js → language-file.templates.js} +3 -5
- package/dist/language-file.templates.js.map +1 -0
- package/dist/mega-factory.templates.d.ts +3 -0
- package/dist/mega-factory.templates.d.ts.map +1 -0
- package/dist/{api/mega-factory.templates.js → mega-factory.templates.js} +4 -4
- package/dist/mega-factory.templates.js.map +1 -0
- package/dist/reflective-layer.templates.d.ts.map +1 -0
- package/dist/{api/reflective-layer.templates.js → reflective-layer.templates.js} +9 -5
- package/dist/reflective-layer.templates.js.map +1 -0
- package/package.json +10 -9
- package/src/{api/entity-types.templates.ts → entity-types.templates.ts} +83 -33
- package/src/{api/generation-headers.ts → generation-headers.ts} +19 -15
- package/src/{api/generator.ts → generator.ts} +23 -16
- package/src/{api/helpers → helpers}/features.ts +9 -9
- package/src/{api/helpers → helpers}/imports-tracking.ts +1 -1
- package/src/{api/helpers → helpers}/index.ts +0 -2
- package/src/{api/helpers → helpers}/primitive-types.ts +4 -4
- package/src/{api/index-ts.ts → index-ts.ts} +4 -3
- package/src/index.ts +3 -2
- package/src/{api/language-file.templates.ts → language-file.templates.ts} +3 -6
- package/src/{api/mega-factory.templates.ts → mega-factory.templates.ts} +4 -5
- package/src/{api/reflective-layer.templates.ts → reflective-layer.templates.ts} +9 -4
- package/dist/api/entity-types.templates.d.ts +0 -5
- package/dist/api/entity-types.templates.d.ts.map +0 -1
- package/dist/api/entity-types.templates.js.map +0 -1
- package/dist/api/generation-headers.d.ts.map +0 -1
- package/dist/api/generation-headers.js.map +0 -1
- package/dist/api/generator.d.ts.map +0 -1
- package/dist/api/generator.js.map +0 -1
- package/dist/api/helpers/classifiers.d.ts.map +0 -1
- package/dist/api/helpers/classifiers.js.map +0 -1
- package/dist/api/helpers/dependencies.d.ts +0 -11
- package/dist/api/helpers/dependencies.d.ts.map +0 -1
- package/dist/api/helpers/dependencies.js +0 -52
- package/dist/api/helpers/dependencies.js.map +0 -1
- package/dist/api/helpers/entities.d.ts.map +0 -1
- package/dist/api/helpers/entities.js.map +0 -1
- package/dist/api/helpers/features.d.ts.map +0 -1
- package/dist/api/helpers/features.js.map +0 -1
- package/dist/api/helpers/imports-tracking.d.ts.map +0 -1
- package/dist/api/helpers/imports-tracking.js.map +0 -1
- package/dist/api/helpers/index.d.ts.map +0 -1
- package/dist/api/helpers/index.js.map +0 -1
- package/dist/api/helpers/mps-annotations.d.ts +0 -19
- package/dist/api/helpers/mps-annotations.d.ts.map +0 -1
- package/dist/api/helpers/mps-annotations.js +0 -65
- package/dist/api/helpers/mps-annotations.js.map +0 -1
- package/dist/api/helpers/primitive-types.d.ts.map +0 -1
- package/dist/api/helpers/primitive-types.js.map +0 -1
- package/dist/api/index-ts.d.ts.map +0 -1
- package/dist/api/index-ts.js.map +0 -1
- package/dist/api/index.d.ts +0 -5
- package/dist/api/index.d.ts.map +0 -1
- package/dist/api/index.js +0 -21
- package/dist/api/index.js.map +0 -1
- package/dist/api/language-file.templates.d.ts.map +0 -1
- package/dist/api/language-file.templates.js.map +0 -1
- package/dist/api/mega-factory.templates.d.ts +0 -4
- package/dist/api/mega-factory.templates.d.ts.map +0 -1
- package/dist/api/mega-factory.templates.js.map +0 -1
- package/dist/api/reflective-layer.templates.d.ts.map +0 -1
- package/dist/api/reflective-layer.templates.js.map +0 -1
- package/dist/utils/index.d.ts +0 -3
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -19
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/json-as-ts.d.ts +0 -2
- package/dist/utils/json-as-ts.d.ts.map +0 -1
- package/dist/utils/json-as-ts.js +0 -18
- package/dist/utils/json-as-ts.js.map +0 -1
- package/dist/utils/textgen.d.ts +0 -21
- package/dist/utils/textgen.d.ts.map +0 -1
- package/dist/utils/textgen.js +0 -67
- package/dist/utils/textgen.js.map +0 -1
- package/src/api/helpers/dependencies.ts +0 -62
- package/src/api/helpers/mps-annotations.ts +0 -67
- package/src/api/index.ts +0 -21
- package/src/utils/index.ts +0 -20
- package/src/utils/json-as-ts.ts +0 -20
- package/src/utils/textgen.ts +0 -89
- /package/dist/{api/helpers → helpers}/classifiers.d.ts +0 -0
- /package/dist/{api/helpers → helpers}/classifiers.js +0 -0
- /package/dist/{api/helpers → helpers}/entities.d.ts +0 -0
- /package/dist/{api/helpers → helpers}/entities.js +0 -0
- /package/dist/{api/helpers → helpers}/imports-tracking.d.ts +0 -0
- /package/dist/{api/helpers → helpers}/primitive-types.d.ts +0 -0
- /package/dist/{api/index-ts.d.ts → index-ts.d.ts} +0 -0
- /package/dist/{api/language-file.templates.d.ts → language-file.templates.d.ts} +0 -0
- /package/dist/{api/reflective-layer.templates.d.ts → reflective-layer.templates.d.ts} +0 -0
- /package/src/{api/helpers → helpers}/classifiers.ts +0 -0
- /package/src/{api/helpers → helpers}/entities.ts +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"language-file.templates.js","sourceRoot":"","sources":["../src/language-file.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,EAAE,OAAO,EAAY,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAC/C,OAAO,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAA;AAC/E,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,IAAI,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAExF,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAA;AAEnE,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CA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EAAE,MAAM,IAAI,EAAE;QACrB;;kBAEU,IAAI;kBACJ,OAAO;kBACP,GAAG;kBACH,EAAE;IAChB;QACI,EAAE;QACF,EAAE;QACF,eAAe,CAAC,eAAe,EAAE,OAAO,CAAC,WAAW,CAAC;QACrD,eAAe,CAAC,eAAe,EAAE,OAAO,CAAC,WAAW,CAAC;QACrD,eAAe,CAAC,OAAO,CAAC,qBAAqB,EAAE,OAAO,CAAC,cAAc,CAAC;QACtE,eAAe,CAAC,cAAc,EAAE,OAAO,CAAC,eAAe,CAAC;QACxD,eAAe;KAClB,CAAC,CAAA;AACN,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mega-factory.templates.d.ts","sourceRoot":"","sources":["../src/mega-factory.templates.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAc,QAAQ,EAAkB,MAAM,eAAe,CAAA;AAKpE,eAAO,MAAM,cAAc,oBAAqB,MAAM,aAAa,QAAQ,EAAE,WAAW,MAAM,WAgD7F,CAAA"}
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
// SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
|
|
16
16
|
// SPDX-License-Identifier: Apache-2.0
|
|
17
17
|
import { isConcrete } from "@lionweb/core";
|
|
18
|
+
import { Deprecated, ioLionWebMpsSpecificAnnotationsFrom } from "@lionweb/io-lionweb-mps-specific";
|
|
19
|
+
import { asJSIdentifier, indent } from "@lionweb/textgen-utils";
|
|
18
20
|
import { asString, commaSeparated } from "littoral-templates";
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
export const megaFactoryFor = (megaFactoryName, languages, mpsAnnotations = [], header) => {
|
|
22
|
-
const isNotDeprecated = (entity) => !mpsAnnotations.some(mpsAnnotation => mpsAnnotation.annotatedNodeId === entity.id && mpsAnnotation instanceof Deprecated);
|
|
21
|
+
export const megaFactoryFor = (megaFactoryName, languages, header) => {
|
|
22
|
+
const isNotDeprecated = (entity) => !ioLionWebMpsSpecificAnnotationsFrom(entity).some((annotation) => annotation instanceof Deprecated);
|
|
23
23
|
const requiresFactoryMethod = (entity) => isConcrete(entity) && isNotDeprecated(entity);
|
|
24
24
|
const factoryFor = (language) => [
|
|
25
25
|
`${asJSIdentifier(language.name)}Factory = {`,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mega-factory.templates.js","sourceRoot":"","sources":["../src/mega-factory.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,EAAE,UAAU,EAA4B,MAAM,eAAe,CAAA;AACpE,OAAO,EAAE,UAAU,EAAE,mCAAmC,EAAE,MAAM,kCAAkC,CAAA;AAClG,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAE7D,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,eAAuB,EAAE,SAAqB,EAAE,MAAe,EAAE,EAAE;IAC9F,MAAM,eAAe,GAAG,CAAC,MAAsB,EAAE,EAAE,CAC/C,CAAC,mCAAmC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,YAAY,UAAU,CAAC,CAAA;IAEvG,MAAM,qBAAqB,GAAG,CAAC,MAAsB,EAAE,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,eAAe,CAAC,MAAM,CAAC,CAAA;IAEvG,MAAM,UAAU,GAAG,CAAC,QAAkB,EAAE,EAAE,CAAC;QACvC,GAAG,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,aA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QAAQ,0BAyE7B,CAAA"}
|
|
@@ -14,10 +14,10 @@
|
|
|
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";
|
|
17
|
+
import { Annotation, Classifier, Concept, Enumeration, featureMetaType, Interface, isConcrete, isEnumeration, isMultiple, isPartition, Link, nameOf, PrimitiveType, Property } from "@lionweb/core";
|
|
18
|
+
import { indent, switchOrIf } from "@lionweb/textgen-utils";
|
|
18
19
|
import { asArray } from "@lionweb/ts-utils";
|
|
19
20
|
import { when, withNewlineAppended } from "littoral-templates";
|
|
20
|
-
import { indent, switchOrIf } from "../utils/textgen.js";
|
|
21
21
|
import { entityMetaType, extendsFrom, nameOfBaseClassForLanguage } from "./helpers/index.js";
|
|
22
22
|
export const reflectiveClassFor = (imports) => {
|
|
23
23
|
// classifier:
|
|
@@ -37,7 +37,7 @@ export const reflectiveClassFor = (imports) => {
|
|
|
37
37
|
const { name, key, id, features } = classifier;
|
|
38
38
|
const metaType = entityMetaType(classifier);
|
|
39
39
|
return [
|
|
40
|
-
`public readonly _${name} = new ${imports.core(metaType)}(this._language, "${name}", "${key}", "${id}"${classifier instanceof Concept ? ", " + classifier.abstract : ""});`,
|
|
40
|
+
`public readonly _${name} = new ${imports.core(metaType)}(this._language, "${name}", "${key}", "${id}"${classifier instanceof Concept ? ", " + classifier.abstract : ""})${isPartition(classifier) ? ".isPartition()" : ""};`,
|
|
41
41
|
// | core (2nd x) |
|
|
42
42
|
`get ${name}(): ${metaType} {`,
|
|
43
43
|
indent([`this.ensureWiredUp();`, `return this._${name};`]),
|
|
@@ -167,8 +167,12 @@ export const reflectiveClassFor = (imports) => {
|
|
|
167
167
|
indent([
|
|
168
168
|
`return (classifier: ${imports.core("Classifier")}, ${parameterPrefix}id: ${imports.json("LionWebId")}) => {`,
|
|
169
169
|
indent(switchOrIf("classifier.key", concreteClassifiers
|
|
170
|
-
.map(
|
|
171
|
-
|
|
170
|
+
.map((classifier) => [
|
|
171
|
+
// case's key:
|
|
172
|
+
`this._${classifier.name}.key`,
|
|
173
|
+
// return value:
|
|
174
|
+
`${classifier.name}.create(id, ${parameterPrefix}handleDelta)`
|
|
175
|
+
]), [
|
|
172
176
|
`const {language} = classifier;`,
|
|
173
177
|
`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
178
|
])),
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reflective-layer.templates.js","sourceRoot":"","sources":["../src/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,EACV,WAAW,EAGX,IAAI,EACJ,MAAM,EACN,aAAa,EACb,QAAQ,EAEX,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAC3C,OAAO,EAAE,IAAI,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAE9D,OAAO,EAAE,cAAc,EAAE,WAAW,EAAW,0BAA0B,EAAE,MAAM,oBAAoB,CAAA;AAErG,MAAM,CAAC,MAAM,kBAAkB,GA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EAAE;gBACF,WAAW,eAAe,iBAAiB,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,iBAAiB,CAAC,IAAI;gBACtH,MAAM,CAAC;oBACH,uBAAuB,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,eAAe,OAAO,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ;oBAC7G,MAAM,CACF,UAAU,CACN,gBAAgB,EAChB,mBAAmB;yBACd,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC;wBACjB,cAAc;wBACd,SAAS,UAAU,CAAC,IAAI,MAAM;wBAC9B,gBAAgB;wBAChB,GAAG,UAAU,CAAC,IAAI,eAAe,eAAe,cAAc;qBACjE,CAAC,EACN;wBACI,gCAAgC;wBAChC,kMAAkM;qBACrM,CACJ,CACJ;oBACD,GAAG;iBACN,CAAC;gBACF,GAAG;gBACH,EAAE;gBACF,iDAAiD,OAAO,CAAC,IAAI,CAAC,oBAAoB,CAAC,eAAe;gBAClG,sEAAsE;gBACtE,MAAM,CAAC;oBACH,2CAA2C;oBAC3C,UAAU,CACN,iBAAiB,EACjB,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,SAAS,IAAI,MAAM,EAAE,oCAAoC,CAAC,CAAC,EACjG;wBACI,iCAAiC;wBACjC,gKAAgK;qBACnK,CACJ;iBACJ,CAAC;gBACF,GAAG;gBACH,EAAE;gBACF,yCAAyC,0BAA0B,CAAC,QAAQ,CAAC,KAAK;aACrF,CAAC;YACF,GAAG;SACN,CAAA;IACL,CAAC,CAAA;AACL,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lionweb/class-core-generator",
|
|
3
|
-
"version": "0.7.0-alpha.
|
|
3
|
+
"version": "0.7.0-alpha.11",
|
|
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",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"url": "https://github.com/LionWeb-io/lionweb-typescript/issues"
|
|
16
16
|
},
|
|
17
17
|
"scripts": {
|
|
18
|
-
"clean": "
|
|
18
|
+
"clean": "npx rimraf dist node_modules -g lionweb-class-core-generator-*.tgz",
|
|
19
19
|
"build": "tsc",
|
|
20
20
|
"lint": "eslint src",
|
|
21
21
|
"prep:pre-release": "npm run clean && npm install && npm run build",
|
|
@@ -27,12 +27,13 @@
|
|
|
27
27
|
"release": "npm publish"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@lionweb/core": "0.7.0-alpha.
|
|
31
|
-
"@lionweb/
|
|
32
|
-
"@lionweb/
|
|
33
|
-
"@lionweb/
|
|
34
|
-
"@
|
|
35
|
-
"
|
|
36
|
-
"
|
|
30
|
+
"@lionweb/core": "0.7.0-alpha.11",
|
|
31
|
+
"@lionweb/io-lionweb-mps-specific": "0.7.0-alpha.11",
|
|
32
|
+
"@lionweb/json": "0.7.0-alpha.11",
|
|
33
|
+
"@lionweb/textgen-utils": "0.7.0-alpha.11",
|
|
34
|
+
"@lionweb/ts-utils": "0.7.0-alpha.11",
|
|
35
|
+
"@lionweb/utilities": "0.7.0-alpha.11",
|
|
36
|
+
"@types/node": "24.3.0",
|
|
37
|
+
"littoral-templates": "0.5.0"
|
|
37
38
|
}
|
|
38
39
|
}
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
import {
|
|
19
19
|
builtinClassifiers,
|
|
20
20
|
Classifier,
|
|
21
|
+
Containment,
|
|
21
22
|
Enumeration,
|
|
22
23
|
Feature,
|
|
23
24
|
featureMetaType,
|
|
@@ -27,30 +28,36 @@ import {
|
|
|
27
28
|
isReference,
|
|
28
29
|
LanguageEntity,
|
|
29
30
|
Link,
|
|
31
|
+
M3Concept,
|
|
30
32
|
nameSorted,
|
|
33
|
+
Node,
|
|
31
34
|
PrimitiveType,
|
|
32
35
|
Property,
|
|
33
36
|
Reference,
|
|
34
37
|
SingleRef
|
|
35
38
|
} from "@lionweb/core"
|
|
36
|
-
import { LionWebId } from "@lionweb/json"
|
|
37
|
-
import { commaSeparated, when, withNewlineAppended } from "littoral-templates"
|
|
38
|
-
|
|
39
|
-
import { indent, switchOrIf, withFirstUpper, wrapInIf } from "../utils/textgen.js"
|
|
40
39
|
import {
|
|
41
40
|
ConceptDescription,
|
|
42
41
|
Deprecated,
|
|
42
|
+
ioLionWebMpsSpecificAnnotationsFrom,
|
|
43
|
+
KeyedDescription,
|
|
44
|
+
ShortDescription,
|
|
45
|
+
VirtualPackage
|
|
46
|
+
} from "@lionweb/io-lionweb-mps-specific"
|
|
47
|
+
import { indent, switchOrIf, withFirstUpper, wrapInIf } from "@lionweb/textgen-utils"
|
|
48
|
+
import { commaSeparated, when, withNewlineAppended } from "littoral-templates"
|
|
49
|
+
|
|
50
|
+
import {
|
|
43
51
|
entityMetaType,
|
|
44
52
|
extendsFrom,
|
|
45
53
|
featuresToConcretelyImplementOf,
|
|
46
54
|
implementsFrom,
|
|
47
55
|
Imports,
|
|
48
56
|
isAbstract,
|
|
49
|
-
MpsAnnotation,
|
|
50
57
|
optionalityPostfix,
|
|
51
58
|
tsFieldTypeForFeature,
|
|
52
59
|
tsTypeForClassifier,
|
|
53
|
-
|
|
60
|
+
tsTypeForDataType,
|
|
54
61
|
tsTypeForPrimitiveType,
|
|
55
62
|
tsTypeForValueManager
|
|
56
63
|
} from "./helpers/index.js"
|
|
@@ -67,7 +74,7 @@ const cardinalityPrefix = (feature: Feature) => {
|
|
|
67
74
|
const valueManagerFor = (feature: Feature) =>
|
|
68
75
|
`${cardinalityPrefix(feature)}${featureMetaType(feature)}ValueManager`
|
|
69
76
|
|
|
70
|
-
export const typeForLanguageEntity = (imports: Imports
|
|
77
|
+
export const typeForLanguageEntity = (imports: Imports) => {
|
|
71
78
|
|
|
72
79
|
const sortedSuperTypesCond = <T extends Classifier>(ts: T[], prefix: string): string =>
|
|
73
80
|
ts.length === 0 ? `` : `${prefix}${nameSorted(ts).map((t) => imports.entity(t)).join(", ")}`
|
|
@@ -78,45 +85,60 @@ export const typeForLanguageEntity = (imports: Imports, mpsAnnotationsPerId: Rec
|
|
|
78
85
|
const classMembersForProperty = (property: Property) => {
|
|
79
86
|
const {name, type} = property
|
|
80
87
|
return [
|
|
81
|
-
`private readonly _${name}: ${imports.generic(valueManagerFor(property))}<${
|
|
82
|
-
|
|
88
|
+
`private readonly _${name}: ${imports.generic(valueManagerFor(property))}<${tsTypeForDataType(type, imports)}>;`,
|
|
89
|
+
jsDocFor(property),
|
|
90
|
+
`get ${name}(): ${tsTypeForDataType(type, imports)}${optionalityPostfix(property)} {`,
|
|
83
91
|
indent(`return this._${name}.get();`),
|
|
84
92
|
`}`,
|
|
85
|
-
`set ${name}(newValue: ${
|
|
93
|
+
`set ${name}(newValue: ${tsTypeForDataType(type, imports)}${optionalityPostfix(property)}) {`,
|
|
86
94
|
indent(`this._${name}.set(newValue);`),
|
|
87
95
|
`}`
|
|
88
96
|
]
|
|
89
97
|
}
|
|
90
98
|
|
|
91
|
-
const tsTypeForLink = (link: Link) =>
|
|
92
|
-
wrapInIf(link instanceof Reference, () => `${imports.core("SingleRef")}<`, ">")(tsTypeForClassifier(link.type, imports))
|
|
93
|
-
+ (link.multiple ? "[]" : optionalityPostfix(link))
|
|
94
|
-
|
|
95
99
|
const classMembersForLink = (link: Link) => {
|
|
96
100
|
const {name, type, multiple} = link
|
|
101
|
+
const nameWithFirstUpper = withFirstUpper(name)
|
|
102
|
+
const tsTypeForClassifier_ = tsTypeForClassifier(type, imports)
|
|
103
|
+
const tsTypeForLink_ = wrapInIf(
|
|
104
|
+
link instanceof Reference,
|
|
105
|
+
() => `${imports.core("SingleRef")}<`, ">")(tsTypeForClassifier_)
|
|
106
|
+
+ (link.multiple ? "[]" : optionalityPostfix(link)
|
|
107
|
+
)
|
|
97
108
|
return [
|
|
98
|
-
`private readonly _${name}: ${imports.generic(valueManagerFor(link))}<${
|
|
99
|
-
|
|
109
|
+
`private readonly _${name}: ${imports.generic(valueManagerFor(link))}<${tsTypeForClassifier_}>;`,
|
|
110
|
+
jsDocFor(link),
|
|
111
|
+
`get ${name}(): ${tsTypeForLink_} {`,
|
|
100
112
|
indent(`return this._${name}.get();`),
|
|
101
113
|
`}`,
|
|
102
114
|
when(!multiple)([
|
|
103
|
-
`set ${name}(newValue: ${
|
|
115
|
+
`set ${name}(newValue: ${tsTypeForLink_}) {`,
|
|
104
116
|
indent(`this._${name}.set(newValue);`),
|
|
105
|
-
`}
|
|
117
|
+
`}`,
|
|
118
|
+
when(link instanceof Containment)([
|
|
119
|
+
`replace${nameWithFirstUpper}With(newValue: ${tsTypeForClassifier_}) {`,
|
|
120
|
+
indent(`this._${name}.replaceWith(newValue);`),
|
|
121
|
+
`}`
|
|
122
|
+
])
|
|
106
123
|
]),
|
|
107
124
|
when(multiple)([
|
|
108
|
-
`add${
|
|
125
|
+
`add${nameWithFirstUpper}(newValue: ${tsTypeForClassifier_}) {`,
|
|
109
126
|
indent(`this._${name}.add(newValue);`),
|
|
110
127
|
`}`,
|
|
111
|
-
`remove${
|
|
128
|
+
`remove${nameWithFirstUpper}(valueToRemove: ${tsTypeForClassifier_}) {`,
|
|
112
129
|
indent(`this._${name}.remove(valueToRemove);`),
|
|
113
130
|
`}`,
|
|
114
|
-
`add${
|
|
131
|
+
`add${nameWithFirstUpper}AtIndex(newValue: ${tsTypeForClassifier_}, index: number) {`,
|
|
115
132
|
indent(`this._${name}.insertAtIndex(newValue, index);`),
|
|
116
133
|
`}`,
|
|
117
|
-
`move${
|
|
134
|
+
`move${nameWithFirstUpper}(oldIndex: number, newIndex: number) {`,
|
|
118
135
|
indent(`this._${name}.move(oldIndex, newIndex);`),
|
|
119
|
-
`}
|
|
136
|
+
`}`,
|
|
137
|
+
when(link instanceof Containment)([
|
|
138
|
+
`replace${nameWithFirstUpper}AtIndex(movedChild: ${tsTypeForClassifier_}, newIndex: number) {`,
|
|
139
|
+
indent(`this._${name}.replaceAtIndex(movedChild, newIndex);`),
|
|
140
|
+
`}`
|
|
141
|
+
])
|
|
120
142
|
])
|
|
121
143
|
]
|
|
122
144
|
}
|
|
@@ -174,7 +196,7 @@ export const typeForLanguageEntity = (imports: Imports, mpsAnnotationsPerId: Rec
|
|
|
174
196
|
[
|
|
175
197
|
``,
|
|
176
198
|
features.map(withNewlineAppended(classMembersForFeature)),
|
|
177
|
-
|
|
199
|
+
`${isAbstract(classifier) ? "protected" : "public"} constructor(classifier: ${imports.core("Classifier")}, id: ${imports.json("LionWebId")}, handleDelta?: ${imports.generic("DeltaHandler")}, parentInfo?: ${imports.generic("Parentage")}) {`,
|
|
178
200
|
indent([
|
|
179
201
|
`super(classifier, id, handleDelta, parentInfo);`,
|
|
180
202
|
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);`)
|
|
@@ -215,18 +237,46 @@ export const typeForLanguageEntity = (imports: Imports, mpsAnnotationsPerId: Rec
|
|
|
215
237
|
const typeForPrimitiveType = (primitiveType: PrimitiveType) =>
|
|
216
238
|
`export type ${primitiveType.name} = ${tsTypeForPrimitiveType(primitiveType)};`
|
|
217
239
|
|
|
218
|
-
const jsDocFor = (entity:
|
|
219
|
-
const
|
|
220
|
-
const conceptDescription =
|
|
221
|
-
const
|
|
222
|
-
const
|
|
223
|
-
|
|
240
|
+
const jsDocFor = (entity: M3Concept) => {
|
|
241
|
+
const annotations = ioLionWebMpsSpecificAnnotationsFrom(entity)
|
|
242
|
+
const conceptDescription = annotations.find((annotation) => annotation instanceof ConceptDescription) as ConceptDescription
|
|
243
|
+
const deprecated = annotations.find((annotation) => annotation instanceof Deprecated) as Deprecated
|
|
244
|
+
const keyedDescription = annotations.find((annotation) => annotation instanceof KeyedDescription) as KeyedDescription
|
|
245
|
+
const shortDescription = annotations.find((annotation) => annotation instanceof ShortDescription) as ShortDescription
|
|
246
|
+
const virtualPackage = annotations.find((annotation) => annotation instanceof VirtualPackage) as VirtualPackage
|
|
247
|
+
const requiresJsDoc =
|
|
248
|
+
!!(conceptDescription?.conceptShortDescription)
|
|
249
|
+
|| !!(conceptDescription?.helpUrl)
|
|
250
|
+
|| !!(shortDescription?.description)
|
|
251
|
+
|| keyedDescription !== undefined
|
|
252
|
+
|| deprecated !== undefined
|
|
253
|
+
|| !!(virtualPackage?.name)
|
|
254
|
+
const linkName = (node: Node) =>
|
|
255
|
+
node instanceof LanguageEntity
|
|
256
|
+
? node.name
|
|
257
|
+
: "??? (not a language's entity)"
|
|
258
|
+
return when(requiresJsDoc)([
|
|
224
259
|
`/**`,
|
|
225
|
-
when(
|
|
226
|
-
() => ` * ${conceptDescription.
|
|
260
|
+
when(!!(conceptDescription?.conceptShortDescription))(
|
|
261
|
+
() => ` * ${conceptDescription.conceptShortDescription}`
|
|
262
|
+
),
|
|
263
|
+
when(!!(conceptDescription?.helpUrl))(
|
|
264
|
+
() => ` * {@see} ${conceptDescription.helpUrl}`
|
|
265
|
+
),
|
|
266
|
+
when(!!(shortDescription?.description))(
|
|
267
|
+
() => ` * ${shortDescription.description}`
|
|
268
|
+
),
|
|
269
|
+
when(keyedDescription !== undefined)(
|
|
270
|
+
() => [
|
|
271
|
+
when(keyedDescription.documentation !== undefined)(` * ${keyedDescription.documentation}`),
|
|
272
|
+
keyedDescription.seeAlso.map((seeAlso) => ` * {@see} {@link ${linkName(seeAlso)}}`)
|
|
273
|
+
]
|
|
227
274
|
),
|
|
228
275
|
when(deprecated !== undefined)(
|
|
229
|
-
() => ` * @deprecated ${deprecated.comment ?? ""}${deprecated.build ===
|
|
276
|
+
() => ` * @deprecated ${deprecated.comment ?? ""}${deprecated.build === undefined ? "" : ` (build: ${deprecated.build})`}`
|
|
277
|
+
),
|
|
278
|
+
when(!!(virtualPackage?.name))(
|
|
279
|
+
() => `(virtual package: ${virtualPackage.name})`
|
|
230
280
|
),
|
|
231
281
|
` */`
|
|
232
282
|
])
|
|
@@ -1,16 +1,22 @@
|
|
|
1
|
-
//
|
|
1
|
+
// Copyright 2025 TRUMPF Laser SE and other contributors
|
|
2
2
|
//
|
|
3
|
-
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License")
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
|
|
16
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
17
|
|
|
5
18
|
import { asString } from "littoral-templates"
|
|
6
19
|
|
|
7
|
-
/**
|
|
8
|
-
* @return the given string, reversed — "abc" -> "cba"
|
|
9
|
-
* Note: only used to hack around the REUSE compliance checker!
|
|
10
|
-
*/
|
|
11
|
-
const reverseString = (str: string) =>
|
|
12
|
-
str.split("").reverse().join("")
|
|
13
|
-
|
|
14
20
|
/**
|
|
15
21
|
* The license header (as //-styled comments) for code originating from Trumpf Laser SE, licensed under Apache-2.0.
|
|
16
22
|
*/
|
|
@@ -28,20 +34,18 @@ const trumpfOriginatingApache2_0LicenseHeaderComments = `// Copyright 2025 TRUMP
|
|
|
28
34
|
// See the License for the specific language governing permissions and
|
|
29
35
|
// limitations under the License.
|
|
30
36
|
//
|
|
31
|
-
//
|
|
32
|
-
//
|
|
33
|
-
`
|
|
37
|
+
// SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
|
|
38
|
+
// SPDX-License-Identifier: Apache-2.0`
|
|
34
39
|
|
|
35
40
|
/**
|
|
36
41
|
* Generic (//-styled) comments warning about code being generated.
|
|
37
42
|
*/
|
|
38
43
|
export const generatedCodeWarningComments = `// Warning: this file is generated!
|
|
39
|
-
// Modifying it by hand is useless at best, and sabotage at worst
|
|
40
|
-
`
|
|
44
|
+
// Modifying it by hand is useless at best, and sabotage at worst.`
|
|
41
45
|
|
|
42
46
|
/**
|
|
43
47
|
* The empty line-separation concatenation of the Trumpf-flavored Apache-2.0 license header and the generation warning.
|
|
44
48
|
*/
|
|
45
49
|
export const defaultTrumpfOriginatingApache2_0LicensedHeader =
|
|
46
|
-
asString([trumpfOriginatingApache2_0LicenseHeaderComments, ``, generatedCodeWarningComments
|
|
50
|
+
asString([trumpfOriginatingApache2_0LicenseHeaderComments, ``, generatedCodeWarningComments])
|
|
47
51
|
|
|
@@ -21,7 +21,6 @@ import { readFileAsJson } from "@lionweb/utilities"
|
|
|
21
21
|
import { writeFileSync } from "fs"
|
|
22
22
|
import { join } from "path"
|
|
23
23
|
import { cwd } from "process"
|
|
24
|
-
import { MpsAnnotation } from "./helpers/index.js"
|
|
25
24
|
|
|
26
25
|
import { indexTsFor } from "./index-ts.js"
|
|
27
26
|
import { languageFileFor } from "./language-file.templates.js"
|
|
@@ -30,55 +29,63 @@ const properGenericImportLocation = "@lionweb/class-core"
|
|
|
30
29
|
|
|
31
30
|
|
|
32
31
|
export type GeneratorOptions = {
|
|
33
|
-
mpsAnnotations: MpsAnnotation[]
|
|
34
32
|
genericImportLocation: string
|
|
35
33
|
header?: string
|
|
34
|
+
verbose: boolean
|
|
36
35
|
}
|
|
37
36
|
|
|
38
37
|
|
|
39
38
|
const withDefaults = (options?: Partial<GeneratorOptions>): GeneratorOptions => ({
|
|
40
|
-
mpsAnnotations: options?.mpsAnnotations ?? [],
|
|
41
39
|
genericImportLocation: options?.genericImportLocation ?? properGenericImportLocation,
|
|
42
|
-
header: options?.header
|
|
40
|
+
header: options?.header,
|
|
41
|
+
verbose: options?.verbose ?? true
|
|
43
42
|
})
|
|
44
43
|
|
|
45
44
|
|
|
46
|
-
export const generateLanguage = (language: Language, generationPath: string,
|
|
45
|
+
export const generateLanguage = (language: Language, generationPath: string, mayBeOptions?: Partial<GeneratorOptions>): string => {
|
|
47
46
|
const {name} = language
|
|
48
47
|
const fileName = `${name}.g.ts`
|
|
49
|
-
writeFileSync(join(generationPath, fileName), languageFileFor(language, withDefaults(
|
|
48
|
+
writeFileSync(join(generationPath, fileName), languageFileFor(language, withDefaults(mayBeOptions)))
|
|
50
49
|
return fileName
|
|
51
50
|
}
|
|
52
51
|
|
|
53
52
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
const logger = (verbose?: boolean): ((text?: string) => void) =>
|
|
54
|
+
verbose ?? true
|
|
55
|
+
? (_text?: string) => {}
|
|
56
|
+
: (text?: string) => { console.log(text ?? ``) }
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
export const generateApiFromLanguagesJson = (languagesJsonPath: string, generationPath: string, mayBeOptions?: Partial<GeneratorOptions>) => {
|
|
60
|
+
const log = logger(mayBeOptions?.verbose)
|
|
61
|
+
log(`Running API generator with cwd: ${cwd()}`)
|
|
62
|
+
log(` Path to languages: ${languagesJsonPath}`)
|
|
63
|
+
log(` Generation path: ${generationPath}`)
|
|
58
64
|
|
|
59
65
|
const languagesJson = readFileAsJson(languagesJsonPath) as LionWebJsonChunk
|
|
60
66
|
const languages = deserializeLanguages(languagesJson, lioncore)
|
|
61
|
-
generateApiFromLanguages(languages, generationPath,
|
|
67
|
+
generateApiFromLanguages(languages, generationPath, mayBeOptions)
|
|
62
68
|
}
|
|
63
69
|
|
|
64
70
|
|
|
65
71
|
export const generateApiFromLanguages = (languages: Language[], generationPath: string, maybeOptions?: Partial<GeneratorOptions>) => {
|
|
66
|
-
|
|
72
|
+
const log = logger(maybeOptions?.verbose)
|
|
73
|
+
log(` Generated:`)
|
|
67
74
|
|
|
68
75
|
const options = withDefaults(maybeOptions)
|
|
69
76
|
|
|
70
77
|
if (languages.length > 1) {
|
|
71
78
|
writeFileSync(join(generationPath, "index.g.ts"), indexTsFor(languages, options))
|
|
72
|
-
|
|
79
|
+
log(` index.g.ts`)
|
|
73
80
|
}
|
|
74
81
|
|
|
75
82
|
languages.forEach((language) => {
|
|
76
83
|
const {name, version, key, id} = language
|
|
77
84
|
const fileName = generateLanguage(language, generationPath, options)
|
|
78
|
-
|
|
85
|
+
log(` ${fileName} -> language: ${name} (version=${version}, key=${key}, id=${id})`)
|
|
79
86
|
})
|
|
80
87
|
|
|
81
|
-
|
|
82
|
-
|
|
88
|
+
log(`[done]`)
|
|
89
|
+
log()
|
|
83
90
|
}
|
|
84
91
|
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
import {
|
|
19
19
|
builtinClassifiers,
|
|
20
20
|
Classifier,
|
|
21
|
-
|
|
21
|
+
DataType,
|
|
22
22
|
Enumeration,
|
|
23
23
|
Feature,
|
|
24
24
|
isContainment,
|
|
@@ -44,17 +44,17 @@ export const typeOf = (feature: Feature): SingleRef<LanguageEntity> => {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
|
|
47
|
-
export const
|
|
48
|
-
if (
|
|
49
|
-
return `unknown /* [ERROR] can't compute a TS type for a null
|
|
47
|
+
export const tsTypeForDataType = (dataType: SingleRef<DataType>, imports: Imports) => {
|
|
48
|
+
if (dataType === null) {
|
|
49
|
+
return `unknown /* [ERROR] can't compute a TS type for a null data type */`
|
|
50
50
|
}
|
|
51
|
-
if (
|
|
52
|
-
return tsTypeForPrimitiveType(
|
|
51
|
+
if (dataType instanceof PrimitiveType) {
|
|
52
|
+
return tsTypeForPrimitiveType(dataType)
|
|
53
53
|
}
|
|
54
|
-
if (
|
|
55
|
-
return imports.entity(
|
|
54
|
+
if (dataType instanceof Enumeration) {
|
|
55
|
+
return imports.entity(dataType)
|
|
56
56
|
}
|
|
57
|
-
return `unknown /* [ERROR] can't compute a TS type for
|
|
57
|
+
return `unknown /* [ERROR] can't compute a TS type for data type ${dataType.name} that has an unhandled/-known meta-type ${dataType.constructor.name} */`
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
// SPDX-License-Identifier: Apache-2.0
|
|
17
17
|
|
|
18
18
|
import { Language, LanguageEntity, lioncoreBuiltins } from "@lionweb/core"
|
|
19
|
-
import { asJSIdentifier } from "
|
|
19
|
+
import { asJSIdentifier } from "@lionweb/textgen-utils"
|
|
20
20
|
|
|
21
21
|
export const importRenamingForLanguage = (language: Language) => asJSIdentifier(language.name)
|
|
22
22
|
|
|
@@ -16,9 +16,7 @@
|
|
|
16
16
|
// SPDX-License-Identifier: Apache-2.0
|
|
17
17
|
|
|
18
18
|
export * from "./classifiers.js"
|
|
19
|
-
export * from "./dependencies.js"
|
|
20
19
|
export * from "./entities.js"
|
|
21
20
|
export * from "./features.js"
|
|
22
21
|
export * from "./imports-tracking.js"
|
|
23
|
-
export * from "./mps-annotations.js"
|
|
24
22
|
export * from "./primitive-types.js"
|
|
@@ -19,13 +19,13 @@ import { builtinPrimitives, PrimitiveType } from "@lionweb/core"
|
|
|
19
19
|
|
|
20
20
|
export const tsTypeForPrimitiveType = (primitiveType: PrimitiveType): string => {
|
|
21
21
|
switch (primitiveType) {
|
|
22
|
-
case builtinPrimitives.
|
|
22
|
+
case builtinPrimitives.booleanDataType:
|
|
23
23
|
return `boolean`
|
|
24
|
-
case builtinPrimitives.
|
|
24
|
+
case builtinPrimitives.stringDataType:
|
|
25
25
|
return `string`
|
|
26
|
-
case builtinPrimitives.
|
|
26
|
+
case builtinPrimitives.integerDataType:
|
|
27
27
|
return `number`
|
|
28
|
-
case builtinPrimitives.
|
|
28
|
+
case builtinPrimitives.jsonDataType:
|
|
29
29
|
return `unknown`
|
|
30
30
|
default:
|
|
31
31
|
return `string`
|
|
@@ -15,13 +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 { dependencyOrderOf } from "@lionweb/ts-utils"
|
|
19
18
|
import { Language } from "@lionweb/core"
|
|
19
|
+
import { indent } from "@lionweb/textgen-utils"
|
|
20
|
+
import { dependencyOrderOf } from "@lionweb/ts-utils"
|
|
21
|
+
import { dependenciesThroughDirectInheritanceOf } from "@lionweb/utilities"
|
|
20
22
|
import { asString, commaSeparated } from "littoral-templates"
|
|
21
23
|
|
|
22
|
-
import { indent } from "../utils/textgen.js"
|
|
23
24
|
import { GeneratorOptions } from "./generator.js"
|
|
24
|
-
import {
|
|
25
|
+
import { importRenamingForLanguage, nameOfBaseClassForLanguage } from "./helpers/index.js"
|
|
25
26
|
|
|
26
27
|
export const indexTsFor = (languages: Language[], options: GeneratorOptions) => {
|
|
27
28
|
const dependenciesInOrderOfDirectInheritance = dependencyOrderOf(languages, dependenciesThroughDirectInheritanceOf)
|
package/src/index.ts
CHANGED
|
@@ -15,5 +15,6 @@
|
|
|
15
15
|
// SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
|
|
16
16
|
// SPDX-License-Identifier: Apache-2.0
|
|
17
17
|
|
|
18
|
-
export
|
|
19
|
-
export * from "./
|
|
18
|
+
export { generateLanguage, generateApiFromLanguages, generateApiFromLanguagesJson } from "./generator.js"
|
|
19
|
+
export * from "./generation-headers.js"
|
|
20
|
+
export * from "./mega-factory.templates.js"
|
|
@@ -15,11 +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 { sortedStringsByUppercase } from "@lionweb/ts-utils"
|
|
19
18
|
import { Concept, Language } from "@lionweb/core"
|
|
20
|
-
import {
|
|
19
|
+
import { indent } from "@lionweb/textgen-utils"
|
|
20
|
+
import { dependencyOrderOf, sortedStringsByUppercase } from "@lionweb/ts-utils"
|
|
21
21
|
import { asString, commaSeparated, when, withNewlineAppended } from "littoral-templates"
|
|
22
|
-
import { indent } from "../utils/textgen.js"
|
|
23
22
|
|
|
24
23
|
import { typeForLanguageEntity } from "./entity-types.templates.js"
|
|
25
24
|
import { GeneratorOptions } from "./generator.js"
|
|
@@ -41,8 +40,6 @@ export const languageFileFor = (language: Language, options: GeneratorOptions) =
|
|
|
41
40
|
throw new Error(`language ${name} has a cycle among the graph of entities with edges formed by the inheritance dependency`)
|
|
42
41
|
}
|
|
43
42
|
|
|
44
|
-
const mpsAnnotationsPerId = groupBy(options.mpsAnnotations, ({annotatedNodeId}) => annotatedNodeId)
|
|
45
|
-
|
|
46
43
|
const postImportsPart = [
|
|
47
44
|
``,
|
|
48
45
|
reflectiveClassFor(imports)(language),
|
|
@@ -50,7 +47,7 @@ export const languageFileFor = (language: Language, options: GeneratorOptions) =
|
|
|
50
47
|
``,
|
|
51
48
|
orderedEntities
|
|
52
49
|
.filter((entity) => entity.language === language)
|
|
53
|
-
.map(withNewlineAppended(typeForLanguageEntity(imports
|
|
50
|
+
.map(withNewlineAppended(typeForLanguageEntity(imports)))
|
|
54
51
|
]
|
|
55
52
|
|
|
56
53
|
return asString([
|