@lionweb/class-core-generator 0.6.13-beta.7 → 0.7.0-alpha.10
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 +10 -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} +37 -16
- 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} +0 -2
- package/dist/generator.d.ts.map +1 -0
- package/dist/{api/generator.js → generator.js} +0 -1
- package/dist/generator.js.map +1 -0
- package/dist/helpers/classifiers.d.ts.map +1 -0
- package/dist/{api/helpers → helpers}/classifiers.js +1 -1
- 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 +11 -11
- package/dist/helpers/features.js.map +1 -0
- package/dist/{api/helpers → helpers}/imports-tracking.d.ts +3 -0
- package/dist/helpers/imports-tracking.d.ts.map +1 -0
- package/dist/{api/helpers → helpers}/imports-tracking.js +9 -1
- package/dist/helpers/imports-tracking.js.map +1 -0
- package/dist/helpers/index.d.ts +6 -0
- package/dist/helpers/index.d.ts.map +1 -0
- package/dist/{api/helpers → helpers}/index.js +1 -3
- package/dist/helpers/index.js.map +1 -0
- package/dist/{api/helpers/types.d.ts → helpers/primitive-types.d.ts} +1 -1
- package/dist/helpers/primitive-types.d.ts.map +1 -0
- package/dist/{api/helpers/types.js → helpers/primitive-types.js} +9 -5
- 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} +8 -8
- 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} +7 -13
- 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} +7 -10
- 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} +24 -35
- package/dist/reflective-layer.templates.js.map +1 -0
- package/package.json +17 -11
- package/src/{api/entity-types.templates.ts → entity-types.templates.ts} +57 -22
- package/src/{api/generation-headers.ts → generation-headers.ts} +20 -16
- package/src/{api/generator.ts → generator.ts} +9 -12
- package/src/{api/helpers → helpers}/classifiers.ts +3 -15
- package/src/{api/helpers → helpers}/entities.ts +2 -8
- package/src/{api/helpers → helpers}/features.ts +14 -14
- package/src/{api/helpers → helpers}/imports-tracking.ts +12 -5
- package/src/{api/helpers → helpers}/index.ts +1 -3
- package/src/{api/helpers/types.ts → helpers/primitive-types.ts} +9 -6
- package/src/{api/index-ts.ts → index-ts.ts} +27 -16
- package/src/index.ts +3 -2
- package/src/{api/language-file.templates.ts → language-file.templates.ts} +11 -19
- package/src/{api/mega-factory.templates.ts → mega-factory.templates.ts} +21 -28
- package/src/{api/reflective-layer.templates.ts → reflective-layer.templates.ts} +51 -69
- package/dist/api/entity-types.templates.d.ts +0 -4
- 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 +0 -8
- 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/types.d.ts.map +0 -1
- package/dist/api/helpers/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 -4
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -20
- 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/string-sorting.d.ts +0 -4
- package/dist/utils/string-sorting.d.ts.map +0 -1
- package/dist/utils/string-sorting.js +0 -23
- package/dist/utils/string-sorting.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/dist/utils/toposort.d.ts +0 -6
- package/dist/utils/toposort.d.ts.map +0 -1
- package/dist/utils/toposort.js +0 -41
- package/dist/utils/toposort.js.map +0 -1
- package/src/api/helpers/dependencies.ts +0 -62
- package/src/api/helpers/mps-annotations.ts +0 -69
- package/src/api/index.ts +0 -21
- package/src/utils/index.ts +0 -21
- package/src/utils/json-as-ts.ts +0 -20
- package/src/utils/string-sorting.ts +0 -29
- package/src/utils/textgen.ts +0 -89
- package/src/utils/toposort.ts +0 -49
- /package/dist/{api/helpers → helpers}/classifiers.d.ts +0 -0
- /package/dist/{api/helpers → helpers}/entities.d.ts +0 -0
- /package/dist/{api/helpers → helpers}/entities.js +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
|
@@ -14,20 +14,14 @@
|
|
|
14
14
|
//
|
|
15
15
|
// SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
|
|
16
16
|
// SPDX-License-Identifier: Apache-2.0
|
|
17
|
-
import { Concept
|
|
17
|
+
import { Concept } from "@lionweb/core";
|
|
18
|
+
import { indent } from "@lionweb/textgen-utils";
|
|
19
|
+
import { dependencyOrderOf, sortedStringsByUppercase } from "@lionweb/ts-utils";
|
|
18
20
|
import { asString, commaSeparated, when, withNewlineAppended } from "littoral-templates";
|
|
19
21
|
import { typeForLanguageEntity } from "./entity-types.templates.js";
|
|
20
|
-
import { reflectiveClassFor } from "./reflective-layer.templates.js";
|
|
21
|
-
import { indent } from "../utils/textgen.js";
|
|
22
|
-
import { sortedStringsByUppercase } from "../utils/string-sorting.js";
|
|
23
|
-
import { dependencyOrderOf } from "../utils/toposort.js";
|
|
24
22
|
import { Imports } from "./helpers/index.js";
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
indent(commaSeparated(sortedStringsByUppercase(items))),
|
|
28
|
-
`} from "${dep}";`,
|
|
29
|
-
``
|
|
30
|
-
]);
|
|
23
|
+
import { reflectiveClassFor } from "./reflective-layer.templates.js";
|
|
24
|
+
const importStatement = (dep, items) => when(items.length > 0)([`import {`, indent(commaSeparated(sortedStringsByUppercase(items))), `} from "${dep}";`, ``]);
|
|
31
25
|
export const languageFileFor = (language, options) => {
|
|
32
26
|
const { name, version, key, id, entities } = language;
|
|
33
27
|
const imports = new Imports(language);
|
|
@@ -35,7 +29,6 @@ export const languageFileFor = (language, options) => {
|
|
|
35
29
|
if (typeof orderedEntities === "boolean") {
|
|
36
30
|
throw new Error(`language ${name} has a cycle among the graph of entities with edges formed by the inheritance dependency`);
|
|
37
31
|
}
|
|
38
|
-
const mpsAnnotationsPerId = groupBy(options.mpsAnnotations, ({ annotatedNodeId }) => annotatedNodeId);
|
|
39
32
|
const postImportsPart = [
|
|
40
33
|
``,
|
|
41
34
|
reflectiveClassFor(imports)(language),
|
|
@@ -43,7 +36,7 @@ export const languageFileFor = (language, options) => {
|
|
|
43
36
|
``,
|
|
44
37
|
orderedEntities
|
|
45
38
|
.filter((entity) => entity.language === language)
|
|
46
|
-
.map(withNewlineAppended(typeForLanguageEntity(imports
|
|
39
|
+
.map(withNewlineAppended(typeForLanguageEntity(imports)))
|
|
47
40
|
];
|
|
48
41
|
return asString([
|
|
49
42
|
options?.header ?? [],
|
|
@@ -57,6 +50,7 @@ export const languageFileFor = (language, options) => {
|
|
|
57
50
|
``,
|
|
58
51
|
``,
|
|
59
52
|
importStatement(`@lionweb/core`, imports.coreImports),
|
|
53
|
+
importStatement(`@lionweb/json`, imports.jsonImports),
|
|
60
54
|
importStatement(options.genericImportLocation, imports.genericImports),
|
|
61
55
|
importStatement(`./index.g.js`, imports.languageImports),
|
|
62
56
|
postImportsPart
|
|
@@ -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,CAAA;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAA;AAEpE,MAAM,eAAe,GAAG,CAAC,GAAW,EAAE,KAAe,EAAE,EAAE,CACrD,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,MAAM,CAAC,cAAc,CAAC,wBAAwB,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,WAAW,GAAG,IAAI,EAAE,EAAE,CAAC,CAAC,CAAA;AAGzH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,QAAkB,EAAE,OAAyB,EAAE,EAAE;IAE7E,MAA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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,22 +15,21 @@
|
|
|
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 = {`,
|
|
26
26
|
indent(commaSeparated(language.entities
|
|
27
27
|
.filter(requiresFactoryMethod)
|
|
28
|
-
.map(
|
|
28
|
+
.map(classifier => `create${classifier.name}: () => ${asJSIdentifier(language.name)}.${classifier.name}.create(newId(), this.handleDelta)`))),
|
|
29
29
|
`}`,
|
|
30
30
|
``
|
|
31
31
|
];
|
|
32
|
-
const languagesWithFactoryMethods = languages
|
|
33
|
-
.filter((language) => language.entities.some(requiresFactoryMethod));
|
|
32
|
+
const languagesWithFactoryMethods = languages.filter(language => language.entities.some(requiresFactoryMethod));
|
|
34
33
|
return asString([
|
|
35
34
|
header ?? [],
|
|
36
35
|
`import {DeltaHandler} from "@lionweb/class-core";`,
|
|
@@ -46,9 +45,7 @@ export const megaFactoryFor = (megaFactoryName, languages, mpsAnnotations = [],
|
|
|
46
45
|
indent([
|
|
47
46
|
``,
|
|
48
47
|
`constructor(`,
|
|
49
|
-
indent([
|
|
50
|
-
`public readonly handleDelta?: DeltaHandler`
|
|
51
|
-
]),
|
|
48
|
+
indent([`public readonly handleDelta?: DeltaHandler`]),
|
|
52
49
|
`) {`,
|
|
53
50
|
`}`,
|
|
54
51
|
``,
|
|
@@ -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,CAA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AAG;QACH,EAAE;KACL,CAAC,CAAA;AACN,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reflective-layer.templates.d.ts","sourceRoot":"","sources":["../src/reflective-layer.templates.ts"],"names":[],"mappings":"AAiBA,OAAO,EAaH,QAAQ,EAOX,MAAM,eAAe,CAAA;AAKtB,OAAO,EAA+B,OAAO,EAA8B,MAAM,oBAAoB,CAAA;AAErG,eAAO,MAAM,kBAAkB,YAAa,OAAO,gBAwI7B,QAAQ,0BAyE7B,CAAA"}
|
|
@@ -14,9 +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,
|
|
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";
|
|
19
|
+
import { asArray } from "@lionweb/ts-utils";
|
|
18
20
|
import { when, withNewlineAppended } from "littoral-templates";
|
|
19
|
-
import { indent, switchOrIf } from "../utils/textgen.js";
|
|
20
21
|
import { entityMetaType, extendsFrom, nameOfBaseClassForLanguage } from "./helpers/index.js";
|
|
21
22
|
export const reflectiveClassFor = (imports) => {
|
|
22
23
|
// classifier:
|
|
@@ -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 : ""})${isPartition(classifier) ? ".isPartition()" : ""};`,
|
|
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,14 @@ 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((classifier) => [
|
|
171
|
+
// case's key:
|
|
172
|
+
`this._${classifier.name}.key`,
|
|
173
|
+
// return value:
|
|
174
|
+
`${classifier.name}.create(id, ${parameterPrefix}handleDelta)`
|
|
175
|
+
]), [
|
|
187
176
|
`const {language} = classifier;`,
|
|
188
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})\`);`
|
|
189
178
|
])),
|
|
@@ -195,7 +184,7 @@ export const reflectiveClassFor = (imports) => {
|
|
|
195
184
|
// (Why can this work?! EnumType is an unsatisfied generic parameter!)
|
|
196
185
|
indent([
|
|
197
186
|
`const {enumeration} = enumerationLiteral;`,
|
|
198
|
-
switchOrIf("enumeration.key", enumerations.map(nameOf).map(
|
|
187
|
+
switchOrIf("enumeration.key", enumerations.map(nameOf).map(name => [`this._${name}.key`, "enumerationLiteral.key as EnumType"]), [
|
|
199
188
|
`const {language} = enumeration;`,
|
|
200
189
|
`throw new Error(\`enumeration with key \${enumeration.key} is not known in language \${language.name} (key=\${language.key}, version=\${language.version})\`);`
|
|
201
190
|
])
|
|
@@ -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,GAAG,CAAC,OAAgB,EAAE,EAAE;IACnD,cAAc;IAEd,MAAM,2BAA2B,GAAG,CAAC,OAAgB,EAAE,EAAE;QACrD,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,QAAQ,EAAE,G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AC,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.
|
|
3
|
+
"version": "0.7.0-alpha.10",
|
|
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,20 +15,26 @@
|
|
|
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
|
-
"pre-release
|
|
22
|
-
"prerelease": "npm run pre-release
|
|
23
|
-
"release": "npm publish",
|
|
24
|
-
"prerelease-beta": "npm run pre-release
|
|
25
|
-
"release-beta": "npm publish --tag beta"
|
|
21
|
+
"prep:pre-release": "npm run clean && npm install && npm run build",
|
|
22
|
+
"prerelease-alpha": "npm run prep:pre-release",
|
|
23
|
+
"release-alpha": "npm publish --tag alpha",
|
|
24
|
+
"prerelease-beta": "npm run prep:pre-release",
|
|
25
|
+
"release-beta": "npm publish --tag beta",
|
|
26
|
+
"prerelease": "npm run prep:pre-release",
|
|
27
|
+
"release": "npm publish"
|
|
26
28
|
},
|
|
27
29
|
"devDependencies": {
|
|
28
|
-
"@lionweb/core": "0.
|
|
29
|
-
"@lionweb/
|
|
30
|
-
"@
|
|
31
|
-
"
|
|
30
|
+
"@lionweb/core": "0.7.0-alpha.10",
|
|
31
|
+
"@lionweb/io-lionweb-mps-specific": "0.7.0-alpha.10",
|
|
32
|
+
"@lionweb/json": "0.7.0-alpha.10",
|
|
33
|
+
"@lionweb/textgen-utils": "0.7.0-alpha.10",
|
|
34
|
+
"@lionweb/ts-utils": "0.7.0-alpha.10",
|
|
35
|
+
"@lionweb/utilities": "0.7.0-alpha.10",
|
|
36
|
+
"@types/node": "22.15.21",
|
|
37
|
+
"littoral-templates": "0.5.0",
|
|
32
38
|
"typescript": "5.3.3"
|
|
33
39
|
}
|
|
34
40
|
}
|
|
@@ -21,41 +21,46 @@ import {
|
|
|
21
21
|
Enumeration,
|
|
22
22
|
Feature,
|
|
23
23
|
featureMetaType,
|
|
24
|
-
Id,
|
|
25
24
|
Interface,
|
|
26
25
|
isContainment,
|
|
27
26
|
isProperty,
|
|
28
27
|
isReference,
|
|
29
28
|
LanguageEntity,
|
|
30
29
|
Link,
|
|
30
|
+
M3Concept,
|
|
31
31
|
nameSorted,
|
|
32
|
+
Node,
|
|
32
33
|
PrimitiveType,
|
|
33
34
|
Property,
|
|
34
35
|
Reference,
|
|
35
36
|
SingleRef
|
|
36
37
|
} from "@lionweb/core"
|
|
37
|
-
import {commaSeparated, when, withNewlineAppended} from "littoral-templates"
|
|
38
|
-
|
|
39
|
-
import {indent, switchOrIf, withFirstUpper, wrapInIf} from "../utils/textgen.js"
|
|
40
38
|
import {
|
|
41
39
|
ConceptDescription,
|
|
42
40
|
Deprecated,
|
|
41
|
+
ioLionWebMpsSpecificAnnotationsFrom,
|
|
42
|
+
KeyedDescription,
|
|
43
|
+
ShortDescription,
|
|
44
|
+
VirtualPackage
|
|
45
|
+
} from "@lionweb/io-lionweb-mps-specific"
|
|
46
|
+
import { indent, switchOrIf, withFirstUpper, wrapInIf } from "@lionweb/textgen-utils"
|
|
47
|
+
import { commaSeparated, when, withNewlineAppended } from "littoral-templates"
|
|
48
|
+
|
|
49
|
+
import {
|
|
43
50
|
entityMetaType,
|
|
44
51
|
extendsFrom,
|
|
45
52
|
featuresToConcretelyImplementOf,
|
|
46
53
|
implementsFrom,
|
|
47
54
|
Imports,
|
|
48
55
|
isAbstract,
|
|
49
|
-
MpsAnnotation,
|
|
50
56
|
optionalityPostfix,
|
|
51
57
|
tsFieldTypeForFeature,
|
|
52
58
|
tsTypeForClassifier,
|
|
53
|
-
|
|
59
|
+
tsTypeForDataType,
|
|
54
60
|
tsTypeForPrimitiveType,
|
|
55
61
|
tsTypeForValueManager
|
|
56
62
|
} from "./helpers/index.js"
|
|
57
63
|
|
|
58
|
-
|
|
59
64
|
const cardinalityPrefix = (feature: Feature) => {
|
|
60
65
|
if (feature instanceof Property) {
|
|
61
66
|
return feature.optional ? "Optional" : "Required"
|
|
@@ -68,7 +73,7 @@ const cardinalityPrefix = (feature: Feature) => {
|
|
|
68
73
|
const valueManagerFor = (feature: Feature) =>
|
|
69
74
|
`${cardinalityPrefix(feature)}${featureMetaType(feature)}ValueManager`
|
|
70
75
|
|
|
71
|
-
export const typeForLanguageEntity = (imports: Imports
|
|
76
|
+
export const typeForLanguageEntity = (imports: Imports) => {
|
|
72
77
|
|
|
73
78
|
const sortedSuperTypesCond = <T extends Classifier>(ts: T[], prefix: string): string =>
|
|
74
79
|
ts.length === 0 ? `` : `${prefix}${nameSorted(ts).map((t) => imports.entity(t)).join(", ")}`
|
|
@@ -79,11 +84,12 @@ export const typeForLanguageEntity = (imports: Imports, mpsAnnotationsPerId: Rec
|
|
|
79
84
|
const classMembersForProperty = (property: Property) => {
|
|
80
85
|
const {name, type} = property
|
|
81
86
|
return [
|
|
82
|
-
`private readonly _${name}: ${imports.generic(valueManagerFor(property))}<${
|
|
83
|
-
|
|
87
|
+
`private readonly _${name}: ${imports.generic(valueManagerFor(property))}<${tsTypeForDataType(type, imports)}>;`,
|
|
88
|
+
jsDocFor(property),
|
|
89
|
+
`get ${name}(): ${tsTypeForDataType(type, imports)}${optionalityPostfix(property)} {`,
|
|
84
90
|
indent(`return this._${name}.get();`),
|
|
85
91
|
`}`,
|
|
86
|
-
`set ${name}(newValue: ${
|
|
92
|
+
`set ${name}(newValue: ${tsTypeForDataType(type, imports)}${optionalityPostfix(property)}) {`,
|
|
87
93
|
indent(`this._${name}.set(newValue);`),
|
|
88
94
|
`}`
|
|
89
95
|
]
|
|
@@ -97,6 +103,7 @@ export const typeForLanguageEntity = (imports: Imports, mpsAnnotationsPerId: Rec
|
|
|
97
103
|
const {name, type, multiple} = link
|
|
98
104
|
return [
|
|
99
105
|
`private readonly _${name}: ${imports.generic(valueManagerFor(link))}<${tsTypeForClassifier(type, imports)}>;`,
|
|
106
|
+
jsDocFor(link),
|
|
100
107
|
`get ${name}(): ${tsTypeForLink(link)} {`,
|
|
101
108
|
indent(`return this._${name}.get();`),
|
|
102
109
|
`}`,
|
|
@@ -163,7 +170,7 @@ export const typeForLanguageEntity = (imports: Imports, mpsAnnotationsPerId: Rec
|
|
|
163
170
|
when(!isAbstract(classifier))(
|
|
164
171
|
() =>
|
|
165
172
|
[
|
|
166
|
-
`static create(id:
|
|
173
|
+
`static create(id: ${imports.json("LionWebId")}, handleDelta?: ${imports.generic("DeltaHandler")}, parentInfo?: ${imports.generic("Parentage")}): ${classifier.name} {`,
|
|
167
174
|
indent([
|
|
168
175
|
`return new ${classifier.name}(${imports.language(classifier.language)}.INSTANCE.${classifier.name}, id, handleDelta, parentInfo);`
|
|
169
176
|
]),
|
|
@@ -175,7 +182,7 @@ export const typeForLanguageEntity = (imports: Imports, mpsAnnotationsPerId: Rec
|
|
|
175
182
|
[
|
|
176
183
|
``,
|
|
177
184
|
features.map(withNewlineAppended(classMembersForFeature)),
|
|
178
|
-
|
|
185
|
+
`${isAbstract(classifier) ? "protected" : "public"} constructor(classifier: ${imports.core("Classifier")}, id: ${imports.json("LionWebId")}, handleDelta?: ${imports.generic("DeltaHandler")}, parentInfo?: ${imports.generic("Parentage")}) {`,
|
|
179
186
|
indent([
|
|
180
187
|
`super(classifier, id, handleDelta, parentInfo);`,
|
|
181
188
|
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);`)
|
|
@@ -216,18 +223,46 @@ export const typeForLanguageEntity = (imports: Imports, mpsAnnotationsPerId: Rec
|
|
|
216
223
|
const typeForPrimitiveType = (primitiveType: PrimitiveType) =>
|
|
217
224
|
`export type ${primitiveType.name} = ${tsTypeForPrimitiveType(primitiveType)};`
|
|
218
225
|
|
|
219
|
-
const jsDocFor = (entity:
|
|
220
|
-
const
|
|
221
|
-
const conceptDescription =
|
|
222
|
-
const
|
|
223
|
-
const
|
|
224
|
-
|
|
226
|
+
const jsDocFor = (entity: M3Concept) => {
|
|
227
|
+
const annotations = ioLionWebMpsSpecificAnnotationsFrom(entity)
|
|
228
|
+
const conceptDescription = annotations.find((annotation) => annotation instanceof ConceptDescription) as ConceptDescription
|
|
229
|
+
const deprecated = annotations.find((annotation) => annotation instanceof Deprecated) as Deprecated
|
|
230
|
+
const keyedDescription = annotations.find((annotation) => annotation instanceof KeyedDescription) as KeyedDescription
|
|
231
|
+
const shortDescription = annotations.find((annotation) => annotation instanceof ShortDescription) as ShortDescription
|
|
232
|
+
const virtualPackage = annotations.find((annotation) => annotation instanceof VirtualPackage) as VirtualPackage
|
|
233
|
+
const requiresJsDoc =
|
|
234
|
+
!!(conceptDescription?.conceptShortDescription)
|
|
235
|
+
|| !!(conceptDescription?.helpUrl)
|
|
236
|
+
|| !!(shortDescription?.description)
|
|
237
|
+
|| keyedDescription !== undefined
|
|
238
|
+
|| deprecated !== undefined
|
|
239
|
+
|| !!(virtualPackage?.name)
|
|
240
|
+
const linkName = (node: Node) =>
|
|
241
|
+
node instanceof LanguageEntity
|
|
242
|
+
? node.name
|
|
243
|
+
: "??? (not a language's entity)"
|
|
244
|
+
return when(requiresJsDoc)([
|
|
225
245
|
`/**`,
|
|
226
|
-
when(
|
|
227
|
-
() => ` * ${conceptDescription.
|
|
246
|
+
when(!!(conceptDescription?.conceptShortDescription))(
|
|
247
|
+
() => ` * ${conceptDescription.conceptShortDescription}`
|
|
248
|
+
),
|
|
249
|
+
when(!!(conceptDescription?.helpUrl))(
|
|
250
|
+
() => ` * {@see} ${conceptDescription.helpUrl}`
|
|
251
|
+
),
|
|
252
|
+
when(!!(shortDescription?.description))(
|
|
253
|
+
() => ` * ${shortDescription.description}`
|
|
254
|
+
),
|
|
255
|
+
when(keyedDescription !== undefined)(
|
|
256
|
+
() => [
|
|
257
|
+
when(keyedDescription.documentation !== undefined)(` * ${keyedDescription.documentation}`),
|
|
258
|
+
keyedDescription.seeAlso.map((seeAlso) => ` * {@see} {@link ${linkName(seeAlso)}}`)
|
|
259
|
+
]
|
|
228
260
|
),
|
|
229
261
|
when(deprecated !== undefined)(
|
|
230
|
-
() => ` * @deprecated ${deprecated.comment ?? ""}${deprecated.build ===
|
|
262
|
+
() => ` * @deprecated ${deprecated.comment ?? ""}${deprecated.build === undefined ? "" : ` (build: ${deprecated.build})`}`
|
|
263
|
+
),
|
|
264
|
+
when(!!(virtualPackage?.name))(
|
|
265
|
+
() => `(virtual package: ${virtualPackage.name})`
|
|
231
266
|
),
|
|
232
267
|
` */`
|
|
233
268
|
])
|
|
@@ -1,15 +1,21 @@
|
|
|
1
|
-
//
|
|
1
|
+
// Copyright 2025 TRUMPF Laser SE and other contributors
|
|
2
2
|
//
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
|
|
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
|
|
6
17
|
|
|
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("")
|
|
18
|
+
import { asString } from "littoral-templates"
|
|
13
19
|
|
|
14
20
|
/**
|
|
15
21
|
* The license header (as //-styled comments) for code originating from Trumpf Laser SE, licensed under Apache-2.0.
|
|
@@ -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
|
|
|
@@ -15,29 +15,26 @@
|
|
|
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 {indexTsFor} from "./index-ts.js"
|
|
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"
|
|
27
24
|
|
|
25
|
+
import { indexTsFor } from "./index-ts.js"
|
|
26
|
+
import { languageFileFor } from "./language-file.templates.js"
|
|
28
27
|
|
|
29
28
|
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
|
|
36
34
|
}
|
|
37
35
|
|
|
38
36
|
|
|
39
37
|
const withDefaults = (options?: Partial<GeneratorOptions>): GeneratorOptions => ({
|
|
40
|
-
mpsAnnotations: options?.mpsAnnotations ?? [],
|
|
41
38
|
genericImportLocation: options?.genericImportLocation ?? properGenericImportLocation,
|
|
42
39
|
header: options?.header
|
|
43
40
|
})
|
|
@@ -56,7 +53,7 @@ export const generateApiFromLanguagesJson = (languagesJsonPath: string, generati
|
|
|
56
53
|
console.log(` Path to languages: ${languagesJsonPath}`)
|
|
57
54
|
console.log(` Generation path: ${generationPath}`)
|
|
58
55
|
|
|
59
|
-
const languagesJson = readFileAsJson(languagesJsonPath) as
|
|
56
|
+
const languagesJson = readFileAsJson(languagesJsonPath) as LionWebJsonChunk
|
|
60
57
|
const languages = deserializeLanguages(languagesJson, lioncore)
|
|
61
58
|
generateApiFromLanguages(languages, generationPath, options)
|
|
62
59
|
}
|
|
@@ -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,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) {
|