From 611f7938688116979e6774a2103ab13ea02e9ceb Mon Sep 17 00:00:00 2001
From: Dennis Hendriks <dh_tue@hotmail.com>
Date: Tue, 30 Jul 2024 13:16:23 +0200
Subject: [PATCH 1/5] #424 CIF to yEd: add empty CifToYedPreChecker class.

---
 .../META-INF/MANIFEST.MF                      |  3 +-
 .../CifToYedRelationsDiagramPreChecker.java   | 31 +++++++++++++++++++
 2 files changed, 33 insertions(+), 1 deletion(-)
 create mode 100644 cif/org.eclipse.escet.cif.cif2yed/src/org/eclipse/escet/cif/cif2yed/CifToYedRelationsDiagramPreChecker.java

diff --git a/cif/org.eclipse.escet.cif.cif2yed/META-INF/MANIFEST.MF b/cif/org.eclipse.escet.cif.cif2yed/META-INF/MANIFEST.MF
index 621359148e..c076a3ab2e 100644
--- a/cif/org.eclipse.escet.cif.cif2yed/META-INF/MANIFEST.MF
+++ b/cif/org.eclipse.escet.cif.cif2yed/META-INF/MANIFEST.MF
@@ -25,7 +25,8 @@ Require-Bundle: org.eclipse.core.resources;bundle-version="3.13.600",
  org.apache.commons.lang3;bundle-version="3.1.0",
  org.eclipse.escet.cif.metamodel.java;bundle-version="5.0.0",
  org.eclipse.escet.cif.cif2cif;bundle-version="5.0.0",
- org.eclipse.escet.common.emf;bundle-version="5.0.0"
+ org.eclipse.escet.common.emf;bundle-version="5.0.0",
+ org.eclipse.escet.cif.checkers;bundle-version="5.0.0"
 Automatic-Module-Name: org.eclipse.escet.cif.cif2yed
 Export-Package: org.eclipse.escet.cif.cif2yed,
  org.eclipse.escet.cif.cif2yed.options
diff --git a/cif/org.eclipse.escet.cif.cif2yed/src/org/eclipse/escet/cif/cif2yed/CifToYedRelationsDiagramPreChecker.java b/cif/org.eclipse.escet.cif.cif2yed/src/org/eclipse/escet/cif/cif2yed/CifToYedRelationsDiagramPreChecker.java
new file mode 100644
index 0000000000..31fce2e1ee
--- /dev/null
+++ b/cif/org.eclipse.escet.cif.cif2yed/src/org/eclipse/escet/cif/cif2yed/CifToYedRelationsDiagramPreChecker.java
@@ -0,0 +1,31 @@
+//////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2010, 2024 Contributors to the Eclipse Foundation
+//
+// See the NOTICE file(s) distributed with this work for additional
+// information regarding copyright ownership.
+//
+// This program and the accompanying materials are made available
+// under the terms of the MIT License which is available at
+// https://opensource.org/licenses/MIT
+//
+// SPDX-License-Identifier: MIT
+//////////////////////////////////////////////////////////////////////////////
+
+package org.eclipse.escet.cif.cif2yed;
+
+import org.eclipse.escet.cif.checkers.CifPreconditionChecker;
+import org.eclipse.escet.common.java.Termination;
+
+/** CIF to yEd transformation precondition checker for generating relations diagrams. */
+public class CifToYedRelationsDiagramPreChecker extends CifPreconditionChecker {
+    /**
+     * Constructor for the {@link CifToYedRelationsDiagramPreChecker} class.
+     *
+     * @param termination Cooperative termination query function.
+     */
+    public CifToYedRelationsDiagramPreChecker(Termination termination) {
+        super(termination
+
+        );
+    }
+}
-- 
GitLab


From 7d9aae39686ce424d791c97a978f7460028d9b7f Mon Sep 17 00:00:00 2001
From: Dennis Hendriks <dh_tue@hotmail.com>
Date: Tue, 30 Jul 2024 13:40:09 +0200
Subject: [PATCH 2/5] #424 Add CompDefNoSpecificParamsCheck check.

