corrected at-most-one-container validation check
Change-Id: Ifd65c5e873a6db8777bf51ffaa357e3ef8ce46ca
Signed-off-by: Christian Krause <henshin.ck@gmail.com>
diff --git a/plugins/org.eclipse.emf.henshin.model/src/org/eclipse/emf/henshin/model/util/HenshinValidator.java b/plugins/org.eclipse.emf.henshin.model/src/org/eclipse/emf/henshin/model/util/HenshinValidator.java
index ece1d53..d03f96e 100644
--- a/plugins/org.eclipse.emf.henshin.model/src/org/eclipse/emf/henshin/model/util/HenshinValidator.java
+++ b/plugins/org.eclipse.emf.henshin.model/src/org/eclipse/emf/henshin/model/util/HenshinValidator.java
@@ -10,8 +10,9 @@
package org.eclipse.emf.henshin.model.util;
import java.util.ArrayList;
-import java.util.HashMap;
+import java.util.HashSet;
import java.util.Map;
+import java.util.Set;
import java.util.regex.Pattern;
import javax.script.ScriptException;
@@ -689,34 +690,23 @@
* @generated NOT
*/
public boolean validateNode_atMostOneContainer(Node node, DiagnosticChain diagnostics, Map<Object, Object> context) {
- boolean result = true;
- Map<EReference, Node> containments = new HashMap<EReference, Node>();
+ Set<Node> containers = new HashSet<Node>();
for (Edge incoming : node.getIncoming()) {
EReference type = incoming.getType();
if (type != null && type.isContainment()) {
- Node container = containments.get(type);
- if (container != null && container != incoming.getSource()) {
- result = false;
- break;
- }
- containments.put(type, incoming.getSource());
+ containers.add(incoming.getSource());
}
}
for (Edge outgoing : node.getOutgoing()) {
EReference type = outgoing.getType();
if (type != null && type.isContainer() && type.getEOpposite() != null) {
- Node container = containments.get(type.getEOpposite());
- if (container != null && container != outgoing.getTarget()) {
- result = false;
- break;
- }
- containments.put(type.getEOpposite(), outgoing.getTarget());
+ containers.add(outgoing.getTarget());
}
}
- if (!result) {
- diagnostics.add(createDiagnostic(Diagnostic.ERROR, node, Node.class, "atMostOneContainer", context));
+ if (containers.size() > 1) {
+ diagnostics.add(createDiagnostic(Diagnostic.ERROR, node.getActionNode(), Node.class, "atMostOneContainer", context));
}
- return result;
+ return false;
}
/**