From 7c8ace018f7e954bf9d17c743ad74210c6b3b6a1 Mon Sep 17 00:00:00 2001 From: Stefan Dirix Date: Fri, 27 Feb 2015 14:45:57 +0100 Subject: [PATCH] [461011] Allow customization of parent determination while matching Extracts the determination of parent objects in the IdentifierEObjectMatcher into a protected method. This method can be overwritten by clients who use a more complex architecture. Bug: 461011 Change-Id: Ic6645cdda971f6b75577eee4e092eebea4ef05fe Signed-off-by: Stefan Dirix --- .../match/eobject/IdentifierEObjectMatcher.java | 23 ++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/match/eobject/IdentifierEObjectMatcher.java b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/match/eobject/IdentifierEObjectMatcher.java index c30a6a11c..aec5d4502 100644 --- a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/match/eobject/IdentifierEObjectMatcher.java +++ b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/match/eobject/IdentifierEObjectMatcher.java @@ -9,6 +9,7 @@ * Obeo - initial API and implementation * Alexandra Buzila - Bug 450360 * Philip Langer - Bug 460778 + * Stefan Dirix - Bug 461011 *******************************************************************************/ package org.eclipse.emf.compare.match.eobject; @@ -228,7 +229,7 @@ public class IdentifierEObjectMatcher implements IEObjectMatcher { match.setLeft(left); // Can we find a parent? Assume we're iterating in containment order - final EObject parentEObject = left.eContainer(); + final EObject parentEObject = getParentEObject(left); final Match parent = leftEObjectsToMatch.get(parentEObject); if (parent != null) { ((InternalEList)parent.getSubmatches()).addUnique(match); @@ -265,7 +266,7 @@ public class IdentifierEObjectMatcher implements IEObjectMatcher { match.setRight(right); // Can we find a parent? - final EObject parentEObject = right.eContainer(); + final EObject parentEObject = getParentEObject(right); final Match parent = rightEObjectsToMatch.get(parentEObject); if (parent != null) { ((InternalEList)parent.getSubmatches()).addUnique(match); @@ -301,7 +302,7 @@ public class IdentifierEObjectMatcher implements IEObjectMatcher { match.setOrigin(origin); // Can we find a parent? - final EObject parentEObject = origin.eContainer(); + final EObject parentEObject = getParentEObject(origin); final Match parent = originEObjectsToMatch.get(parentEObject); if (parent != null) { ((InternalEList)parent.getSubmatches()).addUnique(match); @@ -320,7 +321,21 @@ public class IdentifierEObjectMatcher implements IEObjectMatcher { } /** - * Adds a warning diagnostic to the comparison for an object that has a duplicate ID. + * This method is used to determine the parent objects during matching. The default implementation of this + * method returns the eContainer of the given {@code eObject}. Can be overwritten by clients to still + * allow proper matching when using a more complex architecture. + * + * @param eObject + * The {@link EObject} for which the parent object is to determine. + * @return The parent of the given {@code eObject}. + * @since 3.2 + */ + protected EObject getParentEObject(EObject eObject) { + return eObject.eContainer(); + } + + /** + * Adds a warning diagnostic to the comparison for the duplicate ID. * * @param side * the side where the duplicate ID was found -- 2.11.4.GIT