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

Feature Model: Added check for uniqueness of feature names


Feature names are now checked to be unique among all literals.

Issue-ref: 4278
Issue-URL: af3#4278

Signed-off-by: default avatarAndreas Bayha <bayha@fortiss.org>
parent 0083d70b
No related branches found
No related tags found
1 merge request!1884278
Pipeline #37102 passed
Pipeline: maven-releng

#37103

    FeatureModelTransformationUtils.java b38702296dcb48ff311b382bb9c05d2590e2dfac GREEN
    Pair.java 2dfd7dc65f7b9ba09a120f1a6058d1e8e9556a37 GREEN
    VariabilityUtils.java 66a727bdb58715dc7b1bd0ce320bd647f374f7d6 GREEN
    VariabilityUtils.java 281b8512cdcbdf0494a752562460c9894cbe24e5 YELLOW
    VariabilityUtilsInternal.java 9c781a47513bb0c4ddcd13be1c27d62b70f25998 GREEN
    ......@@ -17,6 +17,7 @@ package org.fortiss.variability.util;
    import static java.util.stream.Collectors.toList;
    import static org.fortiss.variability.model.VariabilityModelElementFactory.createFeatureConfigurationForFeature;
    import static org.fortiss.variability.util.VariabilityUtilsInternal.getAllElementsFromSameContainmentTree;
    import static org.fortiss.variability.util.VariabilityUtilsInternal.getAllReferences;
    import static org.fortiss.variability.util.VariabilityUtilsInternal.getParentsWithType;
    ......@@ -27,6 +28,7 @@ import java.util.regex.Pattern;
    import java.util.stream.Collectors;
    import org.eclipse.emf.common.util.EList;
    import org.eclipse.emf.ecore.EObject;
    import org.fortiss.variability.model.features.AbstractCompositionalFeature;
    import org.fortiss.variability.model.features.AbstractCrossFeatureConstraint;
    import org.fortiss.variability.model.features.AbstractFeature;
    ......@@ -192,4 +194,22 @@ public class VariabilityUtils {
    features.removeAll(getParentsWithType(constraint, AbstractFeature.class));
    return features;
    }
    /**
    * Retrieves all literals with the given name from the whole containment tree in which 'context'
    * is contained in.
    *
    * Note, that the resulting {@link List} should usually contain at most one literal, as literal
    * names should be unique.
    *
    * @param context
    * Any {@link EObject} in the containment tree to search in.
    * @param name
    * The name of the literal which is searched.
    * @return A {@link List} of all literals with the given name.
    */
    public static List<ILiteralReferencable> getLiteralsWithName(EObject context, String name) {
    return getAllElementsFromSameContainmentTree(context, ILiteralReferencable.class).stream()
    .filter(l -> l.getName().equals(name)).collect(toList());
    }
    }
    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