@lionweb/class-core-generator 0.6.13-beta.7 → 0.7.0-alpha.2

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.
Files changed (91) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/api/entity-types.templates.d.ts +3 -3
  3. package/dist/api/entity-types.templates.d.ts.map +1 -1
  4. package/dist/api/entity-types.templates.js +10 -9
  5. package/dist/api/entity-types.templates.js.map +1 -1
  6. package/dist/api/generation-headers.js.map +1 -1
  7. package/dist/api/generator.d.ts +0 -2
  8. package/dist/api/generator.d.ts.map +1 -1
  9. package/dist/api/generator.js +0 -1
  10. package/dist/api/generator.js.map +1 -1
  11. package/dist/api/helpers/classifiers.d.ts.map +1 -1
  12. package/dist/api/helpers/classifiers.js +1 -1
  13. package/dist/api/helpers/classifiers.js.map +1 -1
  14. package/dist/api/helpers/dependencies.d.ts.map +1 -1
  15. package/dist/api/helpers/dependencies.js +2 -2
  16. package/dist/api/helpers/dependencies.js.map +1 -1
  17. package/dist/api/helpers/entities.d.ts.map +1 -1
  18. package/dist/api/helpers/entities.js.map +1 -1
  19. package/dist/api/helpers/features.d.ts.map +1 -1
  20. package/dist/api/helpers/features.js +3 -3
  21. package/dist/api/helpers/features.js.map +1 -1
  22. package/dist/api/helpers/imports-tracking.d.ts +3 -0
  23. package/dist/api/helpers/imports-tracking.d.ts.map +1 -1
  24. package/dist/api/helpers/imports-tracking.js +8 -0
  25. package/dist/api/helpers/imports-tracking.js.map +1 -1
  26. package/dist/api/helpers/index.d.ts +1 -2
  27. package/dist/api/helpers/index.d.ts.map +1 -1
  28. package/dist/api/helpers/index.js +1 -2
  29. package/dist/api/helpers/index.js.map +1 -1
  30. package/dist/api/helpers/{types.d.ts → primitive-types.d.ts} +1 -1
  31. package/dist/api/helpers/primitive-types.d.ts.map +1 -0
  32. package/dist/api/helpers/{types.js → primitive-types.js} +9 -5
  33. package/dist/api/helpers/primitive-types.js.map +1 -0
  34. package/dist/api/index-ts.d.ts.map +1 -1
  35. package/dist/api/index-ts.js +5 -6
  36. package/dist/api/index-ts.js.map +1 -1
  37. package/dist/api/index.d.ts +0 -1
  38. package/dist/api/index.d.ts.map +1 -1
  39. package/dist/api/index.js +0 -1
  40. package/dist/api/index.js.map +1 -1
  41. package/dist/api/language-file.templates.d.ts.map +1 -1
  42. package/dist/api/language-file.templates.js +8 -13
  43. package/dist/api/language-file.templates.js.map +1 -1
  44. package/dist/api/mega-factory.templates.d.ts +1 -2
  45. package/dist/api/mega-factory.templates.d.ts.map +1 -1
  46. package/dist/api/mega-factory.templates.js +6 -9
  47. package/dist/api/mega-factory.templates.js.map +1 -1
  48. package/dist/api/reflective-layer.templates.d.ts.map +1 -1
  49. package/dist/api/reflective-layer.templates.js +19 -34
  50. package/dist/api/reflective-layer.templates.js.map +1 -1
  51. package/dist/utils/index.d.ts +0 -1
  52. package/dist/utils/index.d.ts.map +1 -1
  53. package/dist/utils/index.js +0 -1
  54. package/dist/utils/index.js.map +1 -1
  55. package/dist/utils/textgen.d.ts.map +1 -1
  56. package/dist/utils/textgen.js.map +1 -1
  57. package/package.json +14 -9
  58. package/src/api/entity-types.templates.ts +11 -15
  59. package/src/api/generation-headers.ts +1 -1
  60. package/src/api/generator.ts +9 -12
  61. package/src/api/helpers/classifiers.ts +3 -15
  62. package/src/api/helpers/dependencies.ts +4 -4
  63. package/src/api/helpers/entities.ts +2 -8
  64. package/src/api/helpers/features.ts +5 -5
  65. package/src/api/helpers/imports-tracking.ts +12 -5
  66. package/src/api/helpers/index.ts +1 -2
  67. package/src/api/helpers/{types.ts → primitive-types.ts} +9 -6
  68. package/src/api/index-ts.ts +26 -16
  69. package/src/api/index.ts +1 -2
  70. package/src/api/language-file.templates.ts +12 -19
  71. package/src/api/mega-factory.templates.ts +21 -27
  72. package/src/api/reflective-layer.templates.ts +46 -69
  73. package/src/utils/index.ts +0 -1
  74. package/src/utils/textgen.ts +1 -1
  75. package/dist/api/helpers/mps-annotations.d.ts +0 -19
  76. package/dist/api/helpers/mps-annotations.d.ts.map +0 -1
  77. package/dist/api/helpers/mps-annotations.js +0 -65
  78. package/dist/api/helpers/mps-annotations.js.map +0 -1
  79. package/dist/api/helpers/types.d.ts.map +0 -1
  80. package/dist/api/helpers/types.js.map +0 -1
  81. package/dist/utils/string-sorting.d.ts +0 -4
  82. package/dist/utils/string-sorting.d.ts.map +0 -1
  83. package/dist/utils/string-sorting.js +0 -23
  84. package/dist/utils/string-sorting.js.map +0 -1
  85. package/dist/utils/toposort.d.ts +0 -6
  86. package/dist/utils/toposort.d.ts.map +0 -1
  87. package/dist/utils/toposort.js +0 -41
  88. package/dist/utils/toposort.js.map +0 -1
  89. package/src/api/helpers/mps-annotations.ts +0 -69
  90. package/src/utils/string-sorting.ts +0 -29
  91. package/src/utils/toposort.ts +0 -49
