Change the ProxyingResourceList#contains method to take into account the
fact that we break
the EMF rule for bidirectionnal reference between a Resource and its
ResourceSet

Change-Id: I888a207b6edf6a2594d0f6557a7301ace4a56a23
Signed-off-by: Camille Letavernier <cletavernier@eclipsesource.com>
diff --git a/plugins/compare/bundles/org.eclipse.papyrus.compare.uml2/src/org/eclipse/papyrus/compare/uml2/internal/hook/migration/ModelSetWrapper.java b/plugins/compare/bundles/org.eclipse.papyrus.compare.uml2/src/org/eclipse/papyrus/compare/uml2/internal/hook/migration/ModelSetWrapper.java
index 6b521ee..792683a 100644
--- a/plugins/compare/bundles/org.eclipse.papyrus.compare.uml2/src/org/eclipse/papyrus/compare/uml2/internal/hook/migration/ModelSetWrapper.java
+++ b/plugins/compare/bundles/org.eclipse.papyrus.compare.uml2/src/org/eclipse/papyrus/compare/uml2/internal/hook/migration/ModelSetWrapper.java
@@ -335,6 +335,37 @@
 			}
 		}
 
+		@Override
+		public boolean contains(Object object) {
+			// XXX The super implementation only works up to the 5th element.
+			// Because we're cheating with proxies, the super impl will consider
+			// that we already contain this resource.
+			// Basically, we can't trust the bidirectionnal reference between Resource
+			// and ResourceSet because of the proxy; but EMF does trust it.
+			boolean result = super.contains(object);
+
+			if (result && object instanceof Resource && isProxy((Resource)object)) {
+				// Let's double-check... Copy the super-super implementation
+				if (useEquals()) {
+					for (int i = 0; i < size; ++i) {
+						if (object.equals(data[i])) {
+							return true;
+						}
+					}
+				} else {
+					for (int i = 0; i < size; ++i) {
+						if (data[i] == object) {
+							return true;
+						}
+					}
+				}
+
+				return false;
+			}
+
+			return result;
+		}
+
 		/**
 		 * Removes my proxy for the given {@code resource} if I have one
 		 *