---
 .../checks/CompDefNoSpecificParamsCheck.java  | 91 +++++++++++++++++++
 .../CompDefNoSpecificParamsCheckAlgComp.java  | 25 +++++
 .../CompDefNoSpecificParamsCheckEventLoc.java | 25 +++++
 .../CompDefNoSpecificParamsCheckAlgComp.cif   | 57 ++++++++++++
 ...NoSpecificParamsCheckAlgComp.cif.check.err | 18 ++++
 .../CompDefNoSpecificParamsCheckEventLoc.cif  | 57 ++++++++++++
 ...oSpecificParamsCheckEventLoc.cif.check.err | 21 +++++
 7 files changed, 294 insertions(+)
 create mode 100644 cif/org.eclipse.escet.cif.checkers/src/org/eclipse/escet/cif/checkers/checks/CompDefNoSpecificParamsCheck.java
 create mode 100644 cif/org.eclipse.escet.cif.tests/src-test/org/eclipse/escet/cif/tests/checkers/checks/CompDefNoSpecificParamsCheckAlgComp.java
 create mode 100644 cif/org.eclipse.escet.cif.tests/src-test/org/eclipse/escet/cif/tests/checkers/checks/CompDefNoSpecificParamsCheckEventLoc.java
 create mode 100644 cif/org.eclipse.escet.cif.tests/tests/checks/CompDefNoSpecificParamsCheckAlgComp.cif
 create mode 100644 cif/org.eclipse.escet.cif.tests/tests/checks/CompDefNoSpecificParamsCheckAlgComp.cif.check.err
 create mode 100644 cif/org.eclipse.escet.cif.tests/tests/checks/CompDefNoSpecificParamsCheckEventLoc.cif
 create mode 100644 cif/org.eclipse.escet.cif.tests/tests/checks/CompDefNoSpecificParamsCheckEventLoc.cif.check.err

