From 708c4c609add5b1f3976328e191ddf142e546fb3 Mon Sep 17 00:00:00 2001
From: Andreas Bayha <bayha@fortiss.org>
Date: Thu, 3 Aug 2023 13:36:35 +0200
Subject: [PATCH] YELLOW

Issue-ref: 4240
Issue-URL: https://git.fortiss.org/af3/af3/-/issues/4240

Signed-off-by: Andreas Bayha <bayha@fortiss.org>
---
 .../org/fortiss/variability/analysis/.ratings |  2 +-
 .../analysis/EMFProductLineTranslation.java   | 33 ++++++++++---------
 2 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/org.fortiss.variability/src/org/fortiss/variability/analysis/.ratings b/org.fortiss.variability/src/org/fortiss/variability/analysis/.ratings
index cdb6b56d7..a302ddf4b 100644
--- a/org.fortiss.variability/src/org/fortiss/variability/analysis/.ratings
+++ b/org.fortiss.variability/src/org/fortiss/variability/analysis/.ratings
@@ -1,6 +1,6 @@
 BucketSetMap.java 665a28c80a9693b9b9e31b7ebe59f2de4195d56c YELLOW
 DualKeyMap.java 75fbe85a54e5a655aaf67108ae004f98ed2879d8 YELLOW
-EMFProductLineTranslation.java 58487bc6e6f31115ff5388fcc204dd55a545f106 YELLOW
+EMFProductLineTranslation.java 6fe2de9772ab505ddf002842d4fedddccfc8dd0b YELLOW
 GenericProductLineAnalysis.java 6f6d48544ec2b872fa0a4f747a85657889ad463e YELLOW
 IProductLineConstraint.java 1b0e1231cc578a6e7e544441ac33533b4feafeb1 YELLOW
 IProductLineTranslation.java 733dae03e2baae237b6f0b33f0dd618a4f47cf73 YELLOW
diff --git a/org.fortiss.variability/src/org/fortiss/variability/analysis/EMFProductLineTranslation.java b/org.fortiss.variability/src/org/fortiss/variability/analysis/EMFProductLineTranslation.java
index 58487bc6e..6fe2de977 100644
--- a/org.fortiss.variability/src/org/fortiss/variability/analysis/EMFProductLineTranslation.java
+++ b/org.fortiss.variability/src/org/fortiss/variability/analysis/EMFProductLineTranslation.java
@@ -129,35 +129,29 @@ public class EMFProductLineTranslation implements IProductLineTranslation {
 	private Map<EReference, EClass> reference2TranslatedEClass;
 
 	/** Mapping of attributes to their translated Z3 function. */
-	private DualKeyMap<EAttribute, EClass, FuncDecl<?>> eAttribute2FunDecl =
-			new DualKeyMap<EAttribute, EClass, FuncDecl<?>>();
+	private DualKeyMap<EAttribute, EClass, FuncDecl<?>> eAttribute2FunDecl;
 	/** Mapping of references to their translated Z3 function. */
-	private DualKeyMap<EReference, EClass, FuncDecl<?>> eReference2FunDecl =
-			new DualKeyMap<EReference, EClass, FuncDecl<?>>();
+	private DualKeyMap<EReference, EClass, FuncDecl<?>> eReference2FunDecl;
 
 	/* Model related fields */
 
+	/** The mapping of translated {@link EClass} to the objects that have been collected. */
+	private BucketSetMap<EClass, EObject> class2TranslatedEObjects;
+
 	/**
 	 * Mapping of objects with types to their translated Z3 expressions. The second key EClass is
 	 * necessary as an object is translated for all classes specified in 'translatedClasses').
 	 */
-	private DualKeyMap<EObject, EClass, Expr<?>> eObject2z3Expr =
-			new DualKeyMap<EObject, EClass, Expr<?>>();
+	private DualKeyMap<EObject, EClass, Expr<?>> eObject2z3Expr;
 
 	/**
 	 * The mapping from Z3 {@link Expr} back to the respective {@link EObject} to be used for
 	 * interpreting solver results.
 	 */
-	private Map<Expr<?>, EObject> expr2EObject = new HashMap<Expr<?>, EObject>();
-
-	/** The mapping of translated {@link EClass} to the objects that have been collected. */
-	private BucketSetMap<EClass, EObject> class2TranslatedEObjects;
+	private Map<Expr<?>, EObject> z3Expr2EObject;
 
 	/* Variability related fields */
 
-	/** Mapping of classes to the selection function for this type. */
-	private Map<EClass, FuncDecl<?>> eClass2SelectionFunction;
-
 	/** The {@link AbstractFeatureModel} collected by this translation */
 	private AbstractFeatureModel featureModel;
 	/** Mapping of features to corresponding Z3 {@link BoolExpr}. */
@@ -166,6 +160,9 @@ public class EMFProductLineTranslation implements IProductLineTranslation {
 	/** The mapping of translated {@link EObject}s to global {@link PresenceCondition}s. */
 	private Map<EObject, PresenceConditionTerm> object2presenceCondition;
 
+	/** Mapping of classes to the selection function for this type. */
+	private Map<EClass, FuncDecl<?>> eClass2SelectionFunction;
+
 	/**
 	 * Constructor.
 	 */
@@ -202,6 +199,12 @@ public class EMFProductLineTranslation implements IProductLineTranslation {
 		eClass2SelectionFunction = new HashMap<EClass, FuncDecl<?>>();
 		feature2BoolExpr = new HashMap<AbstractFeature, BoolExpr>();
 
+		eAttribute2FunDecl = new DualKeyMap<EAttribute, EClass, FuncDecl<?>>();
+		eReference2FunDecl = new DualKeyMap<EReference, EClass, FuncDecl<?>>();
+
+		eObject2z3Expr = new DualKeyMap<EObject, EClass, Expr<?>>();
+		z3Expr2EObject = new HashMap<Expr<?>, EObject>();
+
 		// Initialize model independent base types
 		intSort = ctx.mkIntSort();
 		stringSort = ctx.mkStringSort();
@@ -780,7 +783,7 @@ public class EMFProductLineTranslation implements IProductLineTranslation {
 			Expr<?>[] consts = enumSort.getConsts();
 			for(int i = 0; i < objs.size(); i++) {
 				eObject2z3Expr.put(objs.get(i), cls, consts[i]);
-				expr2EObject.put(consts[i], objs.get(i));
+				z3Expr2EObject.put(consts[i], objs.get(i));
 			}
 			Expr<?> noneExpr = consts[consts.length - 1];
 			eClass2NullElement.put(cls, noneExpr);
@@ -811,7 +814,7 @@ public class EMFProductLineTranslation implements IProductLineTranslation {
 	/** {@inheritDoc} */
 	@Override
 	public EObject getEObjectForExpression(Expr<?> expr) {
-		return expr2EObject.get(expr);
+		return z3Expr2EObject.get(expr);
 	}
 
 	/** {@inheritDoc} */
-- 
GitLab