Skip to content

Commit

Permalink
#73 omit StarLasu features in nodes imported from Lionweb
Browse files Browse the repository at this point in the history
  • Loading branch information
alessiostalla committed Jul 9, 2024
1 parent b064e72 commit ecdac8f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/interop/lionweb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,14 @@ export class LanguageMapping {
}
}

function isSpecialConcept(classifier: Classifier | null) {
return classifier?.key == PositionClassifier.key;
}

function importFeature(feature: LWFeature): Feature | undefined {
if (feature.parent == AST_NODE_CLASSIFIER) {
return undefined;
}
const def: Feature = { name: feature.name };
if (feature instanceof Containment) {
if (!isSpecialConcept(feature.type)) {
def.child = true;
def.multiple = feature.multiple;
} else {
// We don't import the containment because we handle it specially
return undefined;
}
def.child = true;
def.multiple = feature.multiple;
}
return def;
}
Expand Down Expand Up @@ -141,7 +135,11 @@ export class TylasuInstantiationFacade implements InstantiationFacade<TylasuWrap

setFeatureValue(node: TylasuWrapper, feature: LWFeature, value: unknown): void {
if (node instanceof TylasuNodeWrapper) {
if (feature instanceof Containment) {
if (feature.parent == AST_NODE_CLASSIFIER) {
if (feature.name == "position") {
node.node.position = value as Position;
}
} else if (feature instanceof Containment) {
if (feature.multiple) {
node.node.addChild(feature.name, (value as TylasuNodeWrapper)?.node);
} else {
Expand Down
4 changes: 4 additions & 0 deletions tests/interop/lionweb.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ describe('Lionweb integration', function() {
expect(root.getRole()).to.be.undefined;
expect(root.nodeDefinition.name).to.equal("EglCompilationUnit");
expect(root.containment("position")).to.be.undefined;
expect(() => root.getAttributeValue("position")).to.throw();
expect(root.nodeDefinition.features.position).to.be.undefined;
expect(root.nodeDefinition.features.originalNode).to.be.undefined;
expect(root.nodeDefinition.features.transpiledNode).to.be.undefined;
expect(root.position).not.to.be.undefined;
expect(root.position?.start.line).to.equal(1);
expect(root.position?.start.column).to.equal(0);
Expand Down

0 comments on commit ecdac8f

Please sign in to comment.