Skip to content

Commit ef58f14

Browse files
committed
Fix treatment of containments in ECore nodes, release version 1.6.6
1 parent 500c2f8 commit ef58f14

File tree

6 files changed

+14273
-7
lines changed

6 files changed

+14273
-7
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.6] – 2024-03-06
6+
7+
### Fixed
8+
- Treatment of containments in ECore nodes
9+
510
## [1.6.5] – 2024-03-06
611

712
### Fixed

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.5",
6+
"version": "1.6.6",
77
"license": "Apache-2.0",
88
"keywords": [
99
"antlr",

src/interop/ecore.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {Point, Position} from "../model/position";
1818
import {Issue, IssueSeverity, IssueType} from "../validation";
1919
import {addLiteral, getEPackage} from "./ecore-basic";
2020
import {
21-
STARLASU_URI_V2,
21+
STARLASU_URI_V2, THE_DESTINATION_INTERFACE,
2222
THE_ENTITY_DECLARATION_INTERFACE,
2323
THE_EXPRESSION_INTERFACE,
2424
THE_ISSUE_ECLASS,
@@ -41,6 +41,7 @@ import {
4141
import {KOLASU_URI_V1, THE_NODE_ECLASS as THE_NODE_ECLASS_V1} from "./kolasu-v1-metamodel";
4242
import {EBigDecimal, EBigInteger} from "./ecore-patching";
4343
import {NodeAdapter} from "../trace/trace-node";
44+
import {EClassifier} from "ecore";
4445

4546
export * as starlasu_v2 from "./starlasu-v2-metamodel";
4647
export * as kolasu_v1 from "./kolasu-v1-metamodel";
@@ -808,6 +809,11 @@ export function registerPackages(resource: ECore.Resource): ECore.EPackage[] {
808809
});
809810
}
810811

812+
export function isNodeType(type: EClassifier) {
813+
return (type.get("interface") && type != THE_DESTINATION_INTERFACE) ||
814+
type.get("eAllSuperTypes")?.find(t => t == THE_NODE_ECLASS_V2 || t == THE_NODE_ECLASS_V1);
815+
}
816+
811817
export interface EcoreMetamodelSupport {
812818
/**
813819
* Generates the metamodel. The standard Kolasu metamodel [EPackage][org.eclipse.emf.ecore.EPackage] is included.
@@ -895,13 +901,13 @@ export class ECoreNode extends NodeAdapter {
895901
for (const ft of this.eo.eClass.get("eAllStructuralFeatures")) {
896902
const name = ft.get("name");
897903
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)) {
904+
if (isReference && !isNodeType(ft.get("eType"))) {
899905
// skip
900906
} else {
901907
result[name] = {
902908
name,
903909
child: isReference && ft.get('containment'),
904-
multiple: (isReference && ft.get('many')) || undefined,
910+
multiple: isReference ? ft.get('many') : undefined,
905911
};
906912
}
907913
}

0 commit comments

Comments
 (0)