diff --git a/cif/org.eclipse.escet.cif.checkers/src/org/eclipse/escet/cif/checkers/checks/CompDefNoSpecificParamsCheck.java b/cif/org.eclipse.escet.cif.checkers/src/org/eclipse/escet/cif/checkers/checks/CompDefNoSpecificParamsCheck.java
new file mode 100644
index 0000000000..49143241c0
--- /dev/null
+++ b/cif/org.eclipse.escet.cif.checkers/src/org/eclipse/escet/cif/checkers/checks/CompDefNoSpecificParamsCheck.java
@@ -0,0 +1,91 @@
+//////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2010, 2024 Contributors to the Eclipse Foundation
+//
+// See the NOTICE file(s) distributed with this work for additional
+// information regarding copyright ownership.
+//
+// This program and the accompanying materials are made available
+// under the terms of the MIT License which is available at
+// https://opensource.org/licenses/MIT
+//
+// SPDX-License-Identifier: MIT
+//////////////////////////////////////////////////////////////////////////////
+
+package org.eclipse.escet.cif.checkers.checks;
+
+import java.util.Arrays;
+import java.util.EnumSet;
+
+import org.eclipse.escet.cif.checkers.CifCheck;
+import org.eclipse.escet.cif.checkers.CifCheckViolations;
+import org.eclipse.escet.cif.metamodel.cif.AlgParameter;
+import org.eclipse.escet.cif.metamodel.cif.ComponentParameter;
+import org.eclipse.escet.cif.metamodel.cif.EventParameter;
+import org.eclipse.escet.cif.metamodel.cif.LocationParameter;
+
+/** CIF check that does not allow certain parameters of component definitions. */
+public class CompDefNoSpecificParamsCheck extends CifCheck {
+    /** The parameters to disallow. */
+    private final EnumSet<NoSpecificCompDefParam> disalloweds;
+
+    /**
+     * Constructor for the {@link CompDefNoSpecificParamsCheck} class.
+     *
+     * @param disalloweds The parameters to disallow.
+     */
+    public CompDefNoSpecificParamsCheck(NoSpecificCompDefParam... disalloweds) {
+        this(EnumSet.copyOf(Arrays.asList(disalloweds)));
+    }
+
+    /**
+     * Constructor for the {@link CompDefNoSpecificParamsCheck} class.
+     *
+     * @param disalloweds The parameters to disallow.
+     */
+    public CompDefNoSpecificParamsCheck(EnumSet<NoSpecificCompDefParam> disalloweds) {
+        this.disalloweds = disalloweds;
+    }
+
+    @Override
+    protected void preprocessAlgParameter(AlgParameter param, CifCheckViolations violations) {
+        if (disalloweds.contains(NoSpecificCompDefParam.ALGEBRAIC)) {
+            violations.add(param, "A component definition has an algebraic parameter");
+        }
+    }
+
+    @Override
+    protected void preprocessComponentParameter(ComponentParameter param, CifCheckViolations violations) {
+        if (disalloweds.contains(NoSpecificCompDefParam.COMPONENT)) {
+            violations.add(param, "A component definition has a component parameter");
+        }
+    }
+
+    @Override
+    protected void preprocessEventParameter(EventParameter param, CifCheckViolations violations) {
+        if (disalloweds.contains(NoSpecificCompDefParam.EVENT)) {
+            violations.add(param, "A component definition has an event parameter");
+        }
+    }
+
+    @Override
+    protected void preprocessLocationParameter(LocationParameter param, CifCheckViolations violations) {
+        if (disalloweds.contains(NoSpecificCompDefParam.LOCATION)) {
+            violations.add(param, "A component definition has a location parameter");
+        }
+    }
+
+    /** The parameters to disallow. */
+    public static enum NoSpecificCompDefParam {
+        /** Disallow algebraic parameters. */
+        ALGEBRAIC,
+
+        /** Disallow component parameters. */
+        COMPONENT,
+
+        /** Disallow event parameters. */
+        EVENT,
+
+        /** Disallow location parameters. */
+        LOCATION,
+    }
+}
diff --git a/cif/org.eclipse.escet.cif.tests/src-test/org/eclipse/escet/cif/tests/checkers/checks/CompDefNoSpecificParamsCheckAlgComp.java b/cif/org.eclipse.escet.cif.tests/src-test/org/eclipse/escet/cif/tests/checkers/checks/CompDefNoSpecificParamsCheckAlgComp.java
new file mode 100644
index 0000000000..0f6ba3c696
--- /dev/null
+++ b/cif/org.eclipse.escet.cif.tests/src-test/org/eclipse/escet/cif/tests/checkers/checks/CompDefNoSpecificParamsCheckAlgComp.java
@@ -0,0 +1,25 @@
+//////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation
+//
+// See the NOTICE file(s) distributed with this work for additional
+// information regarding copyright ownership.
+//
+// This program and the accompanying materials are made available
+// under the terms of the MIT License which is available at
+// https://opensource.org/licenses/MIT
+//
+// SPDX-License-Identifier: MIT
+//////////////////////////////////////////////////////////////////////////////
+
+package org.eclipse.escet.cif.tests.checkers.checks;
+
+import org.eclipse.escet.cif.checkers.checks.CompDefNoSpecificParamsCheck;
+import org.eclipse.escet.cif.checkers.checks.CompNoInitPredsCheck;
+
+/** {@link CompNoInitPredsCheck} that disallows algebraic and component parameters. */
+public class CompDefNoSpecificParamsCheckAlgComp extends CompDefNoSpecificParamsCheck {
+    /** Constructor of the {@link CompDefNoSpecificParamsCheckAlgComp} class. */
+    public CompDefNoSpecificParamsCheckAlgComp() {
+        super(NoSpecificCompDefParam.ALGEBRAIC, NoSpecificCompDefParam.COMPONENT);
+    }
+}
diff --git a/cif/org.eclipse.escet.cif.tests/src-test/org/eclipse/escet/cif/tests/checkers/checks/CompDefNoSpecificParamsCheckEventLoc.java b/cif/org.eclipse.escet.cif.tests/src-test/org/eclipse/escet/cif/tests/checkers/checks/CompDefNoSpecificParamsCheckEventLoc.java
new file mode 100644
index 0000000000..fc8b548b07
--- /dev/null
+++ b/cif/org.eclipse.escet.cif.tests/src-test/org/eclipse/escet/cif/tests/checkers/checks/CompDefNoSpecificParamsCheckEventLoc.java
@@ -0,0 +1,25 @@
+//////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation
+//
+// See the NOTICE file(s) distributed with this work for additional
+// information regarding copyright ownership.
+//
+// This program and the accompanying materials are made available
+// under the terms of the MIT License which is available at
+// https://opensource.org/licenses/MIT
+//
+// SPDX-License-Identifier: MIT
+//////////////////////////////////////////////////////////////////////////////
+
+package org.eclipse.escet.cif.tests.checkers.checks;
+
+import org.eclipse.escet.cif.checkers.checks.CompDefNoSpecificParamsCheck;
+import org.eclipse.escet.cif.checkers.checks.CompNoInitPredsCheck;
+
+/** {@link CompNoInitPredsCheck} that disallows event and location parameters. */
+public class CompDefNoSpecificParamsCheckEventLoc extends CompDefNoSpecificParamsCheck {
+    /** Constructor of the {@link CompDefNoSpecificParamsCheckEventLoc} class. */
+    public CompDefNoSpecificParamsCheckEventLoc() {
+        super(NoSpecificCompDefParam.EVENT, NoSpecificCompDefParam.LOCATION);
+    }
+}
diff --git a/cif/org.eclipse.escet.cif.tests/tests/checks/CompDefNoSpecificParamsCheckAlgComp.cif b/cif/org.eclipse.escet.cif.tests/tests/checks/CompDefNoSpecificParamsCheckAlgComp.cif
new file mode 100644
index 0000000000..06056dc3bd
--- /dev/null
+++ b/cif/org.eclipse.escet.cif.tests/tests/checks/CompDefNoSpecificParamsCheckAlgComp.cif
@@ -0,0 +1,57 @@
+//////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2024 Contributors to the Eclipse Foundation
+//
+// See the NOTICE file(s) distributed with this work for additional
+// information regarding copyright ownership.
+//
+// This program and the accompanying materials are made available
+// under the terms of the MIT License which is available at
+// https://opensource.org/licenses/MIT
+//
+// SPDX-License-Identifier: MIT
+//////////////////////////////////////////////////////////////////////////////
+
+group grp:
+  group def G(
+      alg int a1, a2; alg bool a3;
+      event e1, e2; controllable e3;
+      location l1, l2
+    ):
+    invariant e1 needs a1 + a2 > 0;
+    invariant e2 needs a3;
+    invariant e3 needs l1 and l2;
+    const bool b = true;
+  end
+end
+
+automaton def A(
+    alg int a1, a2; alg bool a3;
+    grp.G g1, g2;
+    event e1, e2; controllable e3;
+    location l1, l2
+  ):
+
+    invariant e1 needs a1 + a2 > 1;
+    invariant e2 needs not a3;
+    invariant e3 needs l1 or l2;
+    invariant g1.b and g2.b;
+
+  location:
+    initial;
+end
+
+automaton aut:
+  location loc1:
+    initial;
+    edge e1, e2, ec;
+
+  location loc2:
+    initial;
+end
+
+event e1, e2;
+controllable ec;
+
+g1: grp.G(1, 2, true, e1, e2, ec, aut.loc1, aut.loc2);
+g2: grp.G(1, 2, true, e1, e2, ec, aut.loc2, aut.loc1);
+a: A(1, 2, true, g1, g2, e1, e2, ec, aut.loc1, aut.loc2);
diff --git a/cif/org.eclipse.escet.cif.tests/tests/checks/CompDefNoSpecificParamsCheckAlgComp.cif.check.err b/cif/org.eclipse.escet.cif.tests/tests/checks/CompDefNoSpecificParamsCheckAlgComp.cif.check.err
new file mode 100644
index 0000000000..d5e4ca9f6b
--- /dev/null
+++ b/cif/org.eclipse.escet.cif.tests/tests/checks/CompDefNoSpecificParamsCheckAlgComp.cif.check.err
@@ -0,0 +1,18 @@
+ERROR: CIF checks tester failed due to unsatisfied preconditions:
+
+  -------------------------------------------------------
+  (1/2) A component definition has a component parameter.
+  -------------------------------------------------------
+   * In automaton definition "A":
+     - automaton def A(alg int a1; alg int a2; alg bool a3; grp.G g1; grp.G g2; event e1; event e2; controllable e3; location l1; location l2):
+                                                                  ^         ^
+
+  --------------------------------------------------------
+  (2/2) A component definition has an algebraic parameter.
+  --------------------------------------------------------
+   * In automaton definition "A":
+     - automaton def A(alg int a1; alg int a2; alg bool a3; grp.G g1; grp.G g2; event e1; event e2; controllable e3; location l1; location l2):
+                               ^           ^            ^
+   * In group definition "grp.G":
+     - group def G(alg int a1; alg int a2; alg bool a3; event e1; event e2; controllable e3; location l1; location l2):
+                           ^           ^            ^
diff --git a/cif/org.eclipse.escet.cif.tests/tests/checks/CompDefNoSpecificParamsCheckEventLoc.cif b/cif/org.eclipse.escet.cif.tests/tests/checks/CompDefNoSpecificParamsCheckEventLoc.cif
new file mode 100644
index 0000000000..06056dc3bd
--- /dev/null
+++ b/cif/org.eclipse.escet.cif.tests/tests/checks/CompDefNoSpecificParamsCheckEventLoc.cif
@@ -0,0 +1,57 @@
+//////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2024 Contributors to the Eclipse Foundation
+//
+// See the NOTICE file(s) distributed with this work for additional
+// information regarding copyright ownership.
+//
+// This program and the accompanying materials are made available
+// under the terms of the MIT License which is available at
+// https://opensource.org/licenses/MIT
+//
+// SPDX-License-Identifier: MIT
+//////////////////////////////////////////////////////////////////////////////
+
+group grp:
+  group def G(
+      alg int a1, a2; alg bool a3;
+      event e1, e2; controllable e3;
+      location l1, l2
+    ):
+    invariant e1 needs a1 + a2 > 0;
+    invariant e2 needs a3;
+    invariant e3 needs l1 and l2;
+    const bool b = true;
+  end
+end
+
+automaton def A(
+    alg int a1, a2; alg bool a3;
+    grp.G g1, g2;
+    event e1, e2; controllable e3;
+    location l1, l2
+  ):
+
+    invariant e1 needs a1 + a2 > 1;
+    invariant e2 needs not a3;
+    invariant e3 needs l1 or l2;
+    invariant g1.b and g2.b;
+
+  location:
+    initial;
+end
+
+automaton aut:
+  location loc1:
+    initial;
+    edge e1, e2, ec;
+
+  location loc2:
+    initial;
+end
+
+event e1, e2;
+controllable ec;
+
+g1: grp.G(1, 2, true, e1, e2, ec, aut.loc1, aut.loc2);
+g2: grp.G(1, 2, true, e1, e2, ec, aut.loc2, aut.loc1);
+a: A(1, 2, true, g1, g2, e1, e2, ec, aut.loc1, aut.loc2);
diff --git a/cif/org.eclipse.escet.cif.tests/tests/checks/CompDefNoSpecificParamsCheckEventLoc.cif.check.err b/cif/org.eclipse.escet.cif.tests/tests/checks/CompDefNoSpecificParamsCheckEventLoc.cif.check.err
new file mode 100644
index 0000000000..202962128e
--- /dev/null
+++ b/cif/org.eclipse.escet.cif.tests/tests/checks/CompDefNoSpecificParamsCheckEventLoc.cif.check.err
@@ -0,0 +1,21 @@
+ERROR: CIF checks tester failed due to unsatisfied preconditions:
+
+  ------------------------------------------------------
+  (1/2) A component definition has a location parameter.
+  ------------------------------------------------------
+   * In automaton definition "A":
+     - automaton def A(alg int a1; alg int a2; alg bool a3; grp.G g1; grp.G g2; event e1; event e2; controllable e3; location l1; location l2):
+                                                                                                                              ^            ^
+   * In group definition "grp.G":
+     - group def G(alg int a1; alg int a2; alg bool a3; event e1; event e2; controllable e3; location l1; location l2):
+                                                                                                      ^            ^
+
+  ----------------------------------------------------
+  (2/2) A component definition has an event parameter.
+  ----------------------------------------------------
+   * In automaton definition "A":
+     - automaton def A(alg int a1; alg int a2; alg bool a3; grp.G g1; grp.G g2; event e1; event e2; controllable e3; location l1; location l2):
+                                                                                      ^         ^                ^
+   * In group definition "grp.G":
+     - group def G(alg int a1; alg int a2; alg bool a3; event e1; event e2; controllable e3; location l1; location l2):
+                                                              ^         ^                ^
-- 
GitLab


