diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/utils/.ratings b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/utils/.ratings index 66e2d2e17c8d530624cd5196002c40c0544e576e..d9c687d0875872c8d8e82c22641cc1121bb2278d 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/utils/.ratings +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/utils/.ratings @@ -2,7 +2,7 @@ CompositionUtils.java a2b1c7f4b1ae4d0783b4e170e432a9e02fc451fd GREEN ConstraintsUtils.java 93ae55d9c4a2645a97bb4162f43eb00acbc94633 GREEN EMFResourceUtils.java 01cddc68d7dd199191792d87f8256d6c52540856 GREEN EcoreSerializerBase.java 63b879cb32a0981dc1fefaf33db098abe81fe520 GREEN -EcoreUtils.java 008f4743d5092afb13c7f4cbbfcb83f1dc6b7721 GREEN +EcoreUtils.java c191385af86ff630d1ad9daacb42751527db8744 YELLOW ExtensionPointUtils.java e3ec0d396b0a88c040fd0117d4a369340d6099f4 GREEN IdentifierUtils.java d074a0f40d0ace7c2dd4ec145f0c2d783fbe115d GREEN JavaUtils.java 88bebee35226100989e118b272c766fa63f3c87c GREEN diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/utils/EcoreUtils.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/utils/EcoreUtils.java index 94c90d21a646af4812d87d41043e5b44329f68af..304f2d58208cd7c917f54479f4fb9668014f51d9 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/utils/EcoreUtils.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/utils/EcoreUtils.java @@ -18,6 +18,7 @@ package org.fortiss.tooling.kernel.utils; import static org.eclipse.emf.common.notify.Notification.EVENT_TYPE_COUNT; import static org.eclipse.emf.ecore.util.EcoreUtil.getAllContents; import static org.eclipse.emf.ecore.util.EcoreUtil.getRootContainer; +import static org.eclipse.emf.ecore.util.EcoreUtil.replace; import static org.eclipse.emf.ecore.util.EcoreUtil.UsageCrossReferencer.find; import java.util.Collection; @@ -43,6 +44,7 @@ import org.eclipse.emf.ecore.EPackage; import org.eclipse.emf.ecore.EPackage.Registry; import org.eclipse.emf.ecore.EReference; import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.EStructuralFeature.Setting; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.ResourceSet; import org.eclipse.emf.ecore.util.EcoreUtil; @@ -495,6 +497,22 @@ public class EcoreUtils { return usages; } + /** + * Replaces all references to the {@link EObject}s contained in the key set of the given + * {@code objectMap} with the corresponding elements they are mapped to. + * + * @param eObjectMap + * Maps each old {@link EObject} to the corresponding new {@link EObject} + */ + public static void + replaceEObjectReferences(Map<? extends EObject, ? extends EObject> eObjectMap) { + for(EObject eObject : eObjectMap.keySet()) { + for(Setting setting : getAllReferences(eObject)) { + replace(setting, eObject, eObjectMap.get(eObject)); + } + } + } + /** * <p> * Disables the notifications emitted by the given {@link EObject} and its children.