@@ -15,39 +15,49 @@
15
15
  // SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
16
16
  // SPDX-License-Identifier: Apache-2.0
17
17
 
18
- import {Language} from "@lionweb/core"
19
- import {asString, commaSeparated} from "littoral-templates"
20
-
21
- import {indent} from "../utils/textgen.js"
22
- import {dependencyOrderOf} from "../utils/toposort.js"
23
- import {dependenciesThroughDirectInheritanceOf, importRenamingForLanguage, nameOfBaseClassForLanguage} from "./helpers/index.js"
24
- import {GeneratorOptions} from "./generator.js"
18
+ import { dependencyOrderOf } from "@lionweb/ts-utils"
19
+ import { Language } from "@lionweb/core"
20
+ import { asString, commaSeparated } from "littoral-templates"
25
21
 
22
+ import { indent } from "../utils/textgen.js"
23
+ import { GeneratorOptions } from "./generator.js"
24
+ import { dependenciesThroughDirectInheritanceOf, importRenamingForLanguage, nameOfBaseClassForLanguage } from "./helpers/index.js"
26
25
 
27
26
  export const indexTsFor = (languages: Language[], options: GeneratorOptions) => {
28
27
  const dependenciesInOrderOfDirectInheritance = dependencyOrderOf(languages, dependenciesThroughDirectInheritanceOf)
29
28
  if (dependenciesInOrderOfDirectInheritance === false) {
30
- console.error(`⚠ CYCLE detected! Proceeding with order of languages as-is, instead of in type-wise (through direct inheritance) dependency order ⇒ generated code might not initialize!`)
29
+ console.error(
30
+ `⚠ CYCLE detected! Proceeding with order of languages as-is, instead of in type-wise (through direct inheritance) dependency order ⇒ generated code might not initialize!`
31
+ )
31
32
  }
32
- const languagesForImports = dependenciesInOrderOfDirectInheritance === false
33
- ? languages
34
- : dependenciesInOrderOfDirectInheritance
35
- .filter((language) => languages.indexOf(language) > -1)
33
+ const languagesForImports =
34
+ dependenciesInOrderOfDirectInheritance === false
35
+ ? languages
36
+ : dependenciesInOrderOfDirectInheritance.filter(language => languages.indexOf(language) > -1)
36
37
 
37
38
  return asString([
38
39
  options.header === undefined ? [] : [options.header, ``],
39
40
  `import {ILanguageBase, LionCore_builtinsBase} from "${options.genericImportLocation}";`,
40
41
  ``,
41
- languagesForImports.map((language) => `import * as ${importRenamingForLanguage(language)} from "./${language.name}.g.js";`),
42
+ languagesForImports.map(language => `import * as ${importRenamingForLanguage(language)} from "./${language.name}.g.js";`),
42
43
  ``,
43
44
  `// ensure that all languages get wired up by triggering that through their first entity:`,
44
45
  `LionCore_builtinsBase.INSTANCE.String;`,
45
46
  languages
46
- .filter(({entities}) => entities.length > 0)
47
- .map((language) => `${importRenamingForLanguage(language)}.${nameOfBaseClassForLanguage(language)}.INSTANCE.${language.entities[0].name};`),
47
+ .filter(({ entities }) => entities.length > 0)
48
+ .map(
49
+ language =>
50
+ `${importRenamingForLanguage(language)}.${nameOfBaseClassForLanguage(language)}.INSTANCE.${language.entities[0].name};`
51
+ ),
48
52
  ``,
49
53
  `export const allLanguageBases: ILanguageBase[] = [`,
50
- indent(commaSeparated(languagesForImports.map((language) => `${importRenamingForLanguage(language)}.${nameOfBaseClassForLanguage(language)}.INSTANCE`))),
54
+ indent(
55
+ commaSeparated(
56
+ languagesForImports.map(
57
+ language => `${importRenamingForLanguage(language)}.${nameOfBaseClassForLanguage(language)}.INSTANCE`
58
+ )
59
+ )
60
+ ),
51
61
  `];`,
52
62
  ``,
53
63
  `export {`,
package/src/api/index.ts CHANGED
@@ -15,7 +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 {generateLanguage, generateApiFromLanguages, generateApiFromLanguagesJson} from "./generator.js"
18
+ export { generateLanguage, generateApiFromLanguages, generateApiFromLanguagesJson } from "./generator.js"
19
19
  export * from "./generation-headers.js"
20
- export * from "./helpers/mps-annotations.js"
21
20
  export * from "./mega-factory.templates.js"
@@ -15,25 +15,19 @@
15
15
  // SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
16
16
  // SPDX-License-Identifier: Apache-2.0
17
17
 
18
- import {Concept, groupBy, Language} from "@lionweb/core"
19
- import {asString, commaSeparated, when, withNewlineAppended} from "littoral-templates"
20
-
21
- import {typeForLanguageEntity} from "./entity-types.templates.js"
22
- import {reflectiveClassFor} from "./reflective-layer.templates.js"
23
- import {indent} from "../utils/textgen.js"
24
- import {sortedStringsByUppercase} from "../utils/string-sorting.js"
25
- import {dependencyOrderOf} from "../utils/toposort.js"
26
- import {Imports} from "./helpers/index.js"
27
- import {GeneratorOptions} from "./generator.js"
18
+ import { sortedStringsByUppercase } from "@lionweb/ts-utils"
19
+ import { Concept, Language } from "@lionweb/core"
20
+ import { dependencyOrderOf } from "@lionweb/ts-utils"
21
+ import { asString, commaSeparated, when, withNewlineAppended } from "littoral-templates"
22
+ import { indent } from "../utils/textgen.js"
28
23
 
24
+ import { typeForLanguageEntity } from "./entity-types.templates.js"
25
+ import { GeneratorOptions } from "./generator.js"
26
+ import { Imports } from "./helpers/index.js"
27
+ import { reflectiveClassFor } from "./reflective-layer.templates.js"
29
28
 
30
29
  const importStatement = (dep: string, items: string[]) =>
31
- when(items.length > 0)([
32
- `import {`,
33
- indent(commaSeparated(sortedStringsByUppercase(items))),
34
- `} from "${dep}";`,
35
- ``
36
- ])
30
+ when(items.length > 0)([`import {`, indent(commaSeparated(sortedStringsByUppercase(items))), `} from "${dep}";`, ``])
37
31
 
38
32
 
39
33
  export const languageFileFor = (language: Language, options: GeneratorOptions) => {
@@ -47,8 +41,6 @@ export const languageFileFor = (language: Language, options: GeneratorOptions) =
47
41
  throw new Error(`language ${name} has a cycle among the graph of entities with edges formed by the inheritance dependency`)
48
42
  }
49
43
 
50
- const mpsAnnotationsPerId = groupBy(options.mpsAnnotations, ({annotatedNodeId}) => annotatedNodeId)
51
-
52
44
  const postImportsPart = [
53
45
  ``,
54
46
  reflectiveClassFor(imports)(language),
@@ -56,7 +48,7 @@ export const languageFileFor = (language: Language, options: GeneratorOptions) =
56
48
  ``,
57
49
  orderedEntities
58
50
  .filter((entity) => entity.language === language)
59
- .map(withNewlineAppended(typeForLanguageEntity(imports, mpsAnnotationsPerId)))
51
+ .map(withNewlineAppended(typeForLanguageEntity(imports)))
60
52
  ]
61
53
 
62
54
  return asString([
@@ -71,6 +63,7 @@ export const languageFileFor = (language: Language, options: GeneratorOptions) =
71
63
  ``,
72
64
  ``,
73
65
  importStatement(`@lionweb/core`, imports.coreImports),
66
+ importStatement(`@lionweb/json`, imports.jsonImports),
74
67
  importStatement(options.genericImportLocation, imports.genericImports),
75
68
  importStatement(`./index.g.js`, imports.languageImports),
76
69
  postImportsPart
@@ -15,46 +15,42 @@
15
15
  // SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
16
16
  // SPDX-License-Identifier: Apache-2.0
17
17
 
18
- import {isConcrete, Language, LanguageEntity} from "@lionweb/core"
19
- import {asString, commaSeparated} from "littoral-templates"
18
+ import { isConcrete, Language, LanguageEntity } from "@lionweb/core"
19
+ import { asString, commaSeparated } from "littoral-templates"
20
20
 
21
- import {asJSIdentifier, indent} from "../utils/textgen.js"
22
- import {Deprecated, MpsAnnotation} from "./helpers/index.js";
21
+ import { asJSIdentifier, indent } from "../utils/textgen.js"
22
+ import { Deprecated, ioLionWebMpsSpecificAnnotationsFrom } from "@lionweb/io-lionweb-mps-specific"
23
23
 
24
+ export const megaFactoryFor = (megaFactoryName: string, languages: Language[], header?: string) => {
25
+ const isNotDeprecated = (entity: LanguageEntity) =>
26
+ !ioLionWebMpsSpecificAnnotationsFrom(entity).some((annotation) => annotation instanceof Deprecated)
24
27
 
25
- export const megaFactoryFor = (megaFactoryName: string, languages: Language[], mpsAnnotations: MpsAnnotation[] = [], header?: string) => {
26
- const isNotDeprecated = (entity: LanguageEntity)=>
27
- !mpsAnnotations.some(
28
- (mpsAnnotation) => mpsAnnotation.annotatedNodeId === entity.id && mpsAnnotation instanceof Deprecated
29
- )
30
-
31
- const requiresFactoryMethod = (entity: LanguageEntity) =>
32
- isConcrete(entity) && isNotDeprecated(entity)
28
+ const requiresFactoryMethod = (entity: LanguageEntity) => isConcrete(entity) && isNotDeprecated(entity)
33
29
 
34
30
  const factoryFor = (language: Language) => [
35
31
  `${asJSIdentifier(language.name)}Factory = {`,
36
- indent(commaSeparated(
37
- language.entities
38
- .filter(requiresFactoryMethod)
39
- .map((classifier) => `create${classifier.name}: () => ${asJSIdentifier(language.name)}.${classifier.name}.create(newId(), this.handleDelta)`)
40
- )),
32
+ indent(
33
+ commaSeparated(
34
+ language.entities
35
+ .filter(requiresFactoryMethod)
36
+ .map(
37
+ classifier =>
38
+ `create${classifier.name}: () => ${asJSIdentifier(language.name)}.${classifier.name}.create(newId(), this.handleDelta)`
39
+ )
40
+ )
41
+ ),
41
42
  `}`,
42
43
  ``
43
44
  ]
44
45
 
45
- const languagesWithFactoryMethods = languages
46
- .filter(
47
- (language) => language.entities.some(requiresFactoryMethod)
48
- )
46
+ const languagesWithFactoryMethods = languages.filter(language => language.entities.some(requiresFactoryMethod))
49
47
 
50
48
  return asString([
51
49
  header ?? [],
52
50
  `import {DeltaHandler} from "@lionweb/class-core";`,
53
51
  ``,
54
52
  `import {`,
55
- indent(commaSeparated(
56
- languagesWithFactoryMethods.map(({name}) => asJSIdentifier(name))
57
- )),
53
+ indent(commaSeparated(languagesWithFactoryMethods.map(({ name }) => asJSIdentifier(name)))),
58
54
  `} from "./index.g.js";`,
59
55
  ``,
60
56
  `import {newId} from "../index.js";`,
@@ -64,9 +60,7 @@ export const megaFactoryFor = (megaFactoryName: string, languages: Language[], m
64
60
  indent([
65
61
  ``,
66
62
  `constructor(`,
67
- indent([
68
- `public readonly handleDelta?: DeltaHandler`
69
- ]),
63
+ indent([`public readonly handleDelta?: DeltaHandler`]),
70
64
  `) {`,
71
65
  `}`,
72
66
  ``,
@@ -17,7 +17,6 @@
17
17
 
18
18
  import {
19
19
  Annotation,
20
- asArray,
21
20
  Classifier,
22
21
  Concept,
23
22
  Enumeration,
@@ -36,90 +35,70 @@ import {
36
35
  Property,
37
36
  SingleRef
38
37
  } from "@lionweb/core"
39
- import {when, withNewlineAppended} from "littoral-templates"
40
-
41
- import {indent, switchOrIf} from "../utils/textgen.js"
42
- import {entityMetaType, extendsFrom, Imports, nameOfBaseClassForLanguage} from "./helpers/index.js"
38
+ import { asArray } from "@lionweb/ts-utils"
39
+ import { when, withNewlineAppended } from "littoral-templates"
43
40
 
41
+ import { indent, switchOrIf } from "../utils/textgen.js"
42
+ import { entityMetaType, extendsFrom, Imports, nameOfBaseClassForLanguage } from "./helpers/index.js"
44
43
 
45
44
  export const reflectiveClassFor = (imports: Imports) => {
46
-
47
45
  // classifier:
48
46
 
49
47
  const reflectiveMembersForFeature = (feature: Feature) => {
50
- const {classifier, name, key, id, optional} = feature
48
+ const { classifier, name, key, id, optional } = feature
51
49
  const metaType = featureMetaType(feature)
52
50
  const qName = `${classifier.name}_${name}`
53
51
  return [
54
52
  `private readonly _${qName} = new ${imports.core(metaType)}(this._${classifier.name}, "${name}", "${key}", "${id}")${optional ? ".isOptional()" : ""}${isMultiple(feature) ? ".isMultiple()" : ""};`,
55
53
  // | core (2nd x) |
56
54
  `get ${qName}(): ${metaType} {`,
57
- indent([
58
- `this.ensureWiredUp();`,
59
- `return this._${qName};`
60
- ]),
55
+ indent([`this.ensureWiredUp();`, `return this._${qName};`]),
61
56
  `}`
62
57
  ]
63
58
  }
64
59
 
65
60
  const reflectiveMembersForClassifier = (classifier: Classifier) => {
66
- const {name, key, id, features} = classifier
61
+ const { name, key, id, features } = classifier
67
62
  const metaType = entityMetaType(classifier)
68
63
  return [
69
- `public readonly _${name} = new ${imports.core(metaType)}(this._language, "${name}", "${key}", "${id}"${classifier instanceof Concept ? (", " + classifier.abstract) : ""});`,
64
+ `public readonly _${name} = new ${imports.core(metaType)}(this._language, "${name}", "${key}", "${id}"${classifier instanceof Concept ? ", " + classifier.abstract : ""});`,
70
65
  // | core (2nd x) |
71
66
  `get ${name}(): ${metaType} {`,
72
- indent([
73
- `this.ensureWiredUp();`,
74
- `return this._${name};`
75
- ]),
67
+ indent([`this.ensureWiredUp();`, `return this._${name};`]),
76
68
  `}`,
77
69
  features.map(reflectiveMembersForFeature)
78
70
  ]
79
71
  }
80
72
 
73
+ // enumeration:
81
74
 
82
- // enumeration:
83
-
84
- const reflectiveMemberForEnumerationLiteral = ({enumeration, name, key, id}: EnumerationLiteral) => {
75
+ const reflectiveMemberForEnumerationLiteral = ({ enumeration, name, key, id }: EnumerationLiteral) => {
85
76
  const qName = `${enumeration.name}_${name}`
86
77
  return [
87
78
  `private readonly _${qName} = new ${imports.core("EnumerationLiteral")}(this._${enumeration.name}, "${name}", "${key}", "${id}");`,
88
79
  // | core (2nd x) |
89
80
  `get ${qName}(): EnumerationLiteral {`,
90
- indent([
91
- `this.ensureWiredUp();`,
92
- `return this._${qName};`
93
- ]),
81
+ indent([`this.ensureWiredUp();`, `return this._${qName};`]),
94
82
  `}`
95
83
  ]
96
84
  }
97
85
 
98
- const reflectiveMembersForEnumeration = ({name, key, id, literals}: Enumeration) =>
99
- [
100
- `public readonly _${name} = new ${imports.core("Enumeration")}(this._language, "${name}", "${key}", "${id}");`,
101
- // | core (2nd x) |
102
- `get ${name}(): Enumeration {`,
103
- indent([
104
- `this.ensureWiredUp();`,
105
- `return this._${name};`
106
- ]),
107
- `}`,
108
- literals.map(reflectiveMemberForEnumerationLiteral)
109
- ]
110
-
111
- const reflectiveMembersForPrimitiveType = ({name, key, id}: PrimitiveType) =>
112
- [
113
- `public readonly _${name} = new ${imports.core("PrimitiveType")}(this._language, "${name}", "${key}", "${id}");`,
114
- // | core (2nd x) |
115
- `get ${name}(): PrimitiveType {`,
116
- indent([
117
- `this.ensureWiredUp();`,
118
- `return this._${name};`
119
- ]),
120
- `}`
121
- ]
122
-
86
+ const reflectiveMembersForEnumeration = ({ name, key, id, literals }: Enumeration) => [
87
+ `public readonly _${name} = new ${imports.core("Enumeration")}(this._language, "${name}", "${key}", "${id}");`,
88
+ // | core (2nd x) |
89
+ `get ${name}(): Enumeration {`,
90
+ indent([`this.ensureWiredUp();`, `return this._${name};`]),
91
+ `}`,
92
+ literals.map(reflectiveMemberForEnumerationLiteral)
93
+ ]
94
+
95
+ const reflectiveMembersForPrimitiveType = ({ name, key, id }: PrimitiveType) => [
96
+ `public readonly _${name} = new ${imports.core("PrimitiveType")}(this._language, "${name}", "${key}", "${id}");`,
97
+ // | core (2nd x) |
98
+ `get ${name}(): PrimitiveType {`,
99
+ indent([`this.ensureWiredUp();`, `return this._${name};`]),
100
+ `}`
101
+ ]
123
102
 
124
103
  const reflectiveMembersForEntity = (entity: LanguageEntity) => {
125
104
  if (entity instanceof Classifier) {
@@ -134,7 +113,6 @@ export const reflectiveClassFor = (imports: Imports) => {
134
113
  return `// unhandled language entity <${entityMetaType(entity)}>"${entity.name}"`
135
114
  }
136
115
 
137
-
138
116
  const refForType = (type: SingleRef<LanguageEntity>) => {
139
117
  if (type === null) {
140
118
  return `???`
@@ -146,12 +124,12 @@ export const reflectiveClassFor = (imports: Imports) => {
146
124
  }
147
125
 
148
126
  const wireUpStatementsForProperty = (property: Property) => {
149
- const {classifier, name, type, optional} = property
127
+ const { classifier, name, type, optional } = property
150
128
  return `this._${classifier.name}_${name}.ofType(${refForType(type)})${optional ? ".isOptional()" : ""};`
151
129
  }
152
130
 
153
131
  const wireUpStatementsForLink = (link: Link) => {
154
- const {classifier, name, type} = link
132
+ const { classifier, name, type } = link
155
133
  return `this._${classifier.name}_${name}.ofType(${refForType(type)});`
156
134
  }
157
135
 
@@ -165,23 +143,24 @@ export const reflectiveClassFor = (imports: Imports) => {
165
143
  return `// unhandled feature <${featureMetaType(feature)}>"${feature.name}"`
166
144
  }
167
145
 
168
- const isConcreteClassifier = (classifier: Classifier): classifier is (Annotation | Concept) =>
146
+ const isConcreteClassifier = (classifier: Classifier): classifier is Annotation | Concept =>
169
147
  classifier instanceof Annotation || classifier instanceof Concept
170
148
 
171
149
  const wireUpStatementsForEntity = (entity: LanguageEntity) => {
172
- const {name} = entity
150
+ const { name } = entity
173
151
  const thisLocalName = (localName: string) => `this._${name}_${localName}`
174
152
  if (entity instanceof Classifier) {
175
153
  const extends_ = extendsFrom(entity)
176
154
  return [
177
- extends_ instanceof Classifier
178
- ? `this._${name}.extends = ${refForType(extends_)};`
179
- : [],
155
+ extends_ instanceof Classifier ? `this._${name}.extends = ${refForType(extends_)};` : [],
180
156
  when(entity instanceof Interface && entity.extends.length > 0)(
181
- () => `this._${name}.extending(${(entity as Interface).extends.map((interface_) => refForType(interface_)).join(", ")});`
157
+ () => `this._${name}.extending(${(entity as Interface).extends.map(interface_ => refForType(interface_)).join(", ")});`
182
158
  ),
183
159
  when(isConcreteClassifier(entity) && entity.implements.length > 0)(
184
- () => `this._${name}.implementing(${asArray((entity as (Annotation | Concept)).implements).map((interface_) => refForType(interface_)).join(", ")});`
160
+ () =>
161
+ `this._${name}.implementing(${asArray((entity as Annotation | Concept).implements)
162
+ .map(interface_ => refForType(interface_))
163
+ .join(", ")});`
185
164
  ),
186
165
  when(entity.features.length > 0)(
187
166
  `this._${name}.havingFeatures(${entity.features.map(nameOf).map(thisLocalName).join(", ")});`
@@ -193,13 +172,13 @@ export const reflectiveClassFor = (imports: Imports) => {
193
172
  return `this._${name}.havingLiterals(${entity.literals.map(nameOf).map(thisLocalName).join(", ")});`
194
173
  }
195
174
  if (entity instanceof PrimitiveType) {
196
- return [] // (nothing to do)
175
+ return [] // (nothing to do)
197
176
  }
198
177
  return `// unhandled language entity <${entityMetaType(entity)}>"${name}"`
199
178
  }
200
179
 
201
180
  return (language: Language) => {
202
- const {version, id, key, entities} = language
181
+ const { version, id, key, entities } = language
203
182
  const enumerations = entities.filter(isEnumeration)
204
183
  const concreteClassifiers = entities.filter(isConcrete)
205
184
  const parameterPrefix = concreteClassifiers.length === 0 ? "_" : ""
@@ -212,10 +191,7 @@ export const reflectiveClassFor = (imports: Imports) => {
212
191
  `private readonly _language: ${imports.core("Language")} = new Language("${imports.thisLanguageNameAsJsIdentifier}", "${version}", "${id}", "${key}");`,
213
192
  // | core | (3rd x)
214
193
  `get language(): Language {`,
215
- indent([
216
- `this.ensureWiredUp();`,
217
- `return this._language;`
218
- ]),
194
+ indent([`this.ensureWiredUp();`, `return this._language;`]),
219
195
  `}`,
220
196
  ``,
221
197
  entities.map(withNewlineAppended(reflectiveMembersForEntity)),
@@ -233,11 +209,13 @@ export const reflectiveClassFor = (imports: Imports) => {
233
209
  ``,
234
210
  `factory(${parameterPrefix}handleDelta?: ${imports.generic("DeltaHandler")}): ${imports.generic("NodeBaseFactory")} {`,
235
211
  indent([
236
- `return (classifier: ${imports.core("Classifier")}, ${parameterPrefix}id: ${imports.core("Id")}) => {`,
212
+ `return (classifier: ${imports.core("Classifier")}, ${parameterPrefix}id: ${imports.json("LionWebId")}) => {`,
237
213
  indent(
238
214
  switchOrIf(
239
215
  "classifier.key",
240
- concreteClassifiers.map(nameOf).map((name) => [`this._${name}.key`, `${name}.create(id, ${parameterPrefix}handleDelta)`]),
216
+ concreteClassifiers
217
+ .map(nameOf)
218
+ .map(name => [`this._${name}.key`, `${name}.create(id, ${parameterPrefix}handleDelta)`]),
241
219
  [
242
220
  `const {language} = classifier;`,
243
221
  `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})\`);`
@@ -254,7 +232,7 @@ export const reflectiveClassFor = (imports: Imports) => {
254
232
  `const {enumeration} = enumerationLiteral;`,
255
233
  switchOrIf(
256
234
  "enumeration.key",
257
- enumerations.map(nameOf).map((name) => [`this._${name}.key`, "enumerationLiteral.key as EnumType"]),
235
+ enumerations.map(nameOf).map(name => [`this._${name}.key`, "enumerationLiteral.key as EnumType"]),
258
236
  [
259
237
  `const {language} = enumeration;`,
260
238
  `throw new Error(\`enumeration with key \${enumeration.key} is not known in language \${language.name} (key=\${language.key}, version=\${language.version})\`);`
@@ -268,6 +246,5 @@ export const reflectiveClassFor = (imports: Imports) => {
268
246
  `}`
269
247
  ]
270
248
  }
271
-
272
249
  }
273
250
 
@@ -16,6 +16,5 @@
16
16
  // SPDX-License-Identifier: Apache-2.0
17
17
 
18
18
  export {asTypeScript} from "./json-as-ts.js"
19
- export {sortedStrings, sortedStringsByUppercase} from "./string-sorting.js"
20
19
  export {indent} from "./textgen.js"
21
20
 
@@ -21,7 +21,7 @@
21
21
  */
22
22
 
23
23
 
24
- import {asString, indentWith, Template} from "littoral-templates"
24
+ import { asString, indentWith, Template } from "littoral-templates"
25
25
 
26
26
 
27
27
  /**
@@ -1,19 +0,0 @@
1
- import { Id, SerializationChunk } from "@lionweb/core";
2
- export declare abstract class MpsAnnotation {
3
- readonly annotatedNodeId: Id;
4
- constructor(annotatedNodeId: Id);
5
- }
6
- export declare class ConceptDescription extends MpsAnnotation {
7
- readonly shortDescription: string | null;
8
- readonly alias: string | null;
9
- constructor(annotatedNodeId: Id, shortDescription: string | null, alias: string | null);
10
- toString(): string;
11
- }
12
- export declare class Deprecated extends MpsAnnotation {
13
- readonly comment: string | null;
14
- readonly build: string | null;
15
- constructor(annotatedNodeId: Id, comment: string | null, build: string | null);
16
- toString(): string;
17
- }
18
- export declare const extractedMpsAnnotations: ({ nodes }: SerializationChunk) => MpsAnnotation[];
19
- //# sourceMappingURL=mps-annotations.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mps-annotations.d.ts","sourceRoot":"","sources":["../../../src/api/helpers/mps-annotations.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAC,EAAE,EAAE,kBAAkB,EAAC,MAAM,eAAe,CAAA;AAGpD,8BAAsB,aAAa;aACH,eAAe,EAAE,EAAE;gBAAnB,eAAe,EAAE,EAAE;CAElD;AAED,qBAAa,kBAAmB,SAAQ,aAAa;aACA,gBAAgB,EAAE,MAAM,GAAG,IAAI;aAAkB,KAAK,EAAE,MAAM,GAAG,IAAI;gBAA1G,eAAe,EAAE,EAAE,EAAkB,gBAAgB,EAAE,MAAM,GAAG,IAAI,EAAkB,KAAK,EAAE,MAAM,GAAG,IAAI;IAGtH,QAAQ;CAGX;AAED,qBAAa,UAAW,SAAQ,aAAa;aACQ,OAAO,EAAE,MAAM,GAAG,IAAI;aAAkB,KAAK,EAAE,MAAM,GAAG,IAAI;gBAAjG,eAAe,EAAE,EAAE,EAAkB,OAAO,EAAE,MAAM,GAAG,IAAI,EAAkB,KAAK,EAAE,MAAM,GAAG,IAAI;IAG7G,QAAQ;CAGX;AAGD,eAAO,MAAM,uBAAuB,cAAa,kBAAkB,KAAG,aAAa,EAuB7E,CAAA"}
@@ -1,65 +0,0 @@
1
- // Copyright 2025 TRUMPF Laser SE and other contributors
2
- //
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
17
- export class MpsAnnotation {
18
- constructor(annotatedNodeId) {
19
- this.annotatedNodeId = annotatedNodeId;
20
- }
21
- }
22
- export class ConceptDescription extends MpsAnnotation {
23
- constructor(annotatedNodeId, shortDescription, alias) {
24
- super(annotatedNodeId);
25
- this.shortDescription = shortDescription;
26
- this.alias = alias;
27
- }
28
- toString() {
29
- return `<ConceptDescription> annotatedNodeId=${this.annotatedNodeId}, shortDescription="${this.shortDescription}"`;
30
- }
31
- }
32
- export class Deprecated extends MpsAnnotation {
33
- constructor(annotatedNodeId, comment, build) {
34
- super(annotatedNodeId);
35
- this.comment = comment;
36
- this.build = build;
37
- }
38
- toString() {
39
- return `<Deprecated> annotatedNodeId=${this.annotatedNodeId}, comment="${this.comment}", build="${this.build}"`;
40
- }
41
- }
42
- export const extractedMpsAnnotations = ({ nodes }) => nodes.flatMap(({ classifier, properties, parent }) => {
43
- const propertyValue = (key) => {
44
- const property = properties.find(({ property }) => property.key === key);
45
- return property === undefined
46
- ? null
47
- : property.value;
48
- };
49
- if (classifier.language !== "io-lionweb-mps-specific" || classifier.version !== "0") {
50
- return [];
51
- }
52
- switch (classifier.key) {
53
- case "ConceptDescription": {
54
- return [new ConceptDescription(parent, propertyValue("ConceptDescription-conceptShortDescription"), propertyValue("ConceptDescription-conceptAlias"))];
55
- }
56
- case "Deprecated": {
57
- return [new Deprecated(parent, propertyValue("Deprecated-comment"), propertyValue("Deprecated-build"))];
58
- }
59
- default: {
60
- console.log(`couldn't handle MPS annotation with key ${classifier.key}`);
61
- return [];
62
- }
63
- }
64
- });
65
- //# sourceMappingURL=mps-annotations.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mps-annotations.js","sourceRoot":"","sources":["../../../src/api/helpers/mps-annotations.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;AAKtC,MAAM,OAAgB,aAAa;IAC/B,YAA4B,eAAmB;QAAnB,oBAAe,GAAf,eAAe,CAAI;IAC/C,CAAC;CACJ;AAED,MAAM,OAAO,kBAAmB,SAAQ,aAAa;IACjD,YAAY,eAAmB,EAAkB,gBAA+B,EAAkB,KAAoB;QAClH,KAAK,CAAC,eAAe,CAAC,CAAA;QADuB,qBAAgB,GAAhB,gBAAgB,CAAe;QAAkB,UAAK,GAAL,KAAK,CAAe;IAEtH,CAAC;IACD,QAAQ;QACJ,OAAO,wCAAwC,IAAI,CAAC,eAAe,uBAAuB,IAAI,CAAC,gBAAgB,GAAG,CAAA;IACtH,CAAC;CACJ;AAED,MAAM,OAAO,UAAW,SAAQ,aAAa;IACzC,YAAY,eAAmB,EAAkB,OAAsB,EAAkB,KAAoB;QACzG,KAAK,CAAC,eAAe,CAAC,CAAA;QADuB,YAAO,GAAP,OAAO,CAAe;QAAkB,UAAK,GAAL,KAAK,CAAe;IAE7G,CAAC;IACD,QAAQ;QACJ,OAAO,gCAAgC,IAAI,CAAC,eAAe,cAAc,IAAI,CAAC,OAAO,aAAa,IAAI,CAAC,KAAK,GAAG,CAAA;IACnH,CAAC;CACJ;AAGD,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,EAAC,KAAK,EAAqB,EAAmB,EAAE,CACpF,KAAK,CAAC,OAAO,CAAgB,CAAC,EAAC,UAAU,EAAE,UAAU,EAAE,MAAM,EAAC,EAAE,EAAE;IAC9D,MAAM,aAAa,GAAG,CAAC,GAAW,EAAiB,EAAE;QACjD,MAAM,QAAQ,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,EAAC,QAAQ,EAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,KAAK,GAAG,CAAC,CAAA;QACtE,OAAO,QAAQ,KAAK,SAAS;YACzB,CAAC,CAAC,IAAI;YACN,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAA;IACxB,CAAC,CAAA;IACD,IAAI,UAAU,CAAC,QAAQ,KAAK,yBAAyB,IAAI,UAAU,CAAC,OAAO,KAAK,GAAG,EAAE,CAAC;QAClF,OAAO,EAAE,CAAA;IACb,CAAC;IACD,QAAQ,UAAU,CAAC,GAAG,EAAE,CAAC;QACrB,KAAK,oBAAoB,CAAC,CAAC,CAAC;YACxB,OAAO,CAAC,IAAI,kBAAkB,CAAC,MAAO,EAAE,aAAa,CAAC,4CAA4C,CAAC,EAAE,aAAa,CAAC,iCAAiC,CAAC,CAAC,CAAC,CAAA;QAC3J,CAAC;QACD,KAAK,YAAY,CAAC,CAAC,CAAC;YAChB,OAAO,CAAC,IAAI,UAAU,CAAC,MAAO,EAAE,aAAa,CAAC,oBAAoB,CAAC,EAAE,aAAa,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAA;QAC5G,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,2CAA2C,UAAU,CAAC,GAAG,EAAE,CAAC,CAAA;YACxE,OAAO,EAAE,CAAA;QACb,CAAC;IACL,CAAC;AACL,CAAC,CAAC,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/api/helpers/types.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAoB,aAAa,EAAC,MAAM,eAAe,CAAA;AAG9D,eAAO,MAAM,sBAAsB,kBAAmB,aAAa,KAAG,MASrE,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/api/helpers/types.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,EAAC,iBAAiB,EAAgB,MAAM,eAAe,CAAA;AAG9D,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,aAA4B,EAAU,EAAE;IAC3E,QAAQ,aAAa,EAAE,CAAC;QACpB,KAAK,iBAAiB,CAAC,eAAe,CAAC,CAAC,OAAO,SAAS,CAAA;QACxD,KAAK,iBAAiB,CAAC,cAAc,CAAC,CAAC,OAAO,QAAQ,CAAA;QACtD,KAAK,iBAAiB,CAAC,eAAe,CAAC,CAAC,OAAO,QAAQ,CAAA;QACvD,KAAK,iBAAiB,CAAC,YAAY,CAAC,CAAC,OAAO,SAAS,CAAA;QACrD;YACI,OAAO,QAAQ,CAAA;IACvB,CAAC;AACL,CAAC,CAAA"}
@@ -1,4 +0,0 @@
1
- export type StringSorter = (strings: string[]) => string[];
2
- export declare const sortedStrings: StringSorter;
3
- export declare const sortedStringsByUppercase: StringSorter;
4
- //# sourceMappingURL=string-sorting.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"string-sorting.d.ts","sourceRoot":"","sources":["../../src/utils/string-sorting.ts"],"names":[],"mappings":"AAiBA,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,MAAM,EAAE,CAAA;AAQ1D,eAAO,MAAM,aAAa,cAAkC,CAAA;AAE5D,eAAO,MAAM,wBAAwB,cAAgD,CAAA"}
@@ -1,23 +0,0 @@
1
- // Copyright 2025 TRUMPF Laser SE and other contributors
2
- //
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
17
- const sortedStringsWith = (strMap) => (strings) => {
18
- strings.sort((l, r) => strMap(l).localeCompare(strMap(r)));
19
- return strings;
20
- };
21
- export const sortedStrings = sortedStringsWith((str) => str);
22
- export const sortedStringsByUppercase = sortedStringsWith((str) => str.toUpperCase());
23
- //# sourceMappingURL=string-sorting.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"string-sorting.js","sourceRoot":"","sources":["../../src/utils/string-sorting.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;AAItC,MAAM,iBAAiB,GAAG,CAAC,MAA+B,EAAgB,EAAE,CACxE,CAAC,OAAO,EAAE,EAAE;IACR,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAC1D,OAAO,OAAO,CAAA;AAClB,CAAC,CAAA;AAEL,MAAM,CAAC,MAAM,aAAa,GAAG,iBAAiB,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,CAAA;AAE5D,MAAM,CAAC,MAAM,wBAAwB,GAAG,iBAAiB,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAA"}
@@ -1,6 +0,0 @@
1
- /**
2
- * Computes the topological order of the transitive closure of the graph with the given vertices and edges given by the edge function,
3
- * or returns {@code false} if there's a cycle.
4
- */
5
- export declare const dependencyOrderOf: <T>(vertices: T[], edgesOf: (vertex: T) => T[]) => false | T[];
6
- //# sourceMappingURL=toposort.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"toposort.d.ts","sourceRoot":"","sources":["../../src/utils/toposort.ts"],"names":[],"mappings":"AAiBA;;;GAGG;AACH,eAAO,MAAM,iBAAiB,gEA0B7B,CAAA"}