@lionweb/class-core-generator 0.7.0-beta.1 → 0.7.0-beta.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 +6 -1
- package/dist/entity-types.templates.d.ts.map +1 -1
- package/dist/entity-types.templates.js +25 -13
- package/dist/entity-types.templates.js.map +1 -1
- package/dist/generation-headers.d.ts +1 -1
- package/dist/generation-headers.d.ts.map +1 -1
- package/dist/generation-headers.js +19 -13
- package/dist/generation-headers.js.map +1 -1
- package/dist/generator.d.ts +3 -2
- package/dist/generator.d.ts.map +1 -1
- package/dist/generator.js +19 -13
- package/dist/generator.js.map +1 -1
- package/dist/helpers/classifiers.d.ts.map +1 -1
- package/dist/helpers/entities.d.ts.map +1 -1
- package/dist/helpers/features.d.ts.map +1 -1
- package/dist/helpers/imports-tracking.d.ts.map +1 -1
- package/dist/helpers/primitive-types.d.ts.map +1 -1
- package/dist/index-ts.d.ts.map +1 -1
- package/dist/language-file.templates.d.ts.map +1 -1
- package/dist/mega-factory.templates.d.ts.map +1 -1
- package/dist/reflective-layer.templates.d.ts.map +1 -1
- package/dist/reflective-layer.templates.js +8 -4
- package/dist/reflective-layer.templates.js.map +1 -1
- package/package.json +11 -12
- package/src/entity-types.templates.ts +28 -14
- package/src/generation-headers.ts +19 -15
- package/src/generator.ts +23 -13
- package/src/reflective-layer.templates.ts +8 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
## 0.7.0
|
|
4
4
|
|
|
5
5
|
* Move `dependenciesThroughDirectInheritanceOf` and `verboseDependencies` functions from `class-core-generator` to `utilities` package.
|
|
6
|
-
*
|
|
6
|
+
* Remove everything specific to annotations coming from the `io.lionweb.mps.specific` language, in favor of using the types and functionality provided by the `@lionweb/io-lionweb-mps-specific` package.
|
|
7
7
|
**Note**: this slightly breaks the API of the generator, but in such a trivial way (because of the use of defaults) that it doesn't warrant an increment in major version, IOHO.
|
|
8
|
+
* Partition concepts are now marked as such in their `ILanguageBase` implementation.
|
|
9
|
+
* Constructors of abstract concepts are now declared `protected` instead of `public`.
|
|
10
|
+
* Make `console.log` verbosity of the generator calls `generateApiFromLanguages[Json]` (for language**s**) configurable, through an extra property `verbose` of the `GeneratorOptions` which defaults to `true`.
|
|
11
|
+
* Add `replace<1-containment>With` and `replace<*-containment>AtIndex` methods.
|
|
12
|
+
* Turn dev-dependencies into real ones — (as they're all used in shipped code).
|
|
8
13
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity-types.templates.d.ts","sourceRoot":"","sources":["../src/entity-types.templates.ts"],"names":[],"mappings":"AAiBA,OAAO,
|
|
1
|
+
{"version":3,"file":"entity-types.templates.d.ts","sourceRoot":"","sources":["../src/entity-types.templates.ts"],"names":[],"mappings":"AAiBA,OAAO,EAWH,cAAc,EASjB,MAAM,eAAe,CAAA;AAYtB,OAAO,EAKH,OAAO,EAQV,MAAM,oBAAoB,CAAA;AAc3B,eAAO,MAAM,qBAAqB,GAAI,SAAS,OAAO,MAgN1C,QAAQ,cAAc,4CAoBjC,CAAA"}
|
|
@@ -14,7 +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 { builtinClassifiers, Classifier, Enumeration, featureMetaType, Interface, isContainment, isProperty, isReference, LanguageEntity, Link, nameSorted, PrimitiveType, Property, Reference } from "@lionweb/core";
|
|
17
|
+
import { builtinClassifiers, Classifier, Containment, Enumeration, featureMetaType, Interface, isContainment, isProperty, isReference, LanguageEntity, Link, nameSorted, PrimitiveType, Property, Reference } from "@lionweb/core";
|
|
18
18
|
import { ConceptDescription, Deprecated, ioLionWebMpsSpecificAnnotationsFrom, KeyedDescription, ShortDescription, VirtualPackage } from "@lionweb/io-lionweb-mps-specific";
|
|
19
19
|
import { indent, switchOrIf, withFirstUpper, wrapInIf } from "@lionweb/textgen-utils";
|
|
20
20
|
import { commaSeparated, when, withNewlineAppended } from "littoral-templates";
|
|
@@ -44,34 +44,46 @@ export const typeForLanguageEntity = (imports) => {
|
|
|
44
44
|
`}`
|
|
45
45
|
];
|
|
46
46
|
};
|
|
47
|
-
const tsTypeForLink = (link) => wrapInIf(link instanceof Reference, () => `${imports.core("SingleRef")}<`, ">")(tsTypeForClassifier(link.type, imports))
|
|
48
|
-
+ (link.multiple ? "[]" : optionalityPostfix(link));
|
|
49
47
|
const classMembersForLink = (link) => {
|
|
50
48
|
const { name, type, multiple } = link;
|
|
49
|
+
const nameWithFirstUpper = withFirstUpper(name);
|
|
50
|
+
const tsTypeForClassifier_ = tsTypeForClassifier(type, imports);
|
|
51
|
+
const tsTypeForLink_ = wrapInIf(link instanceof Reference, () => `${imports.core("SingleRef")}<`, ">")(tsTypeForClassifier_)
|
|
52
|
+
+ (link.multiple ? "[]" : optionalityPostfix(link));
|
|
51
53
|
return [
|
|
52
|
-
`private readonly _${name}: ${imports.generic(valueManagerFor(link))}<${
|
|
54
|
+
`private readonly _${name}: ${imports.generic(valueManagerFor(link))}<${tsTypeForClassifier_}>;`,
|
|
53
55
|
jsDocFor(link),
|
|
54
|
-
`get ${name}(): ${
|
|
56
|
+
`get ${name}(): ${tsTypeForLink_} {`,
|
|
55
57
|
indent(`return this._${name}.get();`),
|
|
56
58
|
`}`,
|
|
57
59
|
when(!multiple)([
|
|
58
|
-
`set ${name}(newValue: ${
|
|
60
|
+
`set ${name}(newValue: ${tsTypeForLink_}) {`,
|
|
59
61
|
indent(`this._${name}.set(newValue);`),
|
|
60
|
-
`}
|
|
62
|
+
`}`,
|
|
63
|
+
when(link instanceof Containment)([
|
|
64
|
+
`replace${nameWithFirstUpper}With(newValue: ${tsTypeForClassifier_}) {`,
|
|
65
|
+
indent(`this._${name}.replaceWith(newValue);`),
|
|
66
|
+
`}`
|
|
67
|
+
])
|
|
61
68
|
]),
|
|
62
69
|
when(multiple)([
|
|
63
|
-
`add${
|
|
70
|
+
`add${nameWithFirstUpper}(newValue: ${tsTypeForClassifier_}) {`,
|
|
64
71
|
indent(`this._${name}.add(newValue);`),
|
|
65
72
|
`}`,
|
|
66
|
-
`remove${
|
|
73
|
+
`remove${nameWithFirstUpper}(valueToRemove: ${tsTypeForClassifier_}) {`,
|
|
67
74
|
indent(`this._${name}.remove(valueToRemove);`),
|
|
68
75
|
`}`,
|
|
69
|
-
`add${
|
|
76
|
+
`add${nameWithFirstUpper}AtIndex(newValue: ${tsTypeForClassifier_}, index: number) {`,
|
|
70
77
|
indent(`this._${name}.insertAtIndex(newValue, index);`),
|
|
71
78
|
`}`,
|
|
72
|
-
`move${
|
|
79
|
+
`move${nameWithFirstUpper}(oldIndex: number, newIndex: number) {`,
|
|
73
80
|
indent(`this._${name}.move(oldIndex, newIndex);`),
|
|
74
|
-
`}
|
|
81
|
+
`}`,
|
|
82
|
+
when(link instanceof Containment)([
|
|
83
|
+
`replace${nameWithFirstUpper}AtIndex(movedChild: ${tsTypeForClassifier_}, newIndex: number) {`,
|
|
84
|
+
indent(`this._${name}.replaceAtIndex(movedChild, newIndex);`),
|
|
85
|
+
`}`
|
|
86
|
+
])
|
|
75
87
|
])
|
|
76
88
|
];
|
|
77
89
|
};
|
|
@@ -113,7 +125,7 @@ export const typeForLanguageEntity = (imports) => {
|
|
|
113
125
|
when(features.length > 0)(() => [
|
|
114
126
|
``,
|
|
115
127
|
features.map(withNewlineAppended(classMembersForFeature)),
|
|
116
|
-
|
|
128
|
+
`${isAbstract(classifier) ? "protected" : "public"} constructor(classifier: ${imports.core("Classifier")}, id: ${imports.json("LionWebId")}, handleDelta?: ${imports.generic("DeltaHandler")}, parentInfo?: ${imports.generic("Parentage")}) {`,
|
|
117
129
|
indent([
|
|
118
130
|
`super(classifier, id, handleDelta, parentInfo);`,
|
|
119
131
|
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);`)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity-types.templates.js","sourceRoot":"","sources":["../src/entity-types.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,kBAAkB,EAClB,UAAU,EACV,WAAW,EAEX,eAAe,EACf,SAAS,EACT,aAAa,EACb,UAAU,EACV,WAAW,EACX,cAAc,EACd,IAAI,EAEJ,UAAU,EAEV,aAAa,EACb,QAAQ,EACR,SAAS,EAEZ,MAAM,eAAe,CAAA;AACtB,OAAO,EACH,kBAAkB,EAClB,UAAU,EACV,mCAAmC,EACnC,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACjB,MAAM,kCAAkC,CAAA;AACzC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AACrF,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAE9E,OAAO,EACH,cAAc,EACd,WAAW,EACX,+BAA+B,EAC/B,cAAc,EAEd,UAAU,EACV,kBAAkB,EAClB,qBAAqB,EACrB,mBAAmB,EACnB,iBAAiB,EACjB,sBAAsB,EACtB,qBAAqB,EACxB,MAAM,oBAAoB,CAAA;AAE3B,MAAM,iBAAiB,GAAG,CAAC,OAAgB,EAAE,EAAE;IAC3C,IAAI,OAAO,YAAY,QAAQ,EAAE,CAAC;QAC9B,OAAO,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAA;IACrD,C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;YAChH,QAAQ,CAAC,QAAQ,CAAC;YAClB,OAAO,IAAI,OAAO,iBAAiB,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,kBAAkB,CAAC,QAAQ,CAAC,IAAI;YACrF,MAAM,CAAC,gBAAgB,IAAI,SAAS,CAAC;YACrC,GAAG;YACH,OAAO,IAAI,cAAc,iBAAiB,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,kBAAkB,CAAC,QAAQ,CAAC,KAAK;YAC7F,MAAM,CAAC,SAAS,IAAI,iBAAiB,CAAC;YACtC,GAAG;SACN,CAAA;IACL,CAAC,CAAA;IAED,MAAM,
|
|
1
|
+
{"version":3,"file":"entity-types.templates.js","sourceRoot":"","sources":["../src/entity-types.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,kBAAkB,EAClB,UAAU,EACV,WAAW,EACX,WAAW,EAEX,eAAe,EACf,SAAS,EACT,aAAa,EACb,UAAU,EACV,WAAW,EACX,cAAc,EACd,IAAI,EAEJ,UAAU,EAEV,aAAa,EACb,QAAQ,EACR,SAAS,EAEZ,MAAM,eAAe,CAAA;AACtB,OAAO,EACH,kBAAkB,EAClB,UAAU,EACV,mCAAmC,EACnC,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACjB,MAAM,kCAAkC,CAAA;AACzC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AACrF,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAE9E,OAAO,EACH,cAAc,EACd,WAAW,EACX,+BAA+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C1B,GAAG,EAAE,CAAC,kBAAkB,UAAU,CAAC,OAAO,IAAI,EAAE,GAAG,UAAU,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,YAAY,UAAU,CAAC,KAAK,GAAG,EAAE,CAC7H;YACD,IAAI,CAAC,CAAC,CAAC,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC,CAC1B,GAAG,EAAE,CAAC,qBAAqB,cAAc,CAAC,IAAI,GAAG,CACpD;YACD,KAAK;SACR,CAAC,CAAA;IACN,CAAC,CAAA;IAED,OAAO,CAAC,MAAsB,EAAE,EAAE,CAC9B;QACI,QAAQ,CAAC,MAAM,CAAC;QAChB,CAAC,GAAG,EAAE;YACF,IAAI,MAAM,YAAY,SAAS,EAAE,CAAC;gBAC9B,OAAO,YAAY,CAAC,MAAM,CAAC,CAAA;YAC/B,CAAC;YACD,IAAI,MAAM,YAAY,UAAU,EAAE,CAAC;gBAC/B,OAAO,0BAA0B,CAAC,MAAM,CAAC,CAAA;YAC7C,CAAC;YACD,IAAI,MAAM,YAAY,WAAW,EAAE,CAAC;gBAChC,OAAO,kBAAkB,CAAC,MAAM,CAAC,CAAA;YACrC,CAAC;YACD,IAAI,MAAM,YAAY,aAAa,EAAE,CAAC;gBAClC,OAAO,oBAAoB,CAAC,MAAM,CAAC,CAAA;YACvC,CAAC;YACD,OAAO,iCAAiC,cAAc,CAAC,MAAM,CAAC,KAAK,MAAM,CAAC,IAAI,GAAG,CAAA;QACrF,CAAC,CAAC,EAAE;KACP,CAAA;AAET,CAAC,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Generic (//-styled) comments warning about code being generated.
|
|
3
3
|
*/
|
|
4
|
-
export declare const generatedCodeWarningComments = "// Warning: this file is generated!\n// Modifying it by hand is useless at best, and sabotage at worst
|
|
4
|
+
export declare const generatedCodeWarningComments = "// Warning: this file is generated!\n// Modifying it by hand is useless at best, and sabotage at worst.";
|
|
5
5
|
/**
|
|
6
6
|
* The empty line-separation concatenation of the Trumpf-flavored Apache-2.0 license header and the generation warning.
|
|
7
7
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generation-headers.d.ts","sourceRoot":"","sources":["../src/generation-headers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generation-headers.d.ts","sourceRoot":"","sources":["../src/generation-headers.ts"],"names":[],"mappings":"AAuCA;;GAEG;AACH,eAAO,MAAM,4BAA4B,4GAC0B,CAAA;AAEnE;;GAEG;AACH,eAAO,MAAM,+CAA+C,QACqC,CAAA"}
|
|
@@ -1,12 +1,20 @@
|
|
|
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
|
import { asString } from "littoral-templates";
|
|
5
|
-
/**
|
|
6
|
-
* @return the given string, reversed — "abc" -> "cba"
|
|
7
|
-
* Note: only used to hack around the REUSE compliance checker!
|
|
8
|
-
*/
|
|
9
|
-
const reverseString = (str) => str.split("").reverse().join("");
|
|
10
18
|
/**
|
|
11
19
|
* The license header (as //-styled comments) for code originating from Trumpf Laser SE, licensed under Apache-2.0.
|
|
12
20
|
*/
|
|
@@ -24,17 +32,15 @@ const trumpfOriginatingApache2_0LicenseHeaderComments = `// Copyright 2025 TRUMP
|
|
|
24
32
|
// See the License for the specific language governing permissions and
|
|
25
33
|
// limitations under the License.
|
|
26
34
|
//
|
|
27
|
-
//
|
|
28
|
-
//
|
|
29
|
-
`;
|
|
35
|
+
// SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
|
|
36
|
+
// SPDX-License-Identifier: Apache-2.0`;
|
|
30
37
|
/**
|
|
31
38
|
* Generic (//-styled) comments warning about code being generated.
|
|
32
39
|
*/
|
|
33
40
|
export const generatedCodeWarningComments = `// Warning: this file is generated!
|
|
34
|
-
// Modifying it by hand is useless at best, and sabotage at worst
|
|
35
|
-
`;
|
|
41
|
+
// Modifying it by hand is useless at best, and sabotage at worst.`;
|
|
36
42
|
/**
|
|
37
43
|
* The empty line-separation concatenation of the Trumpf-flavored Apache-2.0 license header and the generation warning.
|
|
38
44
|
*/
|
|
39
|
-
export const defaultTrumpfOriginatingApache2_0LicensedHeader = asString([trumpfOriginatingApache2_0LicenseHeaderComments, ``, generatedCodeWarningComments
|
|
45
|
+
export const defaultTrumpfOriginatingApache2_0LicensedHeader = asString([trumpfOriginatingApache2_0LicenseHeaderComments, ``, generatedCodeWarningComments]);
|
|
40
46
|
//# sourceMappingURL=generation-headers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generation-headers.js","sourceRoot":"","sources":["../src/generation-headers.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"generation-headers.js","sourceRoot":"","sources":["../src/generation-headers.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,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAE7C;;GAEG;AACH,MAAM,+CAA+C,GAAG;;;;;;;;;;;;;;;uCAejB,CAAA;AAEvC;;GAEG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG;mEACuB,CAAA;AAEnE;;GAEG;AACH,MAAM,CAAC,MAAM,+CAA+C,GACxD,QAAQ,CAAC,CAAC,+CAA+C,EAAE,EAAE,EAAE,4BAA4B,CAAC,CAAC,CAAA"}
|
package/dist/generator.d.ts
CHANGED
|
@@ -2,8 +2,9 @@ import { Language } from "@lionweb/core";
|
|
|
2
2
|
export type GeneratorOptions = {
|
|
3
3
|
genericImportLocation: string;
|
|
4
4
|
header?: string;
|
|
5
|
+
verbose: boolean;
|
|
5
6
|
};
|
|
6
|
-
export declare const generateLanguage: (language: Language, generationPath: string,
|
|
7
|
-
export declare const generateApiFromLanguagesJson: (languagesJsonPath: string, generationPath: string,
|
|
7
|
+
export declare const generateLanguage: (language: Language, generationPath: string, mayBeOptions?: Partial<GeneratorOptions>) => string;
|
|
8
|
+
export declare const generateApiFromLanguagesJson: (languagesJsonPath: string, generationPath: string, mayBeOptions?: Partial<GeneratorOptions>) => void;
|
|
8
9
|
export declare const generateApiFromLanguages: (languages: Language[], generationPath: string, maybeOptions?: Partial<GeneratorOptions>) => void;
|
|
9
10
|
//# sourceMappingURL=generator.d.ts.map
|
package/dist/generator.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../src/generator.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAwB,QAAQ,EAAY,MAAM,eAAe,CAAA;AAaxE,MAAM,MAAM,gBAAgB,GAAG;IAC3B,qBAAqB,EAAE,MAAM,CAAA;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../src/generator.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAwB,QAAQ,EAAY,MAAM,eAAe,CAAA;AAaxE,MAAM,MAAM,gBAAgB,GAAG;IAC3B,qBAAqB,EAAE,MAAM,CAAA;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,OAAO,CAAA;CACnB,CAAA;AAUD,eAAO,MAAM,gBAAgB,GAAI,UAAU,QAAQ,EAAE,gBAAgB,MAAM,EAAE,eAAe,OAAO,CAAC,gBAAgB,CAAC,KAAG,MAKvH,CAAA;AASD,eAAO,MAAM,4BAA4B,GAAI,mBAAmB,MAAM,EAAE,gBAAgB,MAAM,EAAE,eAAe,OAAO,CAAC,gBAAgB,CAAC,SASvI,CAAA;AAGD,eAAO,MAAM,wBAAwB,GAAI,WAAW,QAAQ,EAAE,EAAE,gBAAgB,MAAM,EAAE,eAAe,OAAO,CAAC,gBAAgB,CAAC,SAmB/H,CAAA"}
|
package/dist/generator.js
CHANGED
|
@@ -24,35 +24,41 @@ import { languageFileFor } from "./language-file.templates.js";
|
|
|
24
24
|
const properGenericImportLocation = "@lionweb/class-core";
|
|
25
25
|
const withDefaults = (options) => ({
|
|
26
26
|
genericImportLocation: options?.genericImportLocation ?? properGenericImportLocation,
|
|
27
|
-
header: options?.header
|
|
27
|
+
header: options?.header,
|
|
28
|
+
verbose: options?.verbose ?? true
|
|
28
29
|
});
|
|
29
|
-
export const generateLanguage = (language, generationPath,
|
|
30
|
+
export const generateLanguage = (language, generationPath, mayBeOptions) => {
|
|
30
31
|
const { name } = language;
|
|
31
32
|
const fileName = `${name}.g.ts`;
|
|
32
|
-
writeFileSync(join(generationPath, fileName), languageFileFor(language, withDefaults(
|
|
33
|
+
writeFileSync(join(generationPath, fileName), languageFileFor(language, withDefaults(mayBeOptions)));
|
|
33
34
|
return fileName;
|
|
34
35
|
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
console.log(
|
|
38
|
-
|
|
36
|
+
const logger = (verbose) => verbose ?? true
|
|
37
|
+
? (_text) => { }
|
|
38
|
+
: (text) => { console.log(text ?? ``); };
|
|
39
|
+
export const generateApiFromLanguagesJson = (languagesJsonPath, generationPath, mayBeOptions) => {
|
|
40
|
+
const log = logger(mayBeOptions?.verbose);
|
|
41
|
+
log(`Running API generator with cwd: ${cwd()}`);
|
|
42
|
+
log(` Path to languages: ${languagesJsonPath}`);
|
|
43
|
+
log(` Generation path: ${generationPath}`);
|
|
39
44
|
const languagesJson = readFileAsJson(languagesJsonPath);
|
|
40
45
|
const languages = deserializeLanguages(languagesJson, lioncore);
|
|
41
|
-
generateApiFromLanguages(languages, generationPath,
|
|
46
|
+
generateApiFromLanguages(languages, generationPath, mayBeOptions);
|
|
42
47
|
};
|
|
43
48
|
export const generateApiFromLanguages = (languages, generationPath, maybeOptions) => {
|
|
44
|
-
|
|
49
|
+
const log = logger(maybeOptions?.verbose);
|
|
50
|
+
log(` Generated:`);
|
|
45
51
|
const options = withDefaults(maybeOptions);
|
|
46
52
|
if (languages.length > 1) {
|
|
47
53
|
writeFileSync(join(generationPath, "index.g.ts"), indexTsFor(languages, options));
|
|
48
|
-
|
|
54
|
+
log(` index.g.ts`);
|
|
49
55
|
}
|
|
50
56
|
languages.forEach((language) => {
|
|
51
57
|
const { name, version, key, id } = language;
|
|
52
58
|
const fileName = generateLanguage(language, generationPath, options);
|
|
53
|
-
|
|
59
|
+
log(` ${fileName} -> language: ${name} (version=${version}, key=${key}, id=${id})`);
|
|
54
60
|
});
|
|
55
|
-
|
|
56
|
-
|
|
61
|
+
log(`[done]`);
|
|
62
|
+
log();
|
|
57
63
|
};
|
|
58
64
|
//# sourceMappingURL=generator.js.map
|
package/dist/generator.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../src/generator.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,EAAE;AACF,iEAAiE;AACjE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD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U,
|
|
1
|
+
{"version":3,"file":"classifiers.d.ts","sourceRoot":"","sources":["../../src/helpers/classifiers.ts"],"names":[],"mappings":"AAiBA,OAAO,EAA8C,UAAU,EAAW,OAAO,EAAa,QAAQ,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAGxI,eAAO,MAAM,UAAU,GAAI,YAAY,UAAU,KAAG,OAA+D,CAAA;AAMnH,eAAO,MAAM,WAAW,GAAI,YAAY,UAAU,KAAG,SAAS,CAAC,UAAU,CAAC,GAAG,SAQ5E,CAAA;AAED,eAAO,MAAM,cAAc,GAAI,YAAY,UAAU,KAAG,QAAQ,CAAC,UAAU,CAQ1E,CAAA;AAED,eAAO,MAAM,+BAA+B,GAAI,YAAY,UAAU,KAAG,OAAO,EAO/E,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entities.d.ts","sourceRoot":"","sources":["../../src/helpers/entities.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAkC,cAAc,EAAiB,MAAM,eAAe,CAAA;AAE7F,KAAK,cAAc,GAAG,YAAY,GAAG,SAAS,GAAG,aAAa,GAAG,WAAW,GAAG,eAAe,CAAA;AAE9F,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"entities.d.ts","sourceRoot":"","sources":["../../src/helpers/entities.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAkC,cAAc,EAAiB,MAAM,eAAe,CAAA;AAE7F,KAAK,cAAc,GAAG,YAAY,GAAG,SAAS,GAAG,aAAa,GAAG,WAAW,GAAG,eAAe,CAAA;AAE9F,eAAO,MAAM,cAAc,GAAI,QAAQ,cAAc,KAAG,cAcvD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features.d.ts","sourceRoot":"","sources":["../../src/helpers/features.ts"],"names":[],"mappings":"AAiBA,OAAO,EAEH,UAAU,EACV,QAAQ,EAER,OAAO,EAIP,cAAc,EAId,SAAS,EAEZ,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,OAAO,EAA0B,MAAM,YAAY,CAAA;AAE5D,eAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"features.d.ts","sourceRoot":"","sources":["../../src/helpers/features.ts"],"names":[],"mappings":"AAiBA,OAAO,EAEH,UAAU,EACV,QAAQ,EAER,OAAO,EAIP,cAAc,EAId,SAAS,EAEZ,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,OAAO,EAA0B,MAAM,YAAY,CAAA;AAE5D,eAAO,MAAM,MAAM,GAAI,SAAS,OAAO,KAAG,SAAS,CAAC,cAAc,CAQjE,CAAA;AAGD,eAAO,MAAM,iBAAiB,GAAI,UAAU,SAAS,CAAC,QAAQ,CAAC,EAAE,SAAS,OAAO,WAWhF,CAAA;AAGD,eAAO,MAAM,mBAAmB,GAAI,YAAY,SAAS,CAAC,UAAU,CAAC,EAAE,SAAS,OAAO,WAKtF,CAAA;AAGD,eAAO,MAAM,kBAAkB,GAAI,SAAS,OAAO,wBAA2C,CAAA;AAE9F,eAAO,MAAM,qBAAqB,GAAI,SAAS,OAAO,EAAE,SAAS,OAAO,KAAG,MA0B1E,CAAA;AAED,eAAO,MAAM,qBAAqB,GAAI,SAAS,OAAO,EAAE,SAAS,OAAO,KAAG,MAqB1E,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imports-tracking.d.ts","sourceRoot":"","sources":["../../src/helpers/imports-tracking.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAoB,MAAM,eAAe,CAAA;AAG1E,eAAO,MAAM,yBAAyB,
|
|
1
|
+
{"version":3,"file":"imports-tracking.d.ts","sourceRoot":"","sources":["../../src/helpers/imports-tracking.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAoB,MAAM,eAAe,CAAA;AAG1E,eAAO,MAAM,yBAAyB,GAAI,UAAU,QAAQ,WAAkC,CAAA;AAE9F,eAAO,MAAM,0BAA0B,GAAI,UAAU,QAAQ,WACnB,CAAA;AAM1C,qBAAa,OAAO;aAEY,YAAY,EAAE,QAAQ;gBAAtB,YAAY,EAAE,QAAQ;IAGlD,IAAI,8BAA8B,WAEjC;IAED,IAAI,iBAAiB,WAEpB;IAED,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAoB;IACjD,IAAI,WAAW,aAEd;IACD,IAAI,CAAC,UAAU,EAAE,MAAM;IAKvB,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAoB;IACjD,IAAI,WAAW,aAEd;IACD,IAAI,CAAC,UAAU,EAAE,MAAM;IAKvB,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAoB;IACpD,IAAI,cAAc,aAEjB;IACD,OAAO,CAAC,UAAU,EAAE,MAAM;IAK1B,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAoB;IAClD,IAAI,YAAY,aAEf;IACD,MAAM,CAAC,MAAM,EAAE,cAAc;IAY7B,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAoB;IACrD,IAAI,eAAe,aAElB;IACD,QAAQ,CAAC,QAAQ,EAAE,QAAQ;CAY9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"primitive-types.d.ts","sourceRoot":"","sources":["../../src/helpers/primitive-types.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAqB,aAAa,EAAE,MAAM,eAAe,CAAA;AAEhE,eAAO,MAAM,sBAAsB,
|
|
1
|
+
{"version":3,"file":"primitive-types.d.ts","sourceRoot":"","sources":["../../src/helpers/primitive-types.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAqB,aAAa,EAAE,MAAM,eAAe,CAAA;AAEhE,eAAO,MAAM,sBAAsB,GAAI,eAAe,aAAa,KAAG,MAarE,CAAA"}
|
package/dist/index-ts.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-ts.d.ts","sourceRoot":"","sources":["../src/index-ts.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAMxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAGjD,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"index-ts.d.ts","sourceRoot":"","sources":["../src/index-ts.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAMxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAGjD,eAAO,MAAM,UAAU,GAAI,WAAW,QAAQ,EAAE,EAAE,SAAS,gBAAgB,WA0C1E,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"language-file.templates.d.ts","sourceRoot":"","sources":["../src/language-file.templates.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAW,QAAQ,EAAE,MAAM,eAAe,CAAA;AAMjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAQjD,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"language-file.templates.d.ts","sourceRoot":"","sources":["../src/language-file.templates.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAW,QAAQ,EAAE,MAAM,eAAe,CAAA;AAMjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAQjD,eAAO,MAAM,eAAe,GAAI,UAAU,QAAQ,EAAE,SAAS,gBAAgB,WAsC5E,CAAA"}
|
|
@@ -1 +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,
|
|
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,GAAI,iBAAiB,MAAM,EAAE,WAAW,QAAQ,EAAE,EAAE,SAAS,MAAM,WAgD7F,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reflective-layer.templates.d.ts","sourceRoot":"","sources":["../src/reflective-layer.templates.ts"],"names":[],"mappings":"AAiBA,OAAO,
|
|
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,GAAI,SAAS,OAAO,MAwIvC,UAAU,QAAQ,0BAyE7B,CAAA"}
|
|
@@ -14,7 +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";
|
|
17
|
+
import { Annotation, Classifier, Concept, Enumeration, featureMetaType, Interface, isConcrete, isEnumeration, isMultiple, isPartition, Link, nameOf, PrimitiveType, Property } from "@lionweb/core";
|
|
18
18
|
import { indent, switchOrIf } from "@lionweb/textgen-utils";
|
|
19
19
|
import { asArray } from "@lionweb/ts-utils";
|
|
20
20
|
import { when, withNewlineAppended } from "littoral-templates";
|
|
@@ -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
|
])),
|
|
@@ -1 +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,
|
|
1
|
+
{"version":3,"file":"reflective-layer.templates.js","source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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-beta.
|
|
3
|
+
"version": "0.7.0-beta.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",
|
|
@@ -26,15 +26,14 @@
|
|
|
26
26
|
"prerelease": "npm run prep:pre-release",
|
|
27
27
|
"release": "npm publish"
|
|
28
28
|
},
|
|
29
|
-
"
|
|
30
|
-
"@lionweb/core": "0.7.0-beta.
|
|
31
|
-
"@lionweb/io-lionweb-mps-specific": "0.7.0-beta.
|
|
32
|
-
"@lionweb/json": "0.7.0-beta.
|
|
33
|
-
"@lionweb/textgen-utils": "0.7.0-beta.
|
|
34
|
-
"@lionweb/ts-utils": "0.7.0-beta.
|
|
35
|
-
"@lionweb/utilities": "0.7.0-beta.
|
|
36
|
-
"@types/node": "
|
|
37
|
-
"littoral-templates": "0.
|
|
38
|
-
"typescript": "5.3.3"
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@lionweb/core": "0.7.0-beta.11",
|
|
31
|
+
"@lionweb/io-lionweb-mps-specific": "0.7.0-beta.11",
|
|
32
|
+
"@lionweb/json": "0.7.0-beta.11",
|
|
33
|
+
"@lionweb/textgen-utils": "0.7.0-beta.11",
|
|
34
|
+
"@lionweb/ts-utils": "0.7.0-beta.11",
|
|
35
|
+
"@lionweb/utilities": "0.7.0-beta.11",
|
|
36
|
+
"@types/node": "24.3.0",
|
|
37
|
+
"littoral-templates": "0.5.0"
|
|
39
38
|
}
|
|
40
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,
|
|
@@ -95,36 +96,49 @@ export const typeForLanguageEntity = (imports: Imports) => {
|
|
|
95
96
|
]
|
|
96
97
|
}
|
|
97
98
|
|
|
98
|
-
const tsTypeForLink = (link: Link) =>
|
|
99
|
-
wrapInIf(link instanceof Reference, () => `${imports.core("SingleRef")}<`, ">")(tsTypeForClassifier(link.type, imports))
|
|
100
|
-
+ (link.multiple ? "[]" : optionalityPostfix(link))
|
|
101
|
-
|
|
102
99
|
const classMembersForLink = (link: Link) => {
|
|
103
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
|
+
)
|
|
104
108
|
return [
|
|
105
|
-
`private readonly _${name}: ${imports.generic(valueManagerFor(link))}<${
|
|
109
|
+
`private readonly _${name}: ${imports.generic(valueManagerFor(link))}<${tsTypeForClassifier_}>;`,
|
|
106
110
|
jsDocFor(link),
|
|
107
|
-
`get ${name}(): ${
|
|
111
|
+
`get ${name}(): ${tsTypeForLink_} {`,
|
|
108
112
|
indent(`return this._${name}.get();`),
|
|
109
113
|
`}`,
|
|
110
114
|
when(!multiple)([
|
|
111
|
-
`set ${name}(newValue: ${
|
|
115
|
+
`set ${name}(newValue: ${tsTypeForLink_}) {`,
|
|
112
116
|
indent(`this._${name}.set(newValue);`),
|
|
113
|
-
`}
|
|
117
|
+
`}`,
|
|
118
|
+
when(link instanceof Containment)([
|
|
119
|
+
`replace${nameWithFirstUpper}With(newValue: ${tsTypeForClassifier_}) {`,
|
|
120
|
+
indent(`this._${name}.replaceWith(newValue);`),
|
|
121
|
+
`}`
|
|
122
|
+
])
|
|
114
123
|
]),
|
|
115
124
|
when(multiple)([
|
|
116
|
-
`add${
|
|
125
|
+
`add${nameWithFirstUpper}(newValue: ${tsTypeForClassifier_}) {`,
|
|
117
126
|
indent(`this._${name}.add(newValue);`),
|
|
118
127
|
`}`,
|
|
119
|
-
`remove${
|
|
128
|
+
`remove${nameWithFirstUpper}(valueToRemove: ${tsTypeForClassifier_}) {`,
|
|
120
129
|
indent(`this._${name}.remove(valueToRemove);`),
|
|
121
130
|
`}`,
|
|
122
|
-
`add${
|
|
131
|
+
`add${nameWithFirstUpper}AtIndex(newValue: ${tsTypeForClassifier_}, index: number) {`,
|
|
123
132
|
indent(`this._${name}.insertAtIndex(newValue, index);`),
|
|
124
133
|
`}`,
|
|
125
|
-
`move${
|
|
134
|
+
`move${nameWithFirstUpper}(oldIndex: number, newIndex: number) {`,
|
|
126
135
|
indent(`this._${name}.move(oldIndex, newIndex);`),
|
|
127
|
-
`}
|
|
136
|
+
`}`,
|
|
137
|
+
when(link instanceof Containment)([
|
|
138
|
+
`replace${nameWithFirstUpper}AtIndex(movedChild: ${tsTypeForClassifier_}, newIndex: number) {`,
|
|
139
|
+
indent(`this._${name}.replaceAtIndex(movedChild, newIndex);`),
|
|
140
|
+
`}`
|
|
141
|
+
])
|
|
128
142
|
])
|
|
129
143
|
]
|
|
130
144
|
}
|
|
@@ -182,7 +196,7 @@ export const typeForLanguageEntity = (imports: Imports) => {
|
|
|
182
196
|
[
|
|
183
197
|
``,
|
|
184
198
|
features.map(withNewlineAppended(classMembersForFeature)),
|
|
185
|
-
|
|
199
|
+
`${isAbstract(classifier) ? "protected" : "public"} constructor(classifier: ${imports.core("Classifier")}, id: ${imports.json("LionWebId")}, handleDelta?: ${imports.generic("DeltaHandler")}, parentInfo?: ${imports.generic("Parentage")}) {`,
|
|
186
200
|
indent([
|
|
187
201
|
`super(classifier, id, handleDelta, parentInfo);`,
|
|
188
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);`)
|
|
@@ -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
|
|
package/src/generator.ts
CHANGED
|
@@ -31,51 +31,61 @@ const properGenericImportLocation = "@lionweb/class-core"
|
|
|
31
31
|
export type GeneratorOptions = {
|
|
32
32
|
genericImportLocation: string
|
|
33
33
|
header?: string
|
|
34
|
+
verbose: boolean
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
|
|
37
38
|
const withDefaults = (options?: Partial<GeneratorOptions>): GeneratorOptions => ({
|
|
38
39
|
genericImportLocation: options?.genericImportLocation ?? properGenericImportLocation,
|
|
39
|
-
header: options?.header
|
|
40
|
+
header: options?.header,
|
|
41
|
+
verbose: options?.verbose ?? true
|
|
40
42
|
})
|
|
41
43
|
|
|
42
44
|
|
|
43
|
-
export const generateLanguage = (language: Language, generationPath: string,
|
|
45
|
+
export const generateLanguage = (language: Language, generationPath: string, mayBeOptions?: Partial<GeneratorOptions>): string => {
|
|
44
46
|
const {name} = language
|
|
45
47
|
const fileName = `${name}.g.ts`
|
|
46
|
-
writeFileSync(join(generationPath, fileName), languageFileFor(language, withDefaults(
|
|
48
|
+
writeFileSync(join(generationPath, fileName), languageFileFor(language, withDefaults(mayBeOptions)))
|
|
47
49
|
return fileName
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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}`)
|
|
55
64
|
|
|
56
65
|
const languagesJson = readFileAsJson(languagesJsonPath) as LionWebJsonChunk
|
|
57
66
|
const languages = deserializeLanguages(languagesJson, lioncore)
|
|
58
|
-
generateApiFromLanguages(languages, generationPath,
|
|
67
|
+
generateApiFromLanguages(languages, generationPath, mayBeOptions)
|
|
59
68
|
}
|
|
60
69
|
|
|
61
70
|
|
|
62
71
|
export const generateApiFromLanguages = (languages: Language[], generationPath: string, maybeOptions?: Partial<GeneratorOptions>) => {
|
|
63
|
-
|
|
72
|
+
const log = logger(maybeOptions?.verbose)
|
|
73
|
+
log(` Generated:`)
|
|
64
74
|
|
|
65
75
|
const options = withDefaults(maybeOptions)
|
|
66
76
|
|
|
67
77
|
if (languages.length > 1) {
|
|
68
78
|
writeFileSync(join(generationPath, "index.g.ts"), indexTsFor(languages, options))
|
|
69
|
-
|
|
79
|
+
log(` index.g.ts`)
|
|
70
80
|
}
|
|
71
81
|
|
|
72
82
|
languages.forEach((language) => {
|
|
73
83
|
const {name, version, key, id} = language
|
|
74
84
|
const fileName = generateLanguage(language, generationPath, options)
|
|
75
|
-
|
|
85
|
+
log(` ${fileName} -> language: ${name} (version=${version}, key=${key}, id=${id})`)
|
|
76
86
|
})
|
|
77
87
|
|
|
78
|
-
|
|
79
|
-
|
|
88
|
+
log(`[done]`)
|
|
89
|
+
log()
|
|
80
90
|
}
|
|
81
91
|
|
|
@@ -27,6 +27,7 @@ import {
|
|
|
27
27
|
isConcrete,
|
|
28
28
|
isEnumeration,
|
|
29
29
|
isMultiple,
|
|
30
|
+
isPartition,
|
|
30
31
|
Language,
|
|
31
32
|
LanguageEntity,
|
|
32
33
|
Link,
|
|
@@ -61,7 +62,7 @@ export const reflectiveClassFor = (imports: Imports) => {
|
|
|
61
62
|
const { name, key, id, features } = classifier
|
|
62
63
|
const metaType = entityMetaType(classifier)
|
|
63
64
|
return [
|
|
64
|
-
`public readonly _${name} = new ${imports.core(metaType)}(this._language, "${name}", "${key}", "${id}"${classifier instanceof Concept ? ", " + classifier.abstract : ""});`,
|
|
65
|
+
`public readonly _${name} = new ${imports.core(metaType)}(this._language, "${name}", "${key}", "${id}"${classifier instanceof Concept ? ", " + classifier.abstract : ""})${isPartition(classifier) ? ".isPartition()" : ""};`,
|
|
65
66
|
// | core (2nd x) |
|
|
66
67
|
`get ${name}(): ${metaType} {`,
|
|
67
68
|
indent([`this.ensureWiredUp();`, `return this._${name};`]),
|
|
@@ -214,8 +215,12 @@ export const reflectiveClassFor = (imports: Imports) => {
|
|
|
214
215
|
switchOrIf(
|
|
215
216
|
"classifier.key",
|
|
216
217
|
concreteClassifiers
|
|
217
|
-
.map(
|
|
218
|
-
|
|
218
|
+
.map((classifier) => [
|
|
219
|
+
// case's key:
|
|
220
|
+
`this._${classifier.name}.key`,
|
|
221
|
+
// return value:
|
|
222
|
+
`${classifier.name}.create(id, ${parameterPrefix}handleDelta)`
|
|
223
|
+
]),
|
|
219
224
|
[
|
|
220
225
|
`const {language} = classifier;`,
|
|
221
226
|
`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})\`);`
|