Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Heidelmeier2018-07-21 14:24:53 +0000
committerDaniel Strueber2018-08-15 09:40:26 +0000
commit459ba6865de52c2345211ad58891a21e68f24b9d (patch)
treec802f145620128061c8047fa740fded271ffcc2c
parent3efad0ba29c30ddaaba2de676f3a965567e4abb6 (diff)
downloadorg.eclipse.emft.henshin-459ba6865de52c2345211ad58891a21e68f24b9d.tar.gz
org.eclipse.emft.henshin-459ba6865de52c2345211ad58891a21e68f24b9d.tar.xz
org.eclipse.emft.henshin-459ba6865de52c2345211ad58891a21e68f24b9d.zip
Fix Bug 537256
* Extract method: areNecessaryParameterSet * Move invocation to RuleApplication.execute(...) * Add invocation in UnitApplication.execute(...) Breaks 2 tests in ExamplesTest package because of misuse of IN/INOUT parameters in these examples: * testCombPattern * testEcore2GenModel Signed-off-by: Benjamin Heidelmeier <heidelme@students.uni-marburg.de>
-rw-r--r--plugins/org.eclipse.emf.henshin.interpreter/src/org/eclipse/emf/henshin/interpreter/impl/RuleApplicationImpl.java16
-rw-r--r--plugins/org.eclipse.emf.henshin.interpreter/src/org/eclipse/emf/henshin/interpreter/impl/UnitApplicationImpl.java5
-rw-r--r--plugins/org.eclipse.emf.henshin.interpreter/src/org/eclipse/emf/henshin/interpreter/util/InterpreterUtil.java19
3 files changed, 29 insertions, 11 deletions
diff --git a/plugins/org.eclipse.emf.henshin.interpreter/src/org/eclipse/emf/henshin/interpreter/impl/RuleApplicationImpl.java b/plugins/org.eclipse.emf.henshin.interpreter/src/org/eclipse/emf/henshin/interpreter/impl/RuleApplicationImpl.java
index ca5d9bb57..8a89c424a 100644
--- a/plugins/org.eclipse.emf.henshin.interpreter/src/org/eclipse/emf/henshin/interpreter/impl/RuleApplicationImpl.java
+++ b/plugins/org.eclipse.emf.henshin.interpreter/src/org/eclipse/emf/henshin/interpreter/impl/RuleApplicationImpl.java
@@ -9,7 +9,6 @@
*/
package org.eclipse.emf.henshin.interpreter.impl;
-import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.henshin.interpreter.ApplicationMonitor;
import org.eclipse.emf.henshin.interpreter.Assignment;
import org.eclipse.emf.henshin.interpreter.Change;
@@ -22,6 +21,8 @@ import org.eclipse.emf.henshin.model.ParameterKind;
import org.eclipse.emf.henshin.model.Rule;
import org.eclipse.emf.henshin.model.Unit;
+import static org.eclipse.emf.henshin.interpreter.util.InterpreterUtil.areNecessaryParametersSet;
+
/**
* Default {@link RuleApplication} implementation.
*
@@ -87,6 +88,9 @@ public class RuleApplicationImpl extends AbstractApplicationImpl implements Rule
change = null;
resultMatch = null;
}
+
+ areNecessaryParametersSet(unit.getParameters(), unit.getName(), partialMatch);
+
// Do we need to derive a complete match?
if (completeMatch==null) {
completeMatch = engine.findMatches((Rule) unit, graph, partialMatch).iterator().next();
@@ -214,16 +218,6 @@ public class RuleApplicationImpl extends AbstractApplicationImpl implements Rule
partialMatch = new MatchImpl(assignment, false);
}
- if(partialMatch != null) {
- EList<Parameter> unitParameters = unit.getParameters();
- for (Parameter param : unitParameters) {
- ParameterKind kind = param.getKind();
- if((kind == ParameterKind.INOUT || kind == ParameterKind.IN) && partialMatch.getParameterValue(param) == null) {
- throw new IllegalStateException(unit.getName() + ": " + kind + " Parameter " + param.getName() + " not set");
- }
- }
- }
-
this.completeMatch = null;
this.resultMatch = null;
this.change = null;
diff --git a/plugins/org.eclipse.emf.henshin.interpreter/src/org/eclipse/emf/henshin/interpreter/impl/UnitApplicationImpl.java b/plugins/org.eclipse.emf.henshin.interpreter/src/org/eclipse/emf/henshin/interpreter/impl/UnitApplicationImpl.java
index 35a7a2eb0..48b7c3526 100644
--- a/plugins/org.eclipse.emf.henshin.interpreter/src/org/eclipse/emf/henshin/interpreter/impl/UnitApplicationImpl.java
+++ b/plugins/org.eclipse.emf.henshin.interpreter/src/org/eclipse/emf/henshin/interpreter/impl/UnitApplicationImpl.java
@@ -36,6 +36,8 @@ import org.eclipse.emf.henshin.model.Rule;
import org.eclipse.emf.henshin.model.SequentialUnit;
import org.eclipse.emf.henshin.model.Unit;
+import static org.eclipse.emf.henshin.interpreter.util.InterpreterUtil.areNecessaryParametersSet;
+
/**
* Default {@link UnitApplication} implementation.
*
@@ -82,6 +84,9 @@ public class UnitApplicationImpl extends AbstractApplicationImpl {
if (monitor==null) {
monitor = InterpreterFactory.INSTANCE.createApplicationMonitor();
}
+
+ areNecessaryParametersSet(unit.getParameters(), unit.getName(), assignment);
+
appliedRules.clear();
undoneRules.clear();
resultAssignment = (assignment!=null) ?
diff --git a/plugins/org.eclipse.emf.henshin.interpreter/src/org/eclipse/emf/henshin/interpreter/util/InterpreterUtil.java b/plugins/org.eclipse.emf.henshin.interpreter/src/org/eclipse/emf/henshin/interpreter/util/InterpreterUtil.java
index edcf2a587..02617d232 100644
--- a/plugins/org.eclipse.emf.henshin.interpreter/src/org/eclipse/emf/henshin/interpreter/util/InterpreterUtil.java
+++ b/plugins/org.eclipse.emf.henshin.interpreter/src/org/eclipse/emf/henshin/interpreter/util/InterpreterUtil.java
@@ -37,6 +37,8 @@ import org.eclipse.emf.henshin.interpreter.impl.EGraphImpl;
import org.eclipse.emf.henshin.interpreter.impl.UnitApplicationImpl;
import org.eclipse.emf.henshin.model.Module;
import org.eclipse.emf.henshin.model.Node;
+import org.eclipse.emf.henshin.model.Parameter;
+import org.eclipse.emf.henshin.model.ParameterKind;
import org.eclipse.emf.henshin.model.Rule;
import org.eclipse.emf.henshin.model.Unit;
@@ -536,4 +538,21 @@ public class InterpreterUtil {
return (match != null) ? true : false;
}
+ /**
+ * Check whether all {@link Parameter} of {@link ParameterKind} IN and INOUT of the {@link Unit} are set.
+ *
+ * @param parameters All {@link Parameter} of the unit.
+ * @param unitName The name of the {@link Unit}.
+ * @param assignment The current {@link Assignment} of the {@link UnitApplication}.
+ */
+ public static void areNecessaryParametersSet(Iterable<Parameter> parameters, String unitName,
+ Assignment assignment) throws IllegalStateException {
+ for (Parameter param : parameters) {
+ ParameterKind kind = param.getKind();
+ if((kind == ParameterKind.INOUT || kind == ParameterKind.IN) &&
+ (assignment == null || assignment.getParameterValue(param) == null)) {
+ throw new IllegalStateException(unitName + ": " + kind + " Parameter " + param.getName() + " not set");
+ }
+ }
+ }
}

Back to the top