Skip to content

Commit 500c2f8

Browse files
committed
Fix treatment of containments in ECore nodes, release version 1.6.5
1 parent 9fe1594 commit 500c2f8

File tree

4 files changed

+19
-11
lines changed

4 files changed

+19
-11
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
All notable changes to this project from version 1.2.0 upwards are documented in this file.
33
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
44

5+
## [1.6.5] – 2024-03-06
6+
7+
### Fixed
8+
- Treatment of containments in ECore nodes
9+
510
## [1.6.4] – 2024-03-06
611

712
### Added

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "AST building blocks for TypeScript/JavaScript, part of the *lasu family, with optional integrations with ANTLR4 and Ecore.",
44
"author": "Strumenta s.r.l.",
55
"publisher": "strumenta",
6-
"version": "1.6.4",
6+
"version": "1.6.5",
77
"license": "Apache-2.0",
88
"keywords": [
99
"antlr",

src/interop/ecore.ts

+12-9
Original file line numberDiff line numberDiff line change
@@ -892,16 +892,19 @@ export class ECoreNode extends NodeAdapter {
892892

893893
getProperties(): { [name: string | symbol]: PropertyDefinition } {
894894
const result: { [name: string | symbol]: PropertyDefinition } = {};
895-
for (const attr of this.eo.eClass.get("eAllAttributes")) {
896-
const name = attr.get("name");
897-
result[name] = {name: name, child: false};
895+
for (const ft of this.eo.eClass.get("eAllStructuralFeatures")) {
896+
const name = ft.get("name");
897+
const isReference = ft.isTypeOf('EReference');
898+
if (isReference && !ft.get("eType")?.get("eAllSuperTypes")?.find(t => t == THE_NODE_ECLASS_V2 || t == THE_NODE_ECLASS_V1)) {
899+
// skip
900+
} else {
901+
result[name] = {
902+
name,
903+
child: isReference && ft.get('containment'),
904+
multiple: (isReference && ft.get('many')) || undefined,
905+
};
906+
}
898907
}
899-
this.eo.eContents()
900-
.filter((c) => c.eContainingFeature.get("name") != "position")
901-
.forEach((c) => {
902-
const name = c.eContainingFeature.get("name");
903-
result[name] = {name, child: true, multiple: c.eContainingFeature.get("many")};
904-
});
905908
return result;
906909
}
907910

tests/interop/parser-trace.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ describe('Parser traces – Kolasu metamodel V1', function() {
4747
expect(rootNode.getSimpleType()).to.eql("CompilationUnit");
4848
const child = rootNode.getChildren("dataDefinitions")[3];
4949
expect(child.nodeDefinition.properties).to.eql({
50-
name: { name: "name", child: false },
50+
name: { name: "name", child: false, multiple: undefined },
5151
keywords: { name: "keywords", child: true, multiple: true }
5252
});
5353
expect(child.getAttributes()).to.eql({ name: 'ENDPOINT' });

0 commit comments

Comments
 (0)