Bugfix: Update stale cache values in RuleInfo
Fixes a bug in the macher: During the matching of multi-rules, stale
parameter values from previous executions were loaded from the cached
RuleInfo class.
diff --git a/plugins/org.eclipse.emf.henshin.interpreter/src/org/eclipse/emf/henshin/interpreter/impl/EngineImpl.java b/plugins/org.eclipse.emf.henshin.interpreter/src/org/eclipse/emf/henshin/interpreter/impl/EngineImpl.java
index bd970aa..604a3be 100644
--- a/plugins/org.eclipse.emf.henshin.interpreter/src/org/eclipse/emf/henshin/interpreter/impl/EngineImpl.java
+++ b/plugins/org.eclipse.emf.henshin.interpreter/src/org/eclipse/emf/henshin/interpreter/impl/EngineImpl.java
@@ -451,7 +451,6 @@
while (matchFinder.hasNext()) {
nestedMatches.add(matchFinder.next());
}
-
}
boolean valid = rule.getMultiRules().isEmpty() || doPostponedDanglingChecks(solution, nextMatch);
@@ -862,6 +861,8 @@
+ "'. Register the corresponding package, e.g. using PackageName.eINSTANCE.getName().");
}
}
+ } else {
+ ruleInfo.updateCached();
}
return ruleInfo;
}
diff --git a/plugins/org.eclipse.emf.henshin.interpreter/src/org/eclipse/emf/henshin/interpreter/info/RuleInfo.java b/plugins/org.eclipse.emf.henshin.interpreter/src/org/eclipse/emf/henshin/interpreter/info/RuleInfo.java
index 3511ab0..0878d57 100644
--- a/plugins/org.eclipse.emf.henshin.interpreter/src/org/eclipse/emf/henshin/interpreter/info/RuleInfo.java
+++ b/plugins/org.eclipse.emf.henshin.interpreter/src/org/eclipse/emf/henshin/interpreter/info/RuleInfo.java
@@ -14,6 +14,7 @@
import java.util.Set;
import org.eclipse.emf.henshin.interpreter.impl.EngineImpl;
+import org.eclipse.emf.henshin.interpreter.matching.constraints.Variable;
import org.eclipse.emf.henshin.model.Mapping;
import org.eclipse.emf.henshin.model.Node;
import org.eclipse.emf.henshin.model.Rule;
@@ -80,4 +81,8 @@
public Collection<Node> getPostponed() {
return postponed;
}
+
+ public void updateCached() {
+ variableInfo.updateCached();
+ }
}
\ No newline at end of file
diff --git a/plugins/org.eclipse.emf.henshin.interpreter/src/org/eclipse/emf/henshin/interpreter/info/VariableInfo.java b/plugins/org.eclipse.emf.henshin.interpreter/src/org/eclipse/emf/henshin/interpreter/info/VariableInfo.java
index 64de55f..620a3ff 100644
--- a/plugins/org.eclipse.emf.henshin.interpreter/src/org/eclipse/emf/henshin/interpreter/info/VariableInfo.java
+++ b/plugins/org.eclipse.emf.henshin.interpreter/src/org/eclipse/emf/henshin/interpreter/info/VariableInfo.java
@@ -182,21 +182,7 @@
}
// Attributes:
- for (Attribute attribute : node.getAttributes()) {
- String value = attribute.getValue();
- AttributeConstraint constraint;
- if (rule.getParameter(value) != null) {
- constraint = new AttributeConstraint(attribute.getType(), value, false);
- } else {
- Object constant = engine.evalAttributeExpression(attribute, rule);
- constraint = new AttributeConstraint(attribute.getType(), constant, true);
- }
- var.attributeConstraints.add(constraint);
- UnaryConstraint unaryUserConstraint = engine.createUserConstraints(attribute);
- if (unaryUserConstraint != null) {
- var.attributeUserConstraints.put(constraint, unaryUserConstraint);
- }
- }
+ createAttributeConstraints(node, var);
// Path constraints:
if (node.getGraph() == rule.getLhs() && !rule.getLhs().getPACs().isEmpty()) {
@@ -215,6 +201,24 @@
}
+ private void createAttributeConstraints(Node node, Variable var) {
+ for (Attribute attribute : node.getAttributes()) {
+ String value = attribute.getValue();
+ AttributeConstraint constraint;
+ if (rule.getParameter(value) != null) {
+ constraint = new AttributeConstraint(attribute.getType(), value, false);
+ } else {
+ Object constant = engine.evalAttributeExpression(attribute, rule);
+ constraint = new AttributeConstraint(attribute.getType(), constant, true);
+ }
+ var.attributeConstraints.add(constraint);
+ UnaryConstraint unaryUserConstraint = engine.createUserConstraints(attribute);
+ if (unaryUserConstraint != null) {
+ var.attributeUserConstraints.put(constraint, unaryUserConstraint);
+ }
+ }
+ }
+
private void createDanglingConstraints(Node node, boolean postpone) {
Variable var = node2variable.get(node);
@@ -316,4 +320,11 @@
private static final Integer ONE = new Integer(1);
+ public void updateCached() {
+ for (Entry<Variable, Node> entry : variable2node.entrySet()) {
+ entry.getKey().attributeConstraints.clear();
+ createAttributeConstraints(entry.getValue(), entry.getKey());
+ }
+ }
+
}