From 50b0b53a8064f64f8707bad477cac245043f4c86 Mon Sep 17 00:00:00 2001
From: Dennis Hendriks <dh_tue@hotmail.com>
Date: Tue, 30 Jul 2024 13:45:47 +0200
Subject: [PATCH 3/5] #424 CIF to yEd transformer: use new precondition
 checker.

---
 .../escet/cif/cif2yed/CifToYedApp.java        |  7 ++-
 .../escet/cif/cif2yed/CifToYedDiagram.java    | 11 +++-
 .../cif/cif2yed/CifToYedModelDiagram.java     |  3 +-
 .../cif/cif2yed/CifToYedRelationsDiagram.java | 57 ++-----------------
 .../CifToYedRelationsDiagramPreChecker.java   |  6 +-
 5 files changed, 25 insertions(+), 59 deletions(-)

diff --git a/cif/org.eclipse.escet.cif.cif2yed/src/org/eclipse/escet/cif/cif2yed/CifToYedApp.java b/cif/org.eclipse.escet.cif.cif2yed/src/org/eclipse/escet/cif/cif2yed/CifToYedApp.java
index 97cd4dcdc3..62d05d6ab4 100644
--- a/cif/org.eclipse.escet.cif.cif2yed/src/org/eclipse/escet/cif/cif2yed/CifToYedApp.java
+++ b/cif/org.eclipse.escet.cif.cif2yed/src/org/eclipse/escet/cif/cif2yed/CifToYedApp.java
@@ -42,6 +42,7 @@ import org.eclipse.escet.common.app.framework.options.OutputFileOption;
 import org.eclipse.escet.common.app.framework.output.IOutputComponent;
 import org.eclipse.escet.common.app.framework.output.OutputProvider;
 import org.eclipse.escet.common.java.Assert;
