Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Delaigue2015-12-15 14:57:04 +0000
committerLaurent Delaigue2016-01-05 08:00:21 +0000
commit6e901be5ab8674072fab250add2f996d4298a17f (patch)
treef700855d013edc36a00c93b8d3148741ce4bc048
parentc7e79fa544cfda7500847adfc0881a9c7513ee74 (diff)
downloadorg.eclipse.emf.compare-6e901be5ab8674072fab250add2f996d4298a17f.tar.gz
org.eclipse.emf.compare-6e901be5ab8674072fab250add2f996d4298a17f.tar.xz
org.eclipse.emf.compare-6e901be5ab8674072fab250add2f996d4298a17f.zip
[484577] Make sure 'requires' are on the same side
Former implementation caused diffs from different sides to be linked by 'requires/requiredBy' or 'refines/refinedBy' references, which does not make sense and caused erroneous behavior. Bug: 484577 Change-Id: Ia23a41a4edd8d4336555a1423ce1d56f529662c9 Signed-off-by: Laurent Delaigue <laurent.delaigue@obeo.fr>
-rw-r--r--plugins/org.eclipse.emf.compare.diagram.papyrus/src/org/eclipse/emf/compare/diagram/papyrus/internal/PapyrusDiagramPostComparison.java9
-rw-r--r--plugins/org.eclipse.emf.compare.diagram/src/org/eclipse/emf/compare/diagram/internal/factories/extensions/CoordinatesChangeFactory.java4
-rw-r--r--plugins/org.eclipse.emf.compare.diagram/src/org/eclipse/emf/compare/diagram/internal/factories/extensions/DiagramChangeFactory.java14
-rw-r--r--plugins/org.eclipse.emf.compare.diagram/src/org/eclipse/emf/compare/diagram/internal/factories/extensions/EdgeChangeFactory.java8
-rw-r--r--plugins/org.eclipse.emf.compare.diagram/src/org/eclipse/emf/compare/diagram/internal/factories/extensions/HideFactory.java6
-rw-r--r--plugins/org.eclipse.emf.compare.diagram/src/org/eclipse/emf/compare/diagram/internal/factories/extensions/NodeChangeFactory.java19
-rw-r--r--plugins/org.eclipse.emf.compare.diagram/src/org/eclipse/emf/compare/diagram/internal/factories/extensions/ShowFactory.java6
-rw-r--r--plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/AbstractUMLChangeFactory.java6
-rw-r--r--plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/UMLPostProcessor.java10
-rw-r--r--plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/UMLOpaqueElementBodyChangeFactory.java16
-rw-r--r--plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/profile/UMLProfileApplicationChangeFactory.java3
-rw-r--r--plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/stereotype/UMLDanglingStereotypeApplicationFactory.java14
-rw-r--r--plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/stereotype/UMLStereotypeApplicationChangeFactory.java7
-rw-r--r--plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/stereotype/UMLStereotypeAttributeChangeFactory.java4
-rw-r--r--plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/stereotype/UMLStereotypeReferenceChangeFactory.java6
-rw-r--r--plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/stereotype/UMLStereotypedElementChangeFactory.java12
-rw-r--r--plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/postprocessor/factories/AbstractChangeFactory.java19
-rw-r--r--plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/req/DefaultReqEngine.java12
-rw-r--r--plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/utils/EMFComparePredicates.java18
19 files changed, 136 insertions, 57 deletions
diff --git a/plugins/org.eclipse.emf.compare.diagram.papyrus/src/org/eclipse/emf/compare/diagram/papyrus/internal/PapyrusDiagramPostComparison.java b/plugins/org.eclipse.emf.compare.diagram.papyrus/src/org/eclipse/emf/compare/diagram/papyrus/internal/PapyrusDiagramPostComparison.java
index 7044ee137..bdf167c71 100644
--- a/plugins/org.eclipse.emf.compare.diagram.papyrus/src/org/eclipse/emf/compare/diagram/papyrus/internal/PapyrusDiagramPostComparison.java
+++ b/plugins/org.eclipse.emf.compare.diagram.papyrus/src/org/eclipse/emf/compare/diagram/papyrus/internal/PapyrusDiagramPostComparison.java
@@ -10,9 +10,6 @@
*******************************************************************************/
package org.eclipse.emf.compare.diagram.papyrus.internal;
-import com.google.common.collect.Sets;
-
-import java.util.Collections;
import java.util.Set;
import org.eclipse.emf.compare.Comparison;
@@ -70,7 +67,11 @@ public class PapyrusDiagramPostComparison implements Runnable {
Set<Diff> diffs = indexer.getEquivalentDiffs(key);
if (diffs.size() > 1) {
for (Diff diff : diffs) {
- diff.getRequires().addAll(Sets.difference(diffs, Collections.singleton(diff)));
+ for (Diff other : diffs) {
+ if (other != diff && other.getSource() == diff.getSource()) {
+ diff.getRequires().add(other);
+ }
+ }
}
}
}
diff --git a/plugins/org.eclipse.emf.compare.diagram/src/org/eclipse/emf/compare/diagram/internal/factories/extensions/CoordinatesChangeFactory.java b/plugins/org.eclipse.emf.compare.diagram/src/org/eclipse/emf/compare/diagram/internal/factories/extensions/CoordinatesChangeFactory.java
index bff0c6a51..1547010de 100644
--- a/plugins/org.eclipse.emf.compare.diagram/src/org/eclipse/emf/compare/diagram/internal/factories/extensions/CoordinatesChangeFactory.java
+++ b/plugins/org.eclipse.emf.compare.diagram/src/org/eclipse/emf/compare/diagram/internal/factories/extensions/CoordinatesChangeFactory.java
@@ -89,7 +89,9 @@ public class CoordinatesChangeFactory extends NodeChangeFactory {
@Override
public void setRefiningChanges(Diff extension, DifferenceKind extensionKind, Diff refiningDiff) {
if (extensionKind == DifferenceKind.CHANGE) {
- extension.getRefinedBy().addAll(getAllDifferencesForChange(refiningDiff));
+ extension.getRefinedBy().addAll(
+ Collections2.filter(getAllDifferencesForChange(refiningDiff), fromSide(extension
+ .getSource())));
}
}
diff --git a/plugins/org.eclipse.emf.compare.diagram/src/org/eclipse/emf/compare/diagram/internal/factories/extensions/DiagramChangeFactory.java b/plugins/org.eclipse.emf.compare.diagram/src/org/eclipse/emf/compare/diagram/internal/factories/extensions/DiagramChangeFactory.java
index 67db74e1e..e63e3404d 100644
--- a/plugins/org.eclipse.emf.compare.diagram/src/org/eclipse/emf/compare/diagram/internal/factories/extensions/DiagramChangeFactory.java
+++ b/plugins/org.eclipse.emf.compare.diagram/src/org/eclipse/emf/compare/diagram/internal/factories/extensions/DiagramChangeFactory.java
@@ -11,6 +11,7 @@
package org.eclipse.emf.compare.diagram.internal.factories.extensions;
import com.google.common.base.Predicate;
+import com.google.common.collect.Collections2;
import org.eclipse.emf.compare.Comparison;
import org.eclipse.emf.compare.Diff;
@@ -20,6 +21,7 @@ import org.eclipse.emf.compare.diagram.internal.extensions.DiagramChange;
import org.eclipse.emf.compare.diagram.internal.extensions.DiagramDiff;
import org.eclipse.emf.compare.diagram.internal.extensions.ExtensionsFactory;
import org.eclipse.emf.compare.diagram.internal.factories.AbstractDiagramChangeFactory;
+import org.eclipse.emf.compare.utils.EMFComparePredicates;
import org.eclipse.emf.compare.utils.MatchUtil;
import org.eclipse.emf.compare.utils.ReferenceUtil;
import org.eclipse.emf.ecore.EObject;
@@ -69,13 +71,19 @@ public class DiagramChangeFactory extends AbstractDiagramChangeFactory {
public void setRefiningChanges(Diff extension, DifferenceKind extensionKind, Diff refiningDiff) {
// Macroscopic change on a diagram is refined by the unit main change and all unit children related
// changes.
- extension.getRefinedBy().add(refiningDiff);
- extension.getRefinedBy().addAll(getAllContainedDifferences(refiningDiff));
+ if (refiningDiff.getSource() == extension.getSource()) {
+ extension.getRefinedBy().add(refiningDiff);
+ extension.getRefinedBy().addAll(
+ Collections2.filter(getAllContainedDifferences(refiningDiff), EMFComparePredicates
+ .fromSide(extension.getSource())));
+ }
}
/**
* {@inheritDoc}
- * @see org.eclipse.emf.compare.internal.postprocessor.factories.AbstractChangeFactory#fillRequiredDifferences(org.eclipse.emf.compare.Comparison, org.eclipse.emf.compare.Diff)
+ *
+ * @see org.eclipse.emf.compare.internal.postprocessor.factories.AbstractChangeFactory#fillRequiredDifferences(org.eclipse.emf.compare.Comparison,
+ * org.eclipse.emf.compare.Diff)
*/
@Override
public void fillRequiredDifferences(Comparison comparison, Diff extension) {
diff --git a/plugins/org.eclipse.emf.compare.diagram/src/org/eclipse/emf/compare/diagram/internal/factories/extensions/EdgeChangeFactory.java b/plugins/org.eclipse.emf.compare.diagram/src/org/eclipse/emf/compare/diagram/internal/factories/extensions/EdgeChangeFactory.java
index 7a15bb30e..fa730153f 100644
--- a/plugins/org.eclipse.emf.compare.diagram/src/org/eclipse/emf/compare/diagram/internal/factories/extensions/EdgeChangeFactory.java
+++ b/plugins/org.eclipse.emf.compare.diagram/src/org/eclipse/emf/compare/diagram/internal/factories/extensions/EdgeChangeFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013 Obeo.
+ * Copyright (c) 2013, 2015 Obeo.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -11,6 +11,7 @@
package org.eclipse.emf.compare.diagram.internal.factories.extensions;
import com.google.common.base.Predicate;
+import com.google.common.collect.Collections2;
import com.google.common.collect.Iterables;
import com.google.common.collect.Iterators;
@@ -27,6 +28,7 @@ import org.eclipse.emf.compare.ReferenceChange;
import org.eclipse.emf.compare.diagram.internal.extensions.DiagramDiff;
import org.eclipse.emf.compare.diagram.internal.extensions.EdgeChange;
import org.eclipse.emf.compare.diagram.internal.extensions.ExtensionsFactory;
+import org.eclipse.emf.compare.utils.EMFComparePredicates;
import org.eclipse.emf.compare.utils.MatchUtil;
import org.eclipse.emf.compare.utils.ReferenceUtil;
import org.eclipse.emf.ecore.EObject;
@@ -81,7 +83,9 @@ public class EdgeChangeFactory extends NodeChangeFactory {
public void setRefiningChanges(Diff extension, DifferenceKind extensionKind, Diff refiningDiff) {
super.setRefiningChanges(extension, extensionKind, refiningDiff);
if (extensionKind == DifferenceKind.CHANGE) {
- extension.getRefinedBy().addAll(getAllDifferencesForChange(refiningDiff));
+ extension.getRefinedBy().addAll(
+ Collections2.filter(getAllDifferencesForChange(refiningDiff), EMFComparePredicates
+ .fromSide(extension.getSource())));
}
}
diff --git a/plugins/org.eclipse.emf.compare.diagram/src/org/eclipse/emf/compare/diagram/internal/factories/extensions/HideFactory.java b/plugins/org.eclipse.emf.compare.diagram/src/org/eclipse/emf/compare/diagram/internal/factories/extensions/HideFactory.java
index d5a2b9953..228522db0 100644
--- a/plugins/org.eclipse.emf.compare.diagram/src/org/eclipse/emf/compare/diagram/internal/factories/extensions/HideFactory.java
+++ b/plugins/org.eclipse.emf.compare.diagram/src/org/eclipse/emf/compare/diagram/internal/factories/extensions/HideFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013 Obeo.
+ * Copyright (c) 2013, 2015 Obeo.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -56,7 +56,9 @@ public class HideFactory extends AbstractDiagramChangeFactory {
*/
@Override
public void setRefiningChanges(Diff extension, DifferenceKind extensionKind, Diff refiningDiff) {
- extension.getRefinedBy().add(refiningDiff);
+ if (refiningDiff.getSource() == extension.getSource()) {
+ extension.getRefinedBy().add(refiningDiff);
+ }
}
/**
diff --git a/plugins/org.eclipse.emf.compare.diagram/src/org/eclipse/emf/compare/diagram/internal/factories/extensions/NodeChangeFactory.java b/plugins/org.eclipse.emf.compare.diagram/src/org/eclipse/emf/compare/diagram/internal/factories/extensions/NodeChangeFactory.java
index 0e5d93573..399d276ce 100644
--- a/plugins/org.eclipse.emf.compare.diagram/src/org/eclipse/emf/compare/diagram/internal/factories/extensions/NodeChangeFactory.java
+++ b/plugins/org.eclipse.emf.compare.diagram/src/org/eclipse/emf/compare/diagram/internal/factories/extensions/NodeChangeFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013 Obeo.
+ * Copyright (c) 2013, 2015 Obeo.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -12,6 +12,7 @@ package org.eclipse.emf.compare.diagram.internal.factories.extensions;
import static com.google.common.base.Predicates.and;
import static com.google.common.base.Predicates.instanceOf;
+import static org.eclipse.emf.compare.utils.EMFComparePredicates.fromSide;
import static org.eclipse.emf.compare.utils.EMFComparePredicates.ofKind;
import com.google.common.base.Predicate;
@@ -29,6 +30,7 @@ import org.eclipse.emf.compare.diagram.internal.extensions.DiagramDiff;
import org.eclipse.emf.compare.diagram.internal.extensions.ExtensionsFactory;
import org.eclipse.emf.compare.diagram.internal.extensions.NodeChange;
import org.eclipse.emf.compare.diagram.internal.factories.AbstractDiagramChangeFactory;
+import org.eclipse.emf.compare.utils.EMFComparePredicates;
import org.eclipse.emf.compare.utils.ReferenceUtil;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gmf.runtime.notation.Node;
@@ -76,11 +78,14 @@ public class NodeChangeFactory extends AbstractDiagramChangeFactory {
*/
@Override
public void setRefiningChanges(Diff extension, DifferenceKind extensionKind, Diff refiningDiff) {
- // Macroscopic change on a node is refined by the unit main change and unit children related changes.
- extension.getRefinedBy().add(refiningDiff);
- // if (extensionKind != DifferenceKind.MOVE) {
- extension.getRefinedBy().addAll(getAllContainedDifferences(refiningDiff));
- // }
+ if (refiningDiff.getSource() == extension.getSource()) {
+ // Macroscopic change on a node is refined by the unit main change and unit children related
+ // changes.
+ extension.getRefinedBy().add(refiningDiff);
+ extension.getRefinedBy().addAll(
+ Collections2.filter(getAllContainedDifferences(refiningDiff), EMFComparePredicates
+ .fromSide(extension.getSource())));
+ }
}
/**
@@ -108,7 +113,7 @@ public class NodeChangeFactory extends AbstractDiagramChangeFactory {
Set<Diff> requiredExtensions = new HashSet<Diff>();
Set<Diff> requiringExtensions = new HashSet<Diff>();
final Predicate<Diff> moveReference = and(instanceOf(ReferenceChange.class),
- ofKind(DifferenceKind.MOVE));
+ ofKind(DifferenceKind.MOVE), fromSide(extension.getSource()));
Collection<Diff> refiningMoves = Collections2.filter(extension.getRefinedBy(), moveReference);
for (Diff diff : refiningMoves) {
EObject target = ((ReferenceChange)diff).getValue();
diff --git a/plugins/org.eclipse.emf.compare.diagram/src/org/eclipse/emf/compare/diagram/internal/factories/extensions/ShowFactory.java b/plugins/org.eclipse.emf.compare.diagram/src/org/eclipse/emf/compare/diagram/internal/factories/extensions/ShowFactory.java
index e92f436b2..739a00054 100644
--- a/plugins/org.eclipse.emf.compare.diagram/src/org/eclipse/emf/compare/diagram/internal/factories/extensions/ShowFactory.java
+++ b/plugins/org.eclipse.emf.compare.diagram/src/org/eclipse/emf/compare/diagram/internal/factories/extensions/ShowFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013 Obeo.
+ * Copyright (c) 2013, 2015 Obeo.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -40,7 +40,9 @@ public class ShowFactory extends AbstractDiagramChangeFactory {
@Override
public void setRefiningChanges(Diff extension, DifferenceKind extensionKind, Diff refiningDiff) {
- extension.getRefinedBy().add(refiningDiff);
+ if (refiningDiff.getSource() == extension.getSource()) {
+ extension.getRefinedBy().add(refiningDiff);
+ }
}
/**
diff --git a/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/AbstractUMLChangeFactory.java b/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/AbstractUMLChangeFactory.java
index 2f1dbb266..4370061c8 100644
--- a/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/AbstractUMLChangeFactory.java
+++ b/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/AbstractUMLChangeFactory.java
@@ -13,6 +13,7 @@ package org.eclipse.emf.compare.uml2.internal.postprocessor;
import static com.google.common.base.Predicates.instanceOf;
import com.google.common.base.Predicate;
+import com.google.common.collect.Collections2;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Iterables;
import com.google.common.collect.Iterators;
@@ -32,6 +33,7 @@ import org.eclipse.emf.compare.internal.postprocessor.factories.AbstractChangeFa
import org.eclipse.emf.compare.internal.utils.ComparisonUtil;
import org.eclipse.emf.compare.uml2.internal.StereotypeApplicationChange;
import org.eclipse.emf.compare.uml2.internal.UMLDiff;
+import org.eclipse.emf.compare.utils.EMFComparePredicates;
import org.eclipse.emf.compare.utils.MatchUtil;
import org.eclipse.emf.compare.utils.ReferenceUtil;
import org.eclipse.emf.ecore.EObject;
@@ -517,7 +519,9 @@ public abstract class AbstractUMLChangeFactory extends AbstractChangeFactory {
Predicate<Diff> p) {
if (lookup instanceof EObject) {
List<Diff> crossReferences = findCrossReferences(comparison, (EObject)lookup, p);
- refinedExtension.getRefinedBy().addAll(crossReferences);
+ refinedExtension.getRefinedBy().addAll(
+ Collections2.filter(crossReferences, EMFComparePredicates.fromSide(refinedExtension
+ .getSource())));
}
}
diff --git a/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/UMLPostProcessor.java b/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/UMLPostProcessor.java
index 18d1e16f9..ccba87219 100644
--- a/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/UMLPostProcessor.java
+++ b/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/UMLPostProcessor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2014 Obeo.
+ * Copyright (c) 2012, 2015 Obeo.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -332,10 +332,10 @@ public class UMLPostProcessor implements IPostProcessor {
Comparison comparison = diff.getMatch().getComparison();
for (Diff superSetDiff : comparison.getDifferences(superSet)) {
// Only keep diffs on the same ref and value where parent matches
- if (superSetDiff instanceof ReferenceChange
+ if (superSetDiff instanceof ReferenceChange && superSetDiff.getSource() == diff.getSource()
&& ((ReferenceChange)superSetDiff).getReference() == superSet
&& ((ReferenceChange)superSetDiff).getValue() == diff.getValue()
- && ((ReferenceChange)superSetDiff).getMatch() == diff.getMatch()) {
+ && superSetDiff.getMatch() == diff.getMatch()) {
if (isAddOrSetDiff(diff) && isAddOrSetDiff(superSetDiff)) {
diff.getImplies().add(superSetDiff);
} else if (isDeleteOrUnsetDiff(diff) && isDeleteOrUnsetDiff(superSetDiff)) {
@@ -354,9 +354,9 @@ public class UMLPostProcessor implements IPostProcessor {
Comparison comparison = diff.getMatch().getComparison();
for (Diff superSetDiff : comparison.getDifferences(superSet)) {
if (superSetDiff instanceof ReferenceChange
+ && superSetDiff.getSource() == diff.getSource()
&& ((ReferenceChange)superSetDiff).getReference() == superSet
- && ((ReferenceChange)superSetDiff).getMatch() == comparison.getMatch(diff
- .getValue())) {
+ && superSetDiff.getMatch() == comparison.getMatch(diff.getValue())) {
if (isAddOrSetDiff(diff) && isAddOrSetDiff(superSetDiff)) {
diff.getImplies().add(superSetDiff);
} else if (isDeleteOrUnsetDiff(diff) && isDeleteOrUnsetDiff(superSetDiff)) {
diff --git a/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/UMLOpaqueElementBodyChangeFactory.java b/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/UMLOpaqueElementBodyChangeFactory.java
index 032ca5d76..4325da3a9 100644
--- a/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/UMLOpaqueElementBodyChangeFactory.java
+++ b/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/UMLOpaqueElementBodyChangeFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2014 EclipseSource Muenchen GmbH and others.
+ * Copyright (c) 2014, 2015 EclipseSource Muenchen GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* Philip Langer - initial API and implementation
+ * Obeo - Prevent mixing sides in requires/implies/refines
*******************************************************************************/
package org.eclipse.emf.compare.uml2.internal.postprocessor.extension;
@@ -274,8 +275,10 @@ public class UMLOpaqueElementBodyChangeFactory extends AbstractUMLChangeFactory
@Override
public void setRefiningChanges(Diff extension, DifferenceKind extensionKind, Diff refiningDiff) {
final OpaqueElementBodyChange bodyChange = (OpaqueElementBodyChange)extension;
- bodyChange.getRefinedBy().add(refiningDiff);
- collectAndAddOtherRefiningDiffs(bodyChange, refiningDiff);
+ if (refiningDiff.getSource() == bodyChange.getSource()) {
+ bodyChange.getRefinedBy().add(refiningDiff);
+ collectAndAddOtherRefiningDiffs(bodyChange, refiningDiff);
+ }
}
/**
@@ -292,7 +295,9 @@ public class UMLOpaqueElementBodyChangeFactory extends AbstractUMLChangeFactory
final RefinementCollector collector = new RefinementCollector((AttributeChange)refiningDiff);
Iterable<Diff> collectedRefiningDiffs = collector.collect();
for (Diff otherRefiningDiff : collectedRefiningDiffs) {
- bodyChange.getRefinedBy().add(otherRefiningDiff);
+ if (otherRefiningDiff.getSource() == bodyChange.getSource()) {
+ bodyChange.getRefinedBy().add(otherRefiningDiff);
+ }
}
}
@@ -463,7 +468,8 @@ public class UMLOpaqueElementBodyChangeFactory extends AbstractUMLChangeFactory
* otherwise.
*/
private boolean isChangeOfBodyOrLanguageAttribute(AttributeChange attributeChange) {
- return isChangeOfOpaqueElementBodyAttribute(attributeChange) || isChangeOfOpaqueElementLanguageAttribute(attributeChange);
+ return isChangeOfOpaqueElementBodyAttribute(attributeChange)
+ || isChangeOfOpaqueElementLanguageAttribute(attributeChange);
}
}
diff --git a/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/profile/UMLProfileApplicationChangeFactory.java b/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/profile/UMLProfileApplicationChangeFactory.java
index 86fe4f45c..6fce0f764 100644
--- a/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/profile/UMLProfileApplicationChangeFactory.java
+++ b/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/profile/UMLProfileApplicationChangeFactory.java
@@ -110,7 +110,8 @@ public class UMLProfileApplicationChangeFactory extends AbstractUMLChangeFactory
final EObject eObject = stereotypeApplications.next();
for (Diff diff : comparison.getDifferences(eObject)) {
if (diff instanceof StereotypeApplicationChange
- && diff.getKind() == DifferenceKind.DELETE) {
+ && diff.getKind() == DifferenceKind.DELETE
+ && diff.getSource() == profileApplicationChange.getSource()) {
profileApplicationChange.getRequires().add(diff);
}
}
diff --git a/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/stereotype/UMLDanglingStereotypeApplicationFactory.java b/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/stereotype/UMLDanglingStereotypeApplicationFactory.java
index 3b28e8403..ecf78a15c 100644
--- a/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/stereotype/UMLDanglingStereotypeApplicationFactory.java
+++ b/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/stereotype/UMLDanglingStereotypeApplicationFactory.java
@@ -71,12 +71,14 @@ public class UMLDanglingStereotypeApplicationFactory extends AbstractUMLChangeFa
@Override
public void setRefiningChanges(Diff extension, DifferenceKind extensionKind, Diff refiningDiff) {
- extension.getRefinedBy().add(refiningDiff);
- // Unfortunate, don't know how to set the resourceURI elsewhere than here.
- if (refiningDiff instanceof ResourceAttachmentChange
- && extension instanceof DanglingStereotypeApplication) {
- ((DanglingStereotypeApplication)extension)
- .setResourceURI(((ResourceAttachmentChange)refiningDiff).getResourceURI());
+ if (refiningDiff.getSource() == extension.getSource()) {
+ extension.getRefinedBy().add(refiningDiff);
+ // Unfortunate, don't know how to set the resourceURI elsewhere than here.
+ if (refiningDiff instanceof ResourceAttachmentChange
+ && extension instanceof DanglingStereotypeApplication) {
+ ((DanglingStereotypeApplication)extension)
+ .setResourceURI(((ResourceAttachmentChange)refiningDiff).getResourceURI());
+ }
}
}
diff --git a/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/stereotype/UMLStereotypeApplicationChangeFactory.java b/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/stereotype/UMLStereotypeApplicationChangeFactory.java
index fdee6c537..890030a6c 100644
--- a/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/stereotype/UMLStereotypeApplicationChangeFactory.java
+++ b/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/stereotype/UMLStereotypeApplicationChangeFactory.java
@@ -120,8 +120,8 @@ public class UMLStereotypeApplicationChangeFactory extends AbstractUMLChangeFact
.getDifferences().iterator();
while (changes.hasNext()) {
final Diff diff = changes.next();
- if (diff instanceof AttributeChange || diff instanceof ReferenceChange
- || diff instanceof ResourceAttachmentChange) {
+ if ((diff instanceof AttributeChange || diff instanceof ReferenceChange || diff instanceof ResourceAttachmentChange)
+ && diff.getSource() == extension.getSource()) {
extension.getRefinedBy().add(diff);
}
}
@@ -239,7 +239,8 @@ public class UMLStereotypeApplicationChangeFactory extends AbstractUMLChangeFact
if (setting.getEStructuralFeature() == UMLPackage.Literals.PROFILE_APPLICATION__APPLIED_PROFILE) {
final ProfileApplication profileApplication = (ProfileApplication)setting.getEObject();
for (Diff diff : comparison.getDifferences(profileApplication)) {
- if (diff instanceof ProfileApplicationChange && diff.getKind() == DifferenceKind.ADD) {
+ if (diff instanceof ProfileApplicationChange && diff.getKind() == DifferenceKind.ADD
+ && diff.getSource() == stereotypeApplicationChange.getSource()) {
stereotypeApplicationChange.getRequires().add(diff);
}
}
diff --git a/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/stereotype/UMLStereotypeAttributeChangeFactory.java b/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/stereotype/UMLStereotypeAttributeChangeFactory.java
index f5f8d8eb4..5d6ac4019 100644
--- a/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/stereotype/UMLStereotypeAttributeChangeFactory.java
+++ b/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/stereotype/UMLStereotypeAttributeChangeFactory.java
@@ -128,7 +128,9 @@ public class UMLStereotypeAttributeChangeFactory extends AbstractUMLChangeFactor
*/
@Override
public void setRefiningChanges(Diff extension, DifferenceKind extensionKind, Diff refiningDiff) {
- extension.getRefinedBy().add(refiningDiff);
+ if (refiningDiff.getSource() == extension.getSource()) {
+ extension.getRefinedBy().add(refiningDiff);
+ }
}
/**
diff --git a/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/stereotype/UMLStereotypeReferenceChangeFactory.java b/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/stereotype/UMLStereotypeReferenceChangeFactory.java
index 6b1e3e7c5..79b6a5a25 100644
--- a/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/stereotype/UMLStereotypeReferenceChangeFactory.java
+++ b/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/stereotype/UMLStereotypeReferenceChangeFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013 Obeo.
+ * Copyright (c) 2013, 2015 Obeo.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -128,7 +128,9 @@ public class UMLStereotypeReferenceChangeFactory extends AbstractUMLChangeFactor
*/
@Override
public void setRefiningChanges(Diff extension, DifferenceKind extensionKind, Diff refiningDiff) {
- extension.getRefinedBy().add(refiningDiff);
+ if (refiningDiff.getSource() == extension.getSource()) {
+ extension.getRefinedBy().add(refiningDiff);
+ }
}
/**
diff --git a/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/stereotype/UMLStereotypedElementChangeFactory.java b/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/stereotype/UMLStereotypedElementChangeFactory.java
index d1b148208..48e5e4004 100644
--- a/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/stereotype/UMLStereotypedElementChangeFactory.java
+++ b/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/extension/stereotype/UMLStereotypedElementChangeFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2014 Obeo.
+ * Copyright (c) 2014, 2015 Obeo.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.emf.compare.uml2.internal.postprocessor.extension.stereotype;
+import com.google.common.collect.Collections2;
import com.google.common.collect.Lists;
import java.util.Collections;
@@ -24,6 +25,7 @@ import org.eclipse.emf.compare.uml2.internal.StereotypedElementChange;
import org.eclipse.emf.compare.uml2.internal.UMLCompareFactory;
import org.eclipse.emf.compare.uml2.internal.postprocessor.AbstractUMLChangeFactory;
import org.eclipse.emf.compare.uml2.internal.postprocessor.util.UMLCompareUtil;
+import org.eclipse.emf.compare.utils.EMFComparePredicates;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.Switch;
import org.eclipse.uml2.uml.Element;
@@ -95,8 +97,12 @@ public class UMLStereotypedElementChangeFactory extends AbstractUMLChangeFactory
public void setRefiningChanges(Diff extension, DifferenceKind extensionKind, Diff refiningDiff) {
// super.setRefiningChanges(extension, extensionKind, refiningDiff);
List<StereotypeApplicationChange> stereotypeApplicationChanges = getStereotypeApplicationChanges((ReferenceChange)refiningDiff);
- extension.getRefinedBy().addAll(stereotypeApplicationChanges);
- extension.getRefinedBy().add(refiningDiff);
+ if (refiningDiff.getSource() == extension.getSource()) {
+ extension.getRefinedBy().add(refiningDiff);
+ extension.getRefinedBy().addAll(
+ Collections2.filter(stereotypeApplicationChanges, EMFComparePredicates.fromSide(extension
+ .getSource())));
+ }
}
diff --git a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/postprocessor/factories/AbstractChangeFactory.java b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/postprocessor/factories/AbstractChangeFactory.java
index 061508d1a..86307cdcf 100644
--- a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/postprocessor/factories/AbstractChangeFactory.java
+++ b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/postprocessor/factories/AbstractChangeFactory.java
@@ -11,6 +11,7 @@
package org.eclipse.emf.compare.internal.postprocessor.factories;
import com.google.common.base.Predicate;
+import com.google.common.collect.Collections2;
import com.google.common.collect.Iterables;
import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;
@@ -31,6 +32,7 @@ import org.eclipse.emf.compare.ReferenceChange;
import org.eclipse.emf.compare.ResourceAttachmentChange;
import org.eclipse.emf.compare.internal.utils.ComparisonUtil;
import org.eclipse.emf.compare.util.CompareSwitch;
+import org.eclipse.emf.compare.utils.EMFComparePredicates;
import org.eclipse.emf.compare.utils.MatchUtil;
import org.eclipse.emf.ecore.EObject;
@@ -66,11 +68,12 @@ public abstract class AbstractChangeFactory implements IChangeFactory {
final DifferenceKind extensionKind = getRelatedExtensionKind(input);
ret.setKind(extensionKind);
+ // It's important to set the source before calling setRefiningChanges()
+ // because refines/refinedBy EReferences demand diffs on the same side
+ ret.setSource(input.getSource());
setRefiningChanges(ret, extensionKind, input);
- ret.setSource(input.getSource());
-
// FIXME: Maybe it would be better to get all conflict objects from all conflicting unit differences
// and
// create a new conflict object with these differences, to set on the macroscopic change (ret).
@@ -152,8 +155,10 @@ public abstract class AbstractChangeFactory implements IChangeFactory {
requiredExtensions.remove(macro);
requiringExtensions.remove(macro);
- macro.getRequires().addAll(requiredExtensions);
- macro.getRequiredBy().addAll(requiringExtensions);
+ macro.getRequires().addAll(
+ Collections2.filter(requiredExtensions, EMFComparePredicates.fromSide(macro.getSource())));
+ macro.getRequiredBy().addAll(
+ Collections2.filter(requiringExtensions, EMFComparePredicates.fromSide(macro.getSource())));
}
/**
@@ -178,8 +183,10 @@ public abstract class AbstractChangeFactory implements IChangeFactory {
}
}
}
- macro.getRequires().addAll(requiredExtensions);
- macro.getRequiredBy().addAll(requiringExtensions);
+ macro.getRequires().addAll(
+ Collections2.filter(requiredExtensions, EMFComparePredicates.fromSide(macro.getSource())));
+ macro.getRequiredBy().addAll(
+ Collections2.filter(requiringExtensions, EMFComparePredicates.fromSide(macro.getSource())));
}
/**
diff --git a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/req/DefaultReqEngine.java b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/req/DefaultReqEngine.java
index b645cc79f..6e7d595e1 100644
--- a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/req/DefaultReqEngine.java
+++ b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/req/DefaultReqEngine.java
@@ -39,6 +39,7 @@ import org.eclipse.emf.compare.FeatureMapChange;
import org.eclipse.emf.compare.Match;
import org.eclipse.emf.compare.ReferenceChange;
import org.eclipse.emf.compare.ResourceAttachmentChange;
+import org.eclipse.emf.compare.utils.EMFComparePredicates;
import org.eclipse.emf.compare.utils.MatchUtil;
import org.eclipse.emf.compare.utils.ReferenceUtil;
import org.eclipse.emf.ecore.EObject;
@@ -167,8 +168,12 @@ public class DefaultReqEngine implements IReqEngine {
.getSource(), DifferenceKind.ADD));
}
- difference.getRequires().addAll(requiredDifferences);
- difference.getRequiredBy().addAll(requiredByDifferences);
+ difference.getRequires().addAll(
+ Collections2.filter(requiredDifferences, EMFComparePredicates.fromSide(difference
+ .getSource())));
+ difference.getRequiredBy().addAll(
+ Collections2.filter(requiredByDifferences, EMFComparePredicates.fromSide(difference
+ .getSource())));
}
}
@@ -302,7 +307,8 @@ public class DefaultReqEngine implements IReqEngine {
if (valueMatch != null) {
for (Diff candidate : filter(valueMatch.getDifferences(), or(
instanceOf(ReferenceChange.class), instanceOf(FeatureMapChange.class)))) {
- if (candidate.getKind() == DifferenceKind.DELETE || isDeleteOrUnsetDiff(candidate)) {
+ if (candidate.getSource() == sourceDifference.getSource()
+ && (candidate.getKind() == DifferenceKind.DELETE || isDeleteOrUnsetDiff(candidate))) {
result.add(candidate);
}
}
diff --git a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/utils/EMFComparePredicates.java b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/utils/EMFComparePredicates.java
index 2cb60ad6d..91121c0e0 100644
--- a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/utils/EMFComparePredicates.java
+++ b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/utils/EMFComparePredicates.java
@@ -555,6 +555,24 @@ public final class EMFComparePredicates {
}
/**
+ * This can be used to check that a given Diff originates from the given {@code source} side.
+ *
+ * @param diff
+ * The diff the side of which will be used to filter.
+ * @return The created predicate.
+ */
+ public static Predicate<? super Diff> sameSideAs(final Diff diff) {
+ if (diff == null) {
+ throw new IllegalArgumentException();
+ }
+ return new Predicate<Diff>() {
+ public boolean apply(Diff input) {
+ return input != null && input.getSource() == diff.getSource();
+ }
+ };
+ }
+
+ /**
* This can be used in order to check that a Diff has been detected on the given EObject.
*
* @param eObject

Back to the top