|
1 | 1 | import {ParsingResult} from "../parsing";
|
2 | 2 | import {EcoreMetamodelSupport, fromEObject, loadEObject, loadEPackages, Result, toEObject} from "./ecore";
|
3 |
| -import {Node, NodeDefinition} from "../model/model"; |
| 3 | +import {Node, NodeDefinition, PropertyDefinition} from "../model/model"; |
4 | 4 | import ECore from "ecore/dist/ecore";
|
5 | 5 | import {Position} from "../model/position";
|
6 | 6 | import {PARSER_EPACKAGE, PARSER_TRACE_ECLASS} from "./parser-package";
|
@@ -128,12 +128,18 @@ export abstract class TraceNode extends Node {
|
128 | 128 | };
|
129 | 129 | }
|
130 | 130 |
|
131 |
| - getProperties(): any { |
132 |
| - const result: any = {}; |
| 131 | + getProperties(): { [name: string | symbol]: PropertyDefinition } { |
| 132 | + const result: { [name: string | symbol]: PropertyDefinition } = {}; |
133 | 133 | for (const attr of this.eo.eClass.get("eAllAttributes")) {
|
134 | 134 | const name = attr.get("name");
|
135 |
| - result[name] = { child: false }; |
| 135 | + result[name] = { name: name, child: false }; |
136 | 136 | }
|
| 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 | + }); |
137 | 143 | return result;
|
138 | 144 | }
|
139 | 145 |
|
@@ -208,16 +214,6 @@ export class ParserNode extends TraceNode {
|
208 | 214 | get children(): Node[] {
|
209 | 215 | return this.getChildren();
|
210 | 216 | }
|
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 |
| - } |
221 | 217 | }
|
222 | 218 |
|
223 | 219 | export interface Language {
|
@@ -433,17 +429,6 @@ export class SourceNode extends TraceNode {
|
433 | 429 | get children(): Node[] {
|
434 | 430 | return this.getChildren();
|
435 | 431 | }
|
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 |
| - |
447 | 432 | }
|
448 | 433 |
|
449 | 434 | export class TargetNode extends TraceNode {
|
@@ -504,14 +489,9 @@ export class TargetNode extends TraceNode {
|
504 | 489 | return this.getChildren();
|
505 | 490 | }
|
506 | 491 |
|
507 |
| - getProperties(): any { |
| 492 | + getProperties() { |
508 | 493 | 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"]; |
515 | 495 | return def;
|
516 | 496 | }
|
517 | 497 | }
|
|
0 commit comments