From e665c5da37404123b4b0d103ff69623985e7a2fe Mon Sep 17 00:00:00 2001 From: Bastian Kruck Date: Thu, 22 Jan 2026 14:18:36 +0100 Subject: [PATCH] feat(model-api-gen): allow providing typed concept features to IAsyncNode getter methods - eases working with async api --- .../kotlin/org/modelix/metamodel/ITypedChildLink.kt | 4 ++++ .../commonMain/kotlin/org/modelix/metamodel/ITypedProperty.kt | 4 ++++ .../kotlin/org/modelix/metamodel/ITypedReferenceLink.kt | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/model-api-gen-runtime/src/commonMain/kotlin/org/modelix/metamodel/ITypedChildLink.kt b/model-api-gen-runtime/src/commonMain/kotlin/org/modelix/metamodel/ITypedChildLink.kt index 9c29f0d13f..a3228f2870 100644 --- a/model-api-gen-runtime/src/commonMain/kotlin/org/modelix/metamodel/ITypedChildLink.kt +++ b/model-api-gen-runtime/src/commonMain/kotlin/org/modelix/metamodel/ITypedChildLink.kt @@ -2,6 +2,7 @@ package org.modelix.metamodel import org.modelix.model.api.IChildLink import org.modelix.model.api.INode +import org.modelix.model.api.async.IAsyncNode import org.modelix.model.api.remove interface ITypedChildLink : ITypedConceptFeature { @@ -37,3 +38,6 @@ fun > INode.add class ChildNotSetException(val node: INode, val link: ITypedMandatorySingleChildLink<*>) : Exception("Node $node has no child in role ${link.untyped().name}") + +fun IAsyncNode.getChildren(link: ITypedChildLink) = + getChildren(link.untyped().toReference()) diff --git a/model-api-gen-runtime/src/commonMain/kotlin/org/modelix/metamodel/ITypedProperty.kt b/model-api-gen-runtime/src/commonMain/kotlin/org/modelix/metamodel/ITypedProperty.kt index 5d51b5faab..f48d8dbe5c 100644 --- a/model-api-gen-runtime/src/commonMain/kotlin/org/modelix/metamodel/ITypedProperty.kt +++ b/model-api-gen-runtime/src/commonMain/kotlin/org/modelix/metamodel/ITypedProperty.kt @@ -2,6 +2,7 @@ package org.modelix.metamodel import org.modelix.model.api.INode import org.modelix.model.api.IProperty +import org.modelix.model.api.async.IAsyncNode interface ITypedProperty : ITypedConceptFeature { fun untyped(): IProperty @@ -14,3 +15,6 @@ fun INode.setTypedPropertyValue(property: ITypedProperty, value fun INode.getTypedPropertyValue(property: ITypedProperty): ValueT { return property.deserializeValue(getPropertyValue(property.untyped())) } + +fun IAsyncNode.getPropertyValue(property: ITypedProperty) = + getPropertyValue(property.untyped().toReference()) diff --git a/model-api-gen-runtime/src/commonMain/kotlin/org/modelix/metamodel/ITypedReferenceLink.kt b/model-api-gen-runtime/src/commonMain/kotlin/org/modelix/metamodel/ITypedReferenceLink.kt index 806b076558..c9eb6f6a77 100644 --- a/model-api-gen-runtime/src/commonMain/kotlin/org/modelix/metamodel/ITypedReferenceLink.kt +++ b/model-api-gen-runtime/src/commonMain/kotlin/org/modelix/metamodel/ITypedReferenceLink.kt @@ -2,6 +2,7 @@ package org.modelix.metamodel import org.modelix.model.api.INode import org.modelix.model.api.IReferenceLink +import org.modelix.model.api.async.IAsyncNode interface ITypedReferenceLink : ITypedConceptFeature { fun untyped(): IReferenceLink @@ -22,3 +23,6 @@ fun INode.setReferenceTarget(link: ITypedReferenceLink) : Exception("Node $node has no reference target in role ${link.untyped().name}") + +fun IAsyncNode.getReferenceTarget(reference: ITypedReferenceLink) = + getReferenceTarget(reference.untyped().toReference())