Skip to content

Commit 046f59d

Browse files
committed
Fix node definitions in Playground dynamic nodes
1 parent df92f2f commit 046f59d

File tree

2 files changed

+14
-34
lines changed

2 files changed

+14
-34
lines changed

src/interop/strumenta-playground.ts

+12-32
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {ParsingResult} from "../parsing";
22
import {EcoreMetamodelSupport, fromEObject, loadEObject, loadEPackages, Result, toEObject} from "./ecore";
3-
import {Node, NodeDefinition} from "../model/model";
3+
import {Node, NodeDefinition, PropertyDefinition} from "../model/model";
44
import ECore from "ecore/dist/ecore";
55
import {Position} from "../model/position";
66
import {PARSER_EPACKAGE, PARSER_TRACE_ECLASS} from "./parser-package";
@@ -128,12 +128,18 @@ export abstract class TraceNode extends Node {
128128
};
129129
}
130130

131-
getProperties(): any {
132-
const result: any = {};
131+
getProperties(): { [name: string | symbol]: PropertyDefinition } {
132+
const result: { [name: string | symbol]: PropertyDefinition } = {};
133133
for (const attr of this.eo.eClass.get("eAllAttributes")) {
134134
const name = attr.get("name");
135-
result[name] = { child: false };
135+
result[name] = { name: name, child: false };
136136
}
137+
this.eo.eContents()
138+
.filter((c) => c.eContainingFeature.get("name") != "position")
139+
.forEach((c) => {
140+
const name = c.eContainingFeature.get("name");
141+
result[name] = { name, child: true, multiple: c.eContainingFeature.get("many") };
142+
});
137143
return result;
138144
}
139145

@@ -208,16 +214,6 @@ export class ParserNode extends TraceNode {
208214
get children(): Node[] {
209215
return this.getChildren();
210216
}
211-
212-
getProperties(): any {
213-
const def = super.getProperties();
214-
this.eo.eContents()
215-
.filter((c) => c.eContainingFeature.get("name") != "position")
216-
.forEach((c) => {
217-
def[c.eContainingFeature.get("name")] = { child: true };
218-
});
219-
return def;
220-
}
221217
}
222218

223219
export interface Language {
@@ -433,17 +429,6 @@ export class SourceNode extends TraceNode {
433429
get children(): Node[] {
434430
return this.getChildren();
435431
}
436-
437-
getProperties(): any {
438-
const def = super.getProperties();
439-
this.eo.eContents()
440-
.filter((c) => c.eContainingFeature.get("name") != "position")
441-
.forEach((c) => {
442-
def[c.eContainingFeature.get("name")] = { child: true };
443-
});
444-
return def;
445-
}
446-
447432
}
448433

449434
export class TargetNode extends TraceNode {
@@ -504,14 +489,9 @@ export class TargetNode extends TraceNode {
504489
return this.getChildren();
505490
}
506491

507-
getProperties(): any {
492+
getProperties() {
508493
const def = super.getProperties();
509-
this.eo.eContents()
510-
.filter((c) => c.eContainingFeature.get("name") != "position")
511-
.filter((c) => c.eContainingFeature.get("name") != "destination")
512-
.forEach((c) => {
513-
def[c.eContainingFeature.get("name")] = { child: true };
514-
});
494+
delete def["destination"];
515495
return def;
516496
}
517497
}

tests/interop/parser-trace.test.ts

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

0 commit comments

Comments
 (0)