@lionweb/io-lionweb-mps-specific 0.7.0-alpha.6 → 0.7.0-alpha.8
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/README.md +15 -3
- package/dist/annotations.d.ts +2 -2
- package/dist/annotations.d.ts.map +1 -1
- package/dist/annotations.js.map +1 -1
- package/dist/facade.js +2 -2
- package/dist/facade.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/textualizer.d.ts +8 -0
- package/dist/textualizer.d.ts.map +1 -0
- package/dist/textualizer.js +187 -0
- package/dist/textualizer.js.map +1 -0
- package/meta/io.lionweb.mps.specific.md +35 -0
- package/meta/io.lionweb.mps.specific.puml +39 -0
- package/package.json +5 -4
- /package/{io.lionweb.mps.specific.json → meta/io.lionweb.mps.specific.json} +0 -0
- /package/{io.lionweb.mps.specific.txt → meta/io.lionweb.mps.specific.txt} +0 -0
package/README.md
CHANGED
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
](https://www.npmjs.com/package/@lionweb/io-lionweb-mps-specific)
|
|
9
9
|
|
|
10
10
|
This NPM package contains an implementation of the `io.lionweb.mps.specific` language.
|
|
11
|
-
The MPS implementation of that language is part of the `lionweb-mps` plug-in.
|
|
12
|
-
|
|
11
|
+
The MPS implementation of that language is part of [the `lionweb-mps` plug-in](https://github.com/LionWeb-io/lionweb-mps/tree/mps2021.3).
|
|
12
|
+
The annotations in this language are used to export MPS-specific language (structure) metadata as part of LionWeb language exports from MPS (in the LionCore M3 format).
|
|
13
13
|
More specifically, this pertains to metadata like the *alias*, *short description*, *documentation*, etc., of a language concept.
|
|
14
14
|
|
|
15
15
|
It can be added to a TypeScript codebase as follows:
|
|
@@ -18,5 +18,17 @@ It can be added to a TypeScript codebase as follows:
|
|
|
18
18
|
$ npm add @lionweb/io-lionweb-mps-specific
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
## API
|
|
22
|
+
|
|
23
|
+
The API consists of the following things exported from this package:
|
|
24
|
+
|
|
25
|
+
* The _implementation_ of the language consists of the following classes: `ConceptDescription`, `Deprecated`, `KeyedDescription`, `ShortDescription`, `VirtualPackage`.
|
|
26
|
+
Also see [this PlantUml diagram](meta/io.lionweb.mps.specific.puml) for some more information.
|
|
27
|
+
* The language is _defined_ through the constant `ioLionWebMpsSpecificLanguage` (of type `Language`).
|
|
28
|
+
Its classifiers are exported separately through the `ioLionWebMpsSpecificClassifiers` dictionary.
|
|
29
|
+
* The `deserializeLanguagesWithIoLionWebMpsSpecific` function deserializes a LionWeb serialization chunk as an array of `Language`s, potentially being annotated with instances of annotations from the `io.lionweb.mps.specific` language.
|
|
30
|
+
* The `ioLionWebMpsSpecificAnnotationsFrom` function returns the (instances of the) `io.lionweb.mps.specific` language's annotations that annotate the given language element (of type `M3Concept`).
|
|
31
|
+
* The `textualizationOfAnnotationsIn` function renders an textualization of all instances of `io.lionweb.mps.specific` annotations, in the given languages' tree structure.
|
|
32
|
+
**Note**: only language elements having annotations (at any nesting depth) are rendered.
|
|
33
|
+
This is useful to get a quick overview of the annotations.
|
|
22
34
|
|
package/dist/annotations.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { M3Concept } from "@lionweb/core";
|
|
2
2
|
import { IoLionWebMpsSpecificAnnotation } from "./implementation.js";
|
|
3
3
|
/**
|
|
4
4
|
* @return the `io.lionweb.mps.specific` annotations present on the given node.
|
|
5
5
|
*/
|
|
6
|
-
export declare const ioLionWebMpsSpecificAnnotationsFrom: (node:
|
|
6
|
+
export declare const ioLionWebMpsSpecificAnnotationsFrom: (node: M3Concept) => IoLionWebMpsSpecificAnnotation[];
|
|
7
7
|
//# sourceMappingURL=annotations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotations.d.ts","sourceRoot":"","sources":["../src/annotations.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"annotations.d.ts","sourceRoot":"","sources":["../src/annotations.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACzC,OAAO,EAAE,8BAA8B,EAAE,MAAM,qBAAqB,CAAA;AAEpE;;GAEG;AACH,eAAO,MAAM,mCAAmC,SAAU,SAAS,KAAG,8BAA8B,EAGqB,CAAA"}
|
package/dist/annotations.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotations.js","sourceRoot":"","sources":["../src/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;AAGtC,OAAO,EAAE,8BAA8B,EAAE,MAAM,qBAAqB,CAAA;AAEpE;;GAEG;AACH,MAAM,CAAC,MAAM,mCAAmC,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"annotations.js","sourceRoot":"","sources":["../src/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;AAGtC,OAAO,EAAE,8BAA8B,EAAE,MAAM,qBAAqB,CAAA;AAEpE;;GAEG;AACH,MAAM,CAAC,MAAM,mCAAmC,GAAG,CAAC,IAAe,EAAoC,EAAE,CACrG,IAAI;KACC,WAAW;KACX,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,YAAY,8BAA8B,CAAqC,CAAA"}
|
package/dist/facade.js
CHANGED
|
@@ -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 { areSameClassifiers, areSameLanguages, lioncore,
|
|
17
|
+
import { areSameClassifiers, areSameLanguages, lioncore, lioncoreWriter, updateSettingsNameBased } from "@lionweb/core";
|
|
18
18
|
import { ioLionWebMpsSpecificClassifiers, ioLionWebMpsSpecificLanguage } from "./definition.js";
|
|
19
19
|
import { ConceptDescription, Deprecated, KeyedDescription, ShortDescription, VirtualPackage } from "./implementation.js";
|
|
20
20
|
const ioLionWebMpsSpecificFactory = (parent, classifier, id, propertySettings) => {
|
|
@@ -62,7 +62,7 @@ export const combinedWriter = {
|
|
|
62
62
|
return ioLionWebMpsSpecificFactory(parent, classifier, id, propertySettings);
|
|
63
63
|
}
|
|
64
64
|
if (areSameLanguages(classifier.language, lioncore)) {
|
|
65
|
-
return
|
|
65
|
+
return lioncoreWriter.nodeFor(parent, classifier, id, propertySettings);
|
|
66
66
|
}
|
|
67
67
|
throw new Error(`don't know how to instantiate a ${classifier.name} from language ${classifier.language.name} (${classifier.language.key}, ${classifier.language.version})`);
|
|
68
68
|
},
|
package/dist/facade.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"facade.js","sourceRoot":"","sources":["../src/facade.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,gBAAgB,EAGhB,QAAQ,EAC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9F,UAAU,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,SAAS,EAAK,2EAA2E;IACnH,OAAO,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE,EAAE,gBAAgB,EAAE,EAAE;QAClD,IAAI,gBAAgB,CAAC,UAAU,CAAC,QAAQ,EAAE,4BAA4B,CAAC,EAAE,CAAC;YACtE,OAAO,2BAA2B,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE,EAAE,gBAAgB,CAAC,CAAA;QAChF,CAAC;QACD,IAAI,gBAAgB,CAAC,UAAU,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,CAAC;YAClD,OAAO,cAAc,CAAC,OAAO,CAAC,MAAmB,EAAE,UAAU,EAAE,EAAE,EAAE,gBAAgB,CAAC,CAAA;QACxF,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,mCAAmC,UAAU,CAAC,IAAI,kBAAkB,UAAU,CAAC,QAAQ,CAAC,IAAI,KAAK,UAAU,CAAC,QAAQ,CAAC,GAAG,KAAK,UAAU,CAAC,QAAQ,CAAC,OAAO,GAAG,CAAC,CAAA;IAChL,CAAC;IACD,eAAe,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE;QACtC,uBAAuB,CAAC,IAA0C,EAAE,OAAO,EAAE,KAAK,CAAC,CAAA;IACvF,CAAC;CACJ,CAAA"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAiBA,cAAc,kBAAkB,CAAA;AAChC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,mBAAmB,CAAA;AACjC,cAAc,qBAAqB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAiBA,cAAc,kBAAkB,CAAA;AAChC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,mBAAmB,CAAA;AACjC,cAAc,qBAAqB,CAAA;AACnC,cAAc,kBAAkB,CAAA"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.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,cAAc,kBAAkB,CAAA;AAChC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,mBAAmB,CAAA;AACjC,cAAc,qBAAqB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.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,cAAc,kBAAkB,CAAA;AAChC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,mBAAmB,CAAA;AACjC,cAAc,qBAAqB,CAAA;AACnC,cAAc,kBAAkB,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Language } from "@lionweb/core";
|
|
2
|
+
/**
|
|
3
|
+
* @return textualization of all instances of io.lionweb.mps.specific annotations, in the given languages' tree structure.
|
|
4
|
+
* **Note**: only language elements having annotations (at any nesting depth) are rendered.
|
|
5
|
+
* This is useful to get a quick overview of the annotations.
|
|
6
|
+
*/
|
|
7
|
+
export declare const textualizationOfAnnotationsIn: (languages: Language[]) => string;
|
|
8
|
+
//# sourceMappingURL=textualizer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"textualizer.d.ts","sourceRoot":"","sources":["../src/textualizer.ts"],"names":[],"mappings":"AAiBA,OAAO,EAKH,QAAQ,EAKX,MAAM,eAAe,CAAA;AAsMtB;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,cAAe,QAAQ,EAAE,KAAG,MACH,CAAA"}
|
|
@@ -0,0 +1,187 @@
|
|
|
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
|
+
import { Classifier, Enumeration, EnumerationLiteral, Feature, Language, LanguageEntity, PrimitiveType } from "@lionweb/core";
|
|
18
|
+
import { indent, withFirstLower } from "@lionweb/textgen-utils";
|
|
19
|
+
import { asString, when } from "littoral-templates";
|
|
20
|
+
import { ConceptDescription, Deprecated, KeyedDescription, ShortDescription, VirtualPackage } from "./implementation.js";
|
|
21
|
+
import { ioLionWebMpsSpecificAnnotationsFrom } from "./annotations.js";
|
|
22
|
+
/**
|
|
23
|
+
* @return human-readable text of the location/“path to” the given {@link Node node},
|
|
24
|
+
* which is *assumed* to be a language element – i.e., a {@link M3Concept}.
|
|
25
|
+
*/
|
|
26
|
+
const pathTo = (node) => {
|
|
27
|
+
if (node instanceof LanguageEntity) {
|
|
28
|
+
return `${withFirstLower(node.metaType())} ${node.name} in ${pathTo(node.language)}`;
|
|
29
|
+
}
|
|
30
|
+
if (node instanceof EnumerationLiteral) {
|
|
31
|
+
return `literal ${node.name} of ${pathTo(node.enumeration)}`;
|
|
32
|
+
}
|
|
33
|
+
if (node instanceof Feature) {
|
|
34
|
+
return `${withFirstLower(node.metaType())} ${node.name} of ${pathTo(node.classifier)}`;
|
|
35
|
+
}
|
|
36
|
+
if (node instanceof Language) {
|
|
37
|
+
return `language ${node.name}`;
|
|
38
|
+
}
|
|
39
|
+
throw new Error(`don't know how to handle an instance of ${node.constructor.name}`);
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* @return a textualization of the given io.lionweb.mps.specific annotation.
|
|
43
|
+
*/
|
|
44
|
+
const textualizationOfAnnotation = (annotation) => {
|
|
45
|
+
const textualizeProperty = (propertyName, displayName) => {
|
|
46
|
+
const value = annotation[propertyName];
|
|
47
|
+
return value === undefined
|
|
48
|
+
? undefined
|
|
49
|
+
: `${displayName}: ${value}`;
|
|
50
|
+
};
|
|
51
|
+
const textualizePropertiesWithDisplayNames = (properties) => Object.entries(properties)
|
|
52
|
+
.map(([displayName, propertyName]) => textualizeProperty(propertyName, displayName))
|
|
53
|
+
.filter((optStr) => optStr !== undefined);
|
|
54
|
+
const textualizeProperties = (...propertyNames) => propertyNames
|
|
55
|
+
.map((propertyName) => textualizeProperty(propertyName, propertyName))
|
|
56
|
+
.filter((optStr) => optStr !== undefined);
|
|
57
|
+
if (annotation instanceof ConceptDescription) {
|
|
58
|
+
const fragments = textualizePropertiesWithDisplayNames({ "short description": "conceptShortDescription", "alias": "conceptAlias", "help URL": "helpUrl" });
|
|
59
|
+
return fragments.length === 0
|
|
60
|
+
? `@ConceptDescription: (no info)`
|
|
61
|
+
: [
|
|
62
|
+
`@ConceptDescription:`,
|
|
63
|
+
indent(fragments)
|
|
64
|
+
];
|
|
65
|
+
}
|
|
66
|
+
if (annotation instanceof Deprecated) {
|
|
67
|
+
const fragments = textualizeProperties("comment", "build");
|
|
68
|
+
return fragments.length === 0
|
|
69
|
+
? `@Deprecated: (no info)`
|
|
70
|
+
: [
|
|
71
|
+
`@Deprecated:`,
|
|
72
|
+
indent(fragments)
|
|
73
|
+
];
|
|
74
|
+
}
|
|
75
|
+
if (annotation instanceof KeyedDescription) {
|
|
76
|
+
const fragments = textualizeProperties("documentation");
|
|
77
|
+
return (fragments.length === 0 && annotation.seeAlso.length === 0)
|
|
78
|
+
? `@KeyedDescription: (no info)`
|
|
79
|
+
: [
|
|
80
|
+
`@KeyedDescription: `,
|
|
81
|
+
indent([
|
|
82
|
+
fragments,
|
|
83
|
+
when(annotation.seeAlso.length > 0)([
|
|
84
|
+
`see also:`,
|
|
85
|
+
indent(annotation.seeAlso.map(pathTo))
|
|
86
|
+
])
|
|
87
|
+
])
|
|
88
|
+
];
|
|
89
|
+
}
|
|
90
|
+
if (annotation instanceof ShortDescription) {
|
|
91
|
+
const fragments = textualizeProperties("description");
|
|
92
|
+
return fragments.length === 0
|
|
93
|
+
? `@ShortDescription: (no info)`
|
|
94
|
+
: [
|
|
95
|
+
`@ShortDescription:`,
|
|
96
|
+
indent(fragments)
|
|
97
|
+
];
|
|
98
|
+
}
|
|
99
|
+
if (annotation instanceof VirtualPackage) {
|
|
100
|
+
const fragments = textualizeProperties("name");
|
|
101
|
+
return fragments.length === 0
|
|
102
|
+
? `@VirtualPackage: (no info)`
|
|
103
|
+
: [
|
|
104
|
+
`@VirtualPackage:`,
|
|
105
|
+
indent(fragments)
|
|
106
|
+
];
|
|
107
|
+
}
|
|
108
|
+
throw new Error(`don't know how to handle an instance of ${annotation.constructor.name}`);
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* @return textualization of the given {@link M3Concept language element} provided it either has (1 or more) annotations itself,
|
|
112
|
+
* or if any of its nested language elements – i.e.: descendants – have (1 or more) annotations.
|
|
113
|
+
* Otherwise, it returns an empty array `[]`.
|
|
114
|
+
*/
|
|
115
|
+
const textualizationOfAnnotationsInM3Concept = (node) => {
|
|
116
|
+
const annotations = ioLionWebMpsSpecificAnnotationsFrom(node);
|
|
117
|
+
if (node instanceof Classifier) {
|
|
118
|
+
const annotatedFeatures = node.features.flatMap((feature) => textualizationOfAnnotationsInM3Concept(feature));
|
|
119
|
+
return (annotations.length > 0 || annotatedFeatures.length > 0)
|
|
120
|
+
? [
|
|
121
|
+
`${withFirstLower(node.metaType())} ${node.name}:`,
|
|
122
|
+
indent([
|
|
123
|
+
annotations.map(textualizationOfAnnotation),
|
|
124
|
+
annotatedFeatures
|
|
125
|
+
])
|
|
126
|
+
]
|
|
127
|
+
: [];
|
|
128
|
+
}
|
|
129
|
+
if (node instanceof Enumeration) {
|
|
130
|
+
const annotatedLiterals = node.literals.flatMap((literal) => textualizationOfAnnotationsInM3Concept(literal));
|
|
131
|
+
return (annotations.length > 0 || annotatedLiterals.length > 0)
|
|
132
|
+
? [
|
|
133
|
+
`enumeration ${node.name}:`,
|
|
134
|
+
indent([
|
|
135
|
+
annotations.map(textualizationOfAnnotation),
|
|
136
|
+
annotatedLiterals
|
|
137
|
+
])
|
|
138
|
+
]
|
|
139
|
+
: [];
|
|
140
|
+
}
|
|
141
|
+
if (node instanceof EnumerationLiteral) {
|
|
142
|
+
return annotations.length > 0
|
|
143
|
+
? [
|
|
144
|
+
`enumeration literal ${node.name}:`,
|
|
145
|
+
indent(annotations.map(textualizationOfAnnotation))
|
|
146
|
+
]
|
|
147
|
+
: [];
|
|
148
|
+
}
|
|
149
|
+
if (node instanceof Feature) {
|
|
150
|
+
return annotations.length > 0
|
|
151
|
+
? [
|
|
152
|
+
`${withFirstLower(node.metaType())} ${node.name}:`,
|
|
153
|
+
indent(annotations.map(textualizationOfAnnotation))
|
|
154
|
+
]
|
|
155
|
+
: [];
|
|
156
|
+
}
|
|
157
|
+
if (node instanceof Language) {
|
|
158
|
+
const annotatedEntities = node.entities.flatMap((entity) => textualizationOfAnnotationsInM3Concept(entity));
|
|
159
|
+
return (annotations.length > 0 || annotatedEntities.length > 0)
|
|
160
|
+
? [
|
|
161
|
+
`language ${node.name}:`,
|
|
162
|
+
indent([
|
|
163
|
+
annotations.map(textualizationOfAnnotation),
|
|
164
|
+
annotatedEntities
|
|
165
|
+
])
|
|
166
|
+
]
|
|
167
|
+
: [];
|
|
168
|
+
}
|
|
169
|
+
if (node instanceof PrimitiveType) {
|
|
170
|
+
return annotations.length > 0
|
|
171
|
+
? [
|
|
172
|
+
`primitive type ${node.name}:`,
|
|
173
|
+
indent(annotations.map(textualizationOfAnnotation))
|
|
174
|
+
]
|
|
175
|
+
: [];
|
|
176
|
+
}
|
|
177
|
+
// can't happen as node has type 'never' at this point, because of type exhaustion,
|
|
178
|
+
// but need to return a Template:
|
|
179
|
+
return [];
|
|
180
|
+
};
|
|
181
|
+
/**
|
|
182
|
+
* @return textualization of all instances of io.lionweb.mps.specific annotations, in the given languages' tree structure.
|
|
183
|
+
* **Note**: only language elements having annotations (at any nesting depth) are rendered.
|
|
184
|
+
* This is useful to get a quick overview of the annotations.
|
|
185
|
+
*/
|
|
186
|
+
export const textualizationOfAnnotationsIn = (languages) => asString(languages.map(textualizationOfAnnotationsInM3Concept));
|
|
187
|
+
//# sourceMappingURL=textualizer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"textualizer.js","sourceRoot":"","sources":["../src/textualizer.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,WAAW,EACX,kBAAkB,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CAAA;AAGD;;;;GAIG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,SAAqB,EAAU,EAAE,CAC3E,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,sCAAsC,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
```mermaid
|
|
2
|
+
classDiagram
|
|
3
|
+
|
|
4
|
+
class ConceptDescription,<<Annotation>> ConceptDescription,ConceptDescription ..> Classifier {
|
|
5
|
+
+String? conceptAlias
|
|
6
|
+
+String? conceptShortDescription
|
|
7
|
+
+String? helpUrl
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
class Deprecated,<<Annotation>> Deprecated,Deprecated ..> IKeyed {
|
|
11
|
+
+String? comment
|
|
12
|
+
+String? build
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
class KeyedDescription,<<Annotation>> KeyedDescription,KeyedDescription ..> IKeyed {
|
|
16
|
+
+String? documentation
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
class ShortDescription,<<Annotation>> ShortDescription,ShortDescription ..> Node {
|
|
20
|
+
+String? description
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
class VirtualPackage
|
|
24
|
+
<<Annotation>> VirtualPackage
|
|
25
|
+
VirtualPackage ..> Node
|
|
26
|
+
INamed <|.. VirtualPackage
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
KeyedDescription "*" --> "*" Node: seeAlso
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
```
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
@startuml
|
|
2
|
+
hide empty members
|
|
3
|
+
|
|
4
|
+
' qualified name: "io.lionweb.mps.specific"
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
annotation ConceptDescription {
|
|
8
|
+
conceptAlias: String?
|
|
9
|
+
conceptShortDescription: String?
|
|
10
|
+
helpUrl: String?
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
annotation Deprecated {
|
|
14
|
+
comment: String?
|
|
15
|
+
build: String?
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
annotation KeyedDescription {
|
|
19
|
+
documentation: String?
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
annotation ShortDescription {
|
|
23
|
+
description: String?
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
annotation VirtualPackage implements INamed
|
|
27
|
+
VirtualPackage ..> Node
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
' relations:
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
KeyedDescription "*" --> "*" Node: seeAlso
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
@enduml
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lionweb/io-lionweb-mps-specific",
|
|
3
|
-
"version": "0.7.0-alpha.
|
|
3
|
+
"version": "0.7.0-alpha.8",
|
|
4
4
|
"description": "TypeScript implementation of the io.lionweb.mps.specific language",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -15,9 +15,10 @@
|
|
|
15
15
|
"url": "https://github.com/LionWeb-io/lionweb-typescript/issues"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@lionweb/core": "0.7.0-alpha.
|
|
19
|
-
"@lionweb/json": "0.7.0-alpha.
|
|
20
|
-
"@lionweb/
|
|
18
|
+
"@lionweb/core": "0.7.0-alpha.8",
|
|
19
|
+
"@lionweb/json": "0.7.0-alpha.8",
|
|
20
|
+
"@lionweb/textgen-utils": "0.7.0-alpha.8",
|
|
21
|
+
"@lionweb/ts-utils": "0.7.0-alpha.8",
|
|
21
22
|
"littoral-templates": "0.3.0",
|
|
22
23
|
"nanoid": "5.0.9"
|
|
23
24
|
},
|
|
File without changes
|
|
File without changes
|