diff options
Diffstat (limited to 'plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/conflict')
5 files changed, 4 insertions, 112 deletions
diff --git a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/conflict/AbstractConflictSearch.java b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/conflict/AbstractConflictSearch.java index 9eda013a4..4adecb1b2 100644 --- a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/conflict/AbstractConflictSearch.java +++ b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/conflict/AbstractConflictSearch.java @@ -13,16 +13,10 @@ package org.eclipse.emf.compare.internal.conflict; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; -import static com.google.common.base.Predicates.and; import static org.eclipse.emf.compare.ConflictKind.PSEUDO; import static org.eclipse.emf.compare.ConflictKind.REAL; -import static org.eclipse.emf.compare.DifferenceKind.DELETE; -import static org.eclipse.emf.compare.utils.EMFComparePredicates.ofKind; -import static org.eclipse.emf.compare.utils.EMFComparePredicates.onFeature; -import static org.eclipse.emf.compare.utils.EMFComparePredicates.valueIs; import com.google.common.base.Predicate; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import java.util.List; @@ -47,7 +41,6 @@ import org.eclipse.emf.compare.internal.ThreeWayTextDiff; import org.eclipse.emf.compare.utils.ReferenceUtil; import org.eclipse.emf.ecore.EAttribute; import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.util.EcoreUtil; @@ -233,111 +226,6 @@ public abstract class AbstractConflictSearch<T extends Diff> { } /** - * This will be used whenever we check for conflictual MOVEs in order to determine whether we have a - * pseudo conflict or a real conflict. - * <p> - * Namely, this will retrieve the value of the given {@code feature} on the right and left sides of the - * given {@code match}, then check whether the two given values are on the same index. - * </p> - * <p> - * Note that no sanity checks will be made on either the match's sides or the feature. - * </p> - * - * @param match - * Match for which we need to check a feature. - * @param feature - * The feature which values we need to check. - * @param value1 - * First of the two values which index we are to compare. - * @param value2 - * Second of the two values which index we are to compare. - * @return {@code true} if the two given values are located at the same index in the given feature's - * values list, {@code false} otherwise. - */ - protected boolean matchingIndices(Match match, EStructuralFeature feature, Object value1, Object value2) { - boolean matching = false; - if (feature.isMany()) { - @SuppressWarnings("unchecked") - final List<Object> leftValues = (List<Object>)ReferenceUtil.safeEGet(match.getLeft(), feature); - @SuppressWarnings("unchecked") - final List<Object> rightValues = (List<Object>)ReferenceUtil.safeEGet(match.getRight(), feature); - - // FIXME the detection _will_ fail for non-unique lists with multiple identical values... - int leftIndex = -1; - int rightIndex = -1; - for (int i = 0; i < leftValues.size(); i++) { - final Object left = leftValues.get(i); - if (comparison.getEqualityHelper().matchingValues(left, value1)) { - break; - } else if (hasDiff(match, feature, left) || hasDeleteDiff(match, feature, left)) { - // Do not increment. - } else { - leftIndex++; - } - } - for (int i = 0; i < rightValues.size(); i++) { - final Object right = rightValues.get(i); - if (comparison.getEqualityHelper().matchingValues(right, value2)) { - break; - } else if (hasDiff(match, feature, right) || hasDeleteDiff(match, feature, right)) { - // Do not increment. - } else { - rightIndex++; - } - } - matching = leftIndex == rightIndex; - } else { - matching = true; - } - return matching; - } - - /** - * Checks whether the given {@code match} presents a difference of any kind on the given {@code feature}'s - * {@code value}. - * - * @param match - * The match which differences we'll check. - * @param feature - * The feature on which we expect a difference. - * @param value - * The value we expect to have changed inside {@code feature}. - * @return <code>true</code> if there is such a Diff on {@code match}, <code>false</code> otherwise. - */ - protected boolean hasDiff(Match match, EStructuralFeature feature, Object value) { - return Iterables.any(match.getDifferences(), and(onFeature(feature.getName()), valueIs(value))); - } - - /** - * Checks whether the given {@code value} has been deleted from the given {@code feature} of {@code match} - * . - * - * @param match - * The match which differences we'll check. - * @param feature - * The feature on which we expect a difference. - * @param value - * The value we expect to have been removed from {@code feature}. - * @return <code>true</code> if there is such a Diff on {@code match}, <code>false</code> otherwise. - */ - protected boolean hasDeleteDiff(Match match, EStructuralFeature feature, Object value) { - checkArgument(match.getComparison() == comparison); - final Object expectedValue; - if (value instanceof EObject && comparison.isThreeWay()) { - final Match valueMatch = comparison.getMatch((EObject)value); - if (valueMatch != null) { - expectedValue = valueMatch.getOrigin(); - } else { - expectedValue = value; - } - } else { - expectedValue = value; - } - return Iterables.any(match.getDifferences(), - and(onFeature(feature.getName()), valueIs(expectedValue), ofKind(DELETE))); - } - - /** * This will be called whenever we detect a new conflict in order to create (or update) the actual * association. * diff --git a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/conflict/AttributeChangeConflictSearch.java b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/conflict/AttributeChangeConflictSearch.java index 30270e033..ba39f3142 100644 --- a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/conflict/AttributeChangeConflictSearch.java +++ b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/conflict/AttributeChangeConflictSearch.java @@ -21,6 +21,7 @@ import static org.eclipse.emf.compare.DifferenceKind.MOVE; import static org.eclipse.emf.compare.utils.EMFComparePredicates.ofKind; import static org.eclipse.emf.compare.utils.EMFComparePredicates.onFeature; import static org.eclipse.emf.compare.utils.EMFComparePredicates.possiblyConflictingWith; +import static org.eclipse.emf.compare.utils.MatchUtil.matchingIndices; import com.google.common.collect.Iterables; diff --git a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/conflict/ContainmentRefChangeConflictSearch.java b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/conflict/ContainmentRefChangeConflictSearch.java index ddaa96e2b..30d8c7523 100644 --- a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/conflict/ContainmentRefChangeConflictSearch.java +++ b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/conflict/ContainmentRefChangeConflictSearch.java @@ -23,6 +23,7 @@ import static org.eclipse.emf.compare.utils.EMFComparePredicates.ofKind; import static org.eclipse.emf.compare.utils.EMFComparePredicates.onFeature; import static org.eclipse.emf.compare.utils.EMFComparePredicates.possiblyConflictingWith; import static org.eclipse.emf.compare.utils.EMFComparePredicates.valueMatches; +import static org.eclipse.emf.compare.utils.MatchUtil.matchingIndices; import com.google.common.collect.Iterables; diff --git a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/conflict/FeatureMapChangeConflictSearch.java b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/conflict/FeatureMapChangeConflictSearch.java index c3bb489f9..b42c2e5b0 100644 --- a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/conflict/FeatureMapChangeConflictSearch.java +++ b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/conflict/FeatureMapChangeConflictSearch.java @@ -22,6 +22,7 @@ import static org.eclipse.emf.compare.utils.EMFComparePredicates.ofKind; import static org.eclipse.emf.compare.utils.EMFComparePredicates.onFeature; import static org.eclipse.emf.compare.utils.EMFComparePredicates.possiblyConflictingWith; import static org.eclipse.emf.compare.utils.EMFComparePredicates.valueMatches; +import static org.eclipse.emf.compare.utils.MatchUtil.matchingIndices; import com.google.common.collect.Iterables; diff --git a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/conflict/NonContainmentRefChangeConflictSearch.java b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/conflict/NonContainmentRefChangeConflictSearch.java index 185b618ac..0a220f043 100644 --- a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/conflict/NonContainmentRefChangeConflictSearch.java +++ b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/conflict/NonContainmentRefChangeConflictSearch.java @@ -21,6 +21,7 @@ import static org.eclipse.emf.compare.DifferenceKind.MOVE; import static org.eclipse.emf.compare.utils.EMFComparePredicates.ofKind; import static org.eclipse.emf.compare.utils.EMFComparePredicates.onFeature; import static org.eclipse.emf.compare.utils.EMFComparePredicates.possiblyConflictingWith; +import static org.eclipse.emf.compare.utils.MatchUtil.matchingIndices; import com.google.common.collect.Iterables; |