From df9e2af7238b2e9fa2d4f772f49b86413dc0881c Mon Sep 17 00:00:00 2001 From: Sascha Lisson Date: Fri, 24 Nov 2023 19:45:47 +0100 Subject: [PATCH] use untyped model API to support editor rules generated by MPS (5) --- .../kotlin/org/modelix/editor/CellTemplateBuilder.kt | 4 +++- .../commonMain/kotlin/org/modelix/editor/EditorAspect.kt | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/projectional-editor/src/commonMain/kotlin/org/modelix/editor/CellTemplateBuilder.kt b/projectional-editor/src/commonMain/kotlin/org/modelix/editor/CellTemplateBuilder.kt index 3f364718..55f18e56 100644 --- a/projectional-editor/src/commonMain/kotlin/org/modelix/editor/CellTemplateBuilder.kt +++ b/projectional-editor/src/commonMain/kotlin/org/modelix/editor/CellTemplateBuilder.kt @@ -348,10 +348,12 @@ interface ITypedOrUntypedNode { } } -fun > CellTemplate.builder(concept: ConceptT): CellTemplateBuilder { +fun > CellTemplate.builder(concept: ConceptT): CellTemplateBuilder { + require(this.concept == concept.untyped()) return CellTemplateBuilder(this, concept, INodeConverter.Typed(concept)) } fun CellTemplate.builder(concept: ConceptT): CellTemplateBuilder { + require(this.concept == concept) return CellTemplateBuilder(this, concept, INodeConverter.Untyped) } diff --git a/projectional-editor/src/commonMain/kotlin/org/modelix/editor/EditorAspect.kt b/projectional-editor/src/commonMain/kotlin/org/modelix/editor/EditorAspect.kt index 2f87eca4..e244acab 100644 --- a/projectional-editor/src/commonMain/kotlin/org/modelix/editor/EditorAspect.kt +++ b/projectional-editor/src/commonMain/kotlin/org/modelix/editor/EditorAspect.kt @@ -3,7 +3,9 @@ package org.modelix.editor import org.modelix.aspects.ILanguageAspect import org.modelix.aspects.ILanguageAspectFactory import org.modelix.metamodel.IConceptOfTypedNode +import org.modelix.metamodel.ITypedConcept import org.modelix.metamodel.ITypedNode +import org.modelix.metamodel.typed import org.modelix.model.api.IConcept import org.modelix.model.api.IConceptReference import org.modelix.model.api.ILanguage @@ -14,13 +16,14 @@ class EditorAspect : ILanguageAspect { fun > conceptEditor(concept: ConceptT, body: CellTemplateBuilder.()->Unit): ConceptEditor { return ConceptEditor(concept.untyped()) { subConcept -> - CollectionCellTemplate(subConcept).builder(concept).also(body).template + val typedSubconcept= subConcept.typed() as ConceptT + CollectionCellTemplate(subConcept).builder(typedSubconcept).also(body).template }.also(conceptEditors::add) } fun conceptEditor(concept: IConcept, body: CellTemplateBuilder.()->Unit): ConceptEditor { return ConceptEditor(concept) { subConcept -> - CollectionCellTemplate(subConcept).builder(concept).also(body).template + CollectionCellTemplate(subConcept).builder(subConcept).also(body).template }.also(conceptEditors::add) }