+import org.eclipse.escet.common.java.Termination;
 import org.eclipse.escet.common.java.exceptions.InvalidOptionException;
 import org.eclipse.escet.common.java.exceptions.UnsupportedException;
 import org.w3c.dom.Document;
@@ -86,6 +87,7 @@ public class CifToYedApp extends Application<IOutputComponent> {
     protected int runInternal() {
         // Read CIF specification.
         Specification spec = new CifReader().init().read();
+        String absSpecPath = Paths.resolve(InputFileOption.getPath());
         if (isTerminationRequested()) {
             return 0;
         }
@@ -113,15 +115,16 @@ public class CifToYedApp extends Application<IOutputComponent> {
             outPath = Paths.resolve(outPath);
 
             // Perform transformation to yEd.
+            Termination termination = () -> isTerminationRequested();
             Document doc = null;
             try {
                 switch (kind) {
                     case MODEL:
-                        doc = new CifToYedModelDiagram().transform(spec);
+                        doc = new CifToYedModelDiagram().transform(spec, absSpecPath, termination);
                         break;
 
                     case RELATIONS:
-                        doc = new CifToYedRelationsDiagram().transform(spec);
+                        doc = new CifToYedRelationsDiagram().transform(spec, absSpecPath, termination);
                         break;
                 }
             } catch (UnsupportedException ex) {
diff --git a/cif/org.eclipse.escet.cif.cif2yed/src/org/eclipse/escet/cif/cif2yed/CifToYedDiagram.java b/cif/org.eclipse.escet.cif.cif2yed/src/org/eclipse/escet/cif/cif2yed/CifToYedDiagram.java
index f17a584f52..2bc542d644 100644
--- a/cif/org.eclipse.escet.cif.cif2yed/src/org/eclipse/escet/cif/cif2yed/CifToYedDiagram.java
+++ b/cif/org.eclipse.escet.cif.cif2yed/src/org/eclipse/escet/cif/cif2yed/CifToYedDiagram.java
@@ -34,6 +34,7 @@ import org.eclipse.escet.cif.texteditor.CifCodeHighlighter;
 import org.eclipse.escet.cif.texteditor.CifTextEditorLightTheme;
 import org.eclipse.escet.common.app.framework.AppEnv;
 import org.eclipse.escet.common.java.Assert;
+import org.eclipse.escet.common.java.Termination;
 import org.eclipse.escet.common.java.exceptions.UnsupportedException;
 import org.w3c.dom.DOMImplementation;
 import org.w3c.dom.Document;
@@ -89,10 +90,12 @@ public abstract class CifToYedDiagram {
      * Transform a CIF specification into a yEd/GraphML XML document.
      *
      * @param spec The CIF specification.
+     * @param absSpecPath The absolute local file system path to the CIF file.
+     * @param termination Cooperative termination query function.
      * @return The yEd/GraphML XML document.
      * @throws UnsupportedException If an unsupported feature is found.
      */
-    public Document transform(Specification spec) {
+    public Document transform(Specification spec, String absSpecPath, Termination termination) {
         // Options.
         Assert.check(highlighter == null);
         highlight = SyntaxHighlightingOption.applyHighlighting();
@@ -143,7 +146,7 @@ public abstract class CifToYedDiagram {
             metrics = graphics.getFontMetrics();
 
             // Add content from CIF model.
-            addSpec(spec, root);
+            addSpec(spec, absSpecPath, root, termination);
 
             // Cleanup.
             graphics.dispose();
@@ -163,10 +166,12 @@ public abstract class CifToYedDiagram {
      * Add a CIF specification to the yEd/GraphML diagram.
      *
      * @param spec The CIF specification.
+     * @param absSpecPath The absolute local file system path to the CIF file.
      * @param root The root 'graphml' XML element to which to add new elements.
+     * @param termination Cooperative termination query function.
      * @throws UnsupportedException If an unsupported feature is found.
      */
-    protected abstract void addSpec(Specification spec, Element root);
+    protected abstract void addSpec(Specification spec, String absSpecPath, Element root, Termination termination);
 
     /**
      * Constructs a new yEd/GraphML XML document.
diff --git a/cif/org.eclipse.escet.cif.cif2yed/src/org/eclipse/escet/cif/cif2yed/CifToYedModelDiagram.java b/cif/org.eclipse.escet.cif.cif2yed/src/org/eclipse/escet/cif/cif2yed/CifToYedModelDiagram.java
index ccf1795031..b6e4f7d222 100644
--- a/cif/org.eclipse.escet.cif.cif2yed/src/org/eclipse/escet/cif/cif2yed/CifToYedModelDiagram.java
+++ b/cif/org.eclipse.escet.cif.cif2yed/src/org/eclipse/escet/cif/cif2yed/CifToYedModelDiagram.java
@@ -56,6 +56,7 @@ import org.eclipse.escet.common.box.CodeBox;
 import org.eclipse.escet.common.box.MemoryCodeBox;
 import org.eclipse.escet.common.java.Assert;
 import org.eclipse.escet.common.java.Strings;
+import org.eclipse.escet.common.java.Termination;
 import org.eclipse.escet.common.position.metamodel.position.PositionObject;
 import org.w3c.dom.Element;
 
@@ -65,7 +66,7 @@ public class CifToYedModelDiagram extends CifToYedDiagram {
     private Set<ModelFilter> filters;
 
     @Override
-    protected void addSpec(Specification spec, Element root) {
+    protected void addSpec(Specification spec, String absSpecPath, Element root, Termination termination) {
         // Initialize options.
         filters = ModelFiltersOption.getFilters();
 
diff --git a/cif/org.eclipse.escet.cif.cif2yed/src/org/eclipse/escet/cif/cif2yed/CifToYedRelationsDiagram.java b/cif/org.eclipse.escet.cif.cif2yed/src/org/eclipse/escet/cif/cif2yed/CifToYedRelationsDiagram.java
index fcb1c19658..8c9abd4772 100644
--- a/cif/org.eclipse.escet.cif.cif2yed/src/org/eclipse/escet/cif/cif2yed/CifToYedRelationsDiagram.java
+++ b/cif/org.eclipse.escet.cif.cif2yed/src/org/eclipse/escet/cif/cif2yed/CifToYedRelationsDiagram.java
@@ -55,7 +55,6 @@ import org.eclipse.escet.cif.metamodel.cif.ComplexComponent;
 import org.eclipse.escet.cif.metamodel.cif.Component;
 import org.eclipse.escet.cif.metamodel.cif.ComponentDef;
 import org.eclipse.escet.cif.metamodel.cif.ComponentInst;
-import org.eclipse.escet.cif.metamodel.cif.ComponentParameter;
 import org.eclipse.escet.cif.metamodel.cif.Equation;
 import org.eclipse.escet.cif.metamodel.cif.EventParameter;
 import org.eclipse.escet.cif.metamodel.cif.Group;
@@ -91,7 +90,7 @@ import org.eclipse.escet.common.emf.EMFHelper;
 import org.eclipse.escet.common.java.Assert;
 import org.eclipse.escet.common.java.Pair;
 import org.eclipse.escet.common.java.Strings;
-import org.eclipse.escet.common.java.exceptions.UnsupportedException;
+import org.eclipse.escet.common.java.Termination;
 import org.eclipse.escet.common.position.metamodel.position.PositionObject;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -144,13 +143,14 @@ public class CifToYedRelationsDiagram extends CifToYedDiagram {
     private Map<ComponentDef, String> compDefMap;
 
     @Override
-    protected void addSpec(Specification spec, Element root) {
+    protected void addSpec(Specification spec, String absSpecPath, Element root, Termination termination) {
         // Remove annotations to avoid finding relations in them.
         spec = EMFHelper.deepclone(spec);
         new RemoveAnnotations().transform(spec);
 
-        // Precondition checking.
-        preCheck(spec);
+        // Check preconditions.
+        CifToYedRelationsDiagramPreChecker checker = new CifToYedRelationsDiagramPreChecker(termination);
+        checker.reportPreconditionViolations(spec, absSpecPath, "CIF to yEd transformer");
 
         // Initialize.
         relations = RelationKindsOption.getKinds();
@@ -180,53 +180,6 @@ public class CifToYedRelationsDiagram extends CifToYedDiagram {
         removeEmptyComps(root);
     }
 
-    /**
-     * Check preconditions for the given component, recursively.
-     *
-     * @param comp The component to check, recursively.
-     * @throws UnsupportedException If an unsupported feature is found.
-     */
-    private void preCheck(ComplexComponent comp) {
-        // Skip automata, as they don't contain component definitions.
-        if (comp instanceof Automaton) {
-            return;
-        }
-        Group group = (Group)comp;
-
-        // Check component definitions.
-        for (ComponentDef cdef: group.getDefinitions()) {
-            preCheck(cdef);
-        }
-
-        // Check recursively. Skip component instantiations as we already check
-        // the component definitions and their bodies.
-        for (Component child: group.getComponents()) {
-            if (child instanceof ComponentInst) {
-                continue;
-            }
-            preCheck((ComplexComponent)child);
-        }
-    }
-
-    /**
-     * Check preconditions for the given component definition, recursively.
-     *
-     * @param cdef The component definition to check, recursively.
-     * @throws UnsupportedException If an unsupported feature is found.
-     */
-    private void preCheck(ComponentDef cdef) {
-        // Check parameters.
-        for (Parameter param: cdef.getParameters()) {
-            if (param instanceof ComponentParameter) {
-                String msg = fmt("Component parameter \"%s\" is not supported.", CifTextUtils.getAbsName(param));
-                throw new UnsupportedException(msg);
-            }
-        }
-
-        // Check body.
-        preCheck(cdef.getBody());
-    }
-
     /**
      * Add a component, or body of a component definition.
      *
diff --git a/cif/org.eclipse.escet.cif.cif2yed/src/org/eclipse/escet/cif/cif2yed/CifToYedRelationsDiagramPreChecker.java b/cif/org.eclipse.escet.cif.cif2yed/src/org/eclipse/escet/cif/cif2yed/CifToYedRelationsDiagramPreChecker.java
index 31fce2e1ee..c4a8c47eff 100644
--- a/cif/org.eclipse.escet.cif.cif2yed/src/org/eclipse/escet/cif/cif2yed/CifToYedRelationsDiagramPreChecker.java
+++ b/cif/org.eclipse.escet.cif.cif2yed/src/org/eclipse/escet/cif/cif2yed/CifToYedRelationsDiagramPreChecker.java
@@ -14,6 +14,8 @@
 package org.eclipse.escet.cif.cif2yed;
 
 import org.eclipse.escet.cif.checkers.CifPreconditionChecker;
+import org.eclipse.escet.cif.checkers.checks.CompDefNoSpecificParamsCheck;
+import org.eclipse.escet.cif.checkers.checks.CompDefNoSpecificParamsCheck.NoSpecificCompDefParam;
 import org.eclipse.escet.common.java.Termination;
 
 /** CIF to yEd transformation precondition checker for generating relations diagrams. */
@@ -24,7 +26,9 @@ public class CifToYedRelationsDiagramPreChecker extends CifPreconditionChecker {
      * @param termination Cooperative termination query function.
      */
     public CifToYedRelationsDiagramPreChecker(Termination termination) {
-        super(termination
+        super(termination,
+
+                new CompDefNoSpecificParamsCheck(NoSpecificCompDefParam.COMPONENT)
 
         );
     }
-- 
GitLab


From 68ea95121287bd38168fb54b678caf24d82cc382 Mon Sep 17 00:00:00 2001
From: Dennis Hendriks <dh_tue@hotmail.com>
Date: Tue, 30 Jul 2024 13:47:03 +0200
Subject: [PATCH 4/5] #424 Update CIF to yEd test output.

---
 .../tests/cif2yed/comp_param.relations.err               | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/cif/org.eclipse.escet.cif.tests/tests/cif2yed/comp_param.relations.err b/cif/org.eclipse.escet.cif.tests/tests/cif2yed/comp_param.relations.err
index 8b4eca1cae..3373715e73 100644
--- a/cif/org.eclipse.escet.cif.tests/tests/cif2yed/comp_param.relations.err
+++ b/cif/org.eclipse.escet.cif.tests/tests/cif2yed/comp_param.relations.err
@@ -1,2 +1,9 @@
 ERROR: Failed to generate a yEd relations diagram for CIF file "cif2yed/comp_param.cif".
-CAUSE: Component parameter "g1.G2.p3" is not supported.
+CAUSE: CIF to yEd transformer failed due to unsatisfied preconditions:
+
+  -------------------------------------------------------
+  (1/1) A component definition has a component parameter.
+  -------------------------------------------------------
+   * In group definition "g1.G2":
+     - group def G2(g6.G7 p3):
+                          ^
-- 
GitLab


From 114626180bd7f2e31eb8dfc061dec89a95b690a0 Mon Sep 17 00:00:00 2001
From: Dennis Hendriks <dh_tue@hotmail.com>
Date: Wed, 31 Jul 2024 08:15:30 +0200
Subject: [PATCH 5/5] #424 CifToYedRelationsDiagramPreChecker: source code
 layout improvement.

---
 .../cif/cif2yed/CifToYedRelationsDiagramPreChecker.java     | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/cif/org.eclipse.escet.cif.cif2yed/src/org/eclipse/escet/cif/cif2yed/CifToYedRelationsDiagramPreChecker.java b/cif/org.eclipse.escet.cif.cif2yed/src/org/eclipse/escet/cif/cif2yed/CifToYedRelationsDiagramPreChecker.java
index c4a8c47eff..5a3a944598 100644
--- a/cif/org.eclipse.escet.cif.cif2yed/src/org/eclipse/escet/cif/cif2yed/CifToYedRelationsDiagramPreChecker.java
+++ b/cif/org.eclipse.escet.cif.cif2yed/src/org/eclipse/escet/cif/cif2yed/CifToYedRelationsDiagramPreChecker.java
@@ -26,10 +26,6 @@ public class CifToYedRelationsDiagramPreChecker extends CifPreconditionChecker {
      * @param termination Cooperative termination query function.
      */
     public CifToYedRelationsDiagramPreChecker(Termination termination) {
-        super(termination,
-
-                new CompDefNoSpecificParamsCheck(NoSpecificCompDefParam.COMPONENT)
-
-        );
+        super(termination, new CompDefNoSpecificParamsCheck(NoSpecificCompDefParam.COMPONENT));
     }
 }
-- 
GitLab