Skip to content

Commit ecdac8f

Browse files
committed
#73 omit StarLasu features in nodes imported from Lionweb
1 parent b064e72 commit ecdac8f

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

src/interop/lionweb.ts

+10-12
Original file line numberDiff line numberDiff line change
@@ -70,20 +70,14 @@ export class LanguageMapping {
7070
}
7171
}
7272

73-
function isSpecialConcept(classifier: Classifier | null) {
74-
return classifier?.key == PositionClassifier.key;
75-
}
76-
7773
function importFeature(feature: LWFeature): Feature | undefined {
74+
if (feature.parent == AST_NODE_CLASSIFIER) {
75+
return undefined;
76+
}
7877
const def: Feature = { name: feature.name };
7978
if (feature instanceof Containment) {
80-
if (!isSpecialConcept(feature.type)) {
81-
def.child = true;
82-
def.multiple = feature.multiple;
83-
} else {
84-
// We don't import the containment because we handle it specially
85-
return undefined;
86-
}
79+
def.child = true;
80+
def.multiple = feature.multiple;
8781
}
8882
return def;
8983
}
@@ -141,7 +135,11 @@ export class TylasuInstantiationFacade implements InstantiationFacade<TylasuWrap
141135

142136
setFeatureValue(node: TylasuWrapper, feature: LWFeature, value: unknown): void {
143137
if (node instanceof TylasuNodeWrapper) {
144-
if (feature instanceof Containment) {
138+
if (feature.parent == AST_NODE_CLASSIFIER) {
139+
if (feature.name == "position") {
140+
node.node.position = value as Position;
141+
}
142+
} else if (feature instanceof Containment) {
145143
if (feature.multiple) {
146144
node.node.addChild(feature.name, (value as TylasuNodeWrapper)?.node);
147145
} else {

tests/interop/lionweb.test.ts

+4
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ describe('Lionweb integration', function() {
122122
expect(root.getRole()).to.be.undefined;
123123
expect(root.nodeDefinition.name).to.equal("EglCompilationUnit");
124124
expect(root.containment("position")).to.be.undefined;
125+
expect(() => root.getAttributeValue("position")).to.throw();
126+
expect(root.nodeDefinition.features.position).to.be.undefined;
127+
expect(root.nodeDefinition.features.originalNode).to.be.undefined;
128+
expect(root.nodeDefinition.features.transpiledNode).to.be.undefined;
125129
expect(root.position).not.to.be.undefined;
126130
expect(root.position?.start.line).to.equal(1);
127131
expect(root.position?.start.column).to.equal(0);

0 commit comments

Comments
 (0)