From 483596cf2a82c3f80d7dbac92825736acdd40f15 Mon Sep 17 00:00:00 2001 From: Sascha Lisson Date: Thu, 2 May 2024 10:58:01 +0200 Subject: [PATCH] fix: MPS constraints weren't evaluated for wrapper actions --- .../org/modelix/editor/ssr/mps/ModelixSSRServerForMPS.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/projectional-editor-ssr-mps/src/main/kotlin/org/modelix/editor/ssr/mps/ModelixSSRServerForMPS.kt b/projectional-editor-ssr-mps/src/main/kotlin/org/modelix/editor/ssr/mps/ModelixSSRServerForMPS.kt index c47d5d70..a9ba2876 100644 --- a/projectional-editor-ssr-mps/src/main/kotlin/org/modelix/editor/ssr/mps/ModelixSSRServerForMPS.kt +++ b/projectional-editor-ssr-mps/src/main/kotlin/org/modelix/editor/ssr/mps/ModelixSSRServerForMPS.kt @@ -291,9 +291,12 @@ object MPSConstraints : IConstraintsChecker { // Constraints only prevent creating a node. If it already exists, it's handled by the model checker. if (node.getNode() != null) return emptyList() - val parentNode = node.getParent()?.getNode().toMPS() - // MPS doesn't support constraint checking without a parent node - if (parentNode == null) return emptyList() + // Correct would be `parentNode = node.getParent()?.getNode().toMPS()` + // but the parent node is not allowed to be null. + // MPS itself then just passes the nearest existing ancestor to the constraints. + // Without this hack we cannot evaluate any constraints and there would be too many incorrect entries in the + // code completion menu. + val parentNode = node.getExistingAncestor().toMPS() // ConstraintsCanBeFacade.checkCanBeRoot()