Skip to content
Snippets Groups Projects
Commit 8e1a8755 authored by Andreas Bayha's avatar Andreas Bayha
Browse files

YELLOW

Issue-ref: 4346
Issue-URL: af3#4346



Signed-off-by: default avatarAndreas Bayha <bayha@fortiss.org>
parent 9d8ff4de
No related branches found
No related tags found
1 merge request!2194346
Pipeline #39660 passed
Pipeline: maven-releng

#39661

    IReuseProvider.java 18d293f7f1f072883188f16fb6eeb52c8d6042cf GREEN
    IReuseProviderService.java bcc70de0bb8d39c330e3a25d884abc7092dc1b7e GREEN
    LayoutedReuseProviderBase.java b0e4ce3cda818b0723ec37b925a4c4c3d0c41909 GREEN
    ReuseProviderBase.java 51be8cde5d4aa3ec79433a5d728a6342f18d29ba YELLOW
    ReuseProviderBase.java b324d23be4deffbc97e587a76b527be2573942d1 YELLOW
    ReuseProviderService.java c4ef33283002d6dac6167f9c6c8f71d2c2ce39d1 GREEN
    ......@@ -21,7 +21,6 @@ import static org.fortiss.tooling.kernel.utils.EcoreUtils.getChildrenWithType;
    import static org.fortiss.tooling.kernel.utils.EcoreUtils.replaceEObjectReferences;
    import java.util.ArrayList;
    import java.util.Collection;
    import java.util.HashSet;
    import java.util.List;
    import java.util.Set;
    ......@@ -144,8 +143,9 @@ public class ReuseProviderBase<T extends EObject> implements IReuseProvider<T> {
    * The {@link EObject} for which all reference targets shall be removed.
    */
    private void removeExternalReferences(EObject element) {
    // Whitelist all contained elements as reference targets.
    // Whitelist all contained elements as legal references (since they will also be copied).
    Set<EObject> whitelist = new HashSet<EObject>(getChildrenWithType(element, EObject.class));
    whitelist.add(element);
    removeReferences(element, whitelist);
    }
    ......@@ -159,27 +159,25 @@ public class ReuseProviderBase<T extends EObject> implements IReuseProvider<T> {
    */
    @SuppressWarnings("unchecked")
    private void removeReferences(EObject element, Set<EObject> whitelist) {
    // FIXME (SeB): the loop below does not get all internal/nested references, which is why it
    // will skip the removals of internal references due to no direct references in the given
    // element.
    for(EReference ref : element.eClass().getEReferences()) {
    for(EReference ref : element.eClass().getEAllReferences()) {
    Object refTarget = element.eGet(ref);
    if(refTarget == null) {
    continue;
    }
    if(refTarget instanceof Collection<?>) {
    Collection<EObject> refTargetCollection = (Collection<EObject>)refTarget;
    if(refTarget instanceof List<?>) {
    List<EObject> refTargetList = (List<EObject>)refTarget;
    if(ref.isContainment()) {
    // Containment relations must not be removed. Yet, references of children need
    // to be removed recursively.
    refTargetCollection.stream()
    .forEach(target -> removeReferences(target, whitelist));
    refTargetList.stream().forEach(target -> removeReferences(target, whitelist));
    } else {
    refTargetCollection.removeIf(target -> !whitelist.contains(target));
    refTargetList.removeIf(t -> !whitelist.contains(t));
    }
    } else {
    if(ref.isContainment()) {
    // Keep reference target and make recursive call.
    ......
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment