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

Variability: Added possibility to limit scope to product-line analysis


The product-line analysis can now define a scope that limits the
translated model elements.

Issue-ref: 4240
Issue-URL: af3#4240

Signed-off-by: default avatarAndreas Bayha <bayha@fortiss.org>
parent 62bece81
No related branches found
No related tags found
1 merge request!1784240
Pipeline #37812 passed
Pipeline: maven-releng

#37813

    ......@@ -16,20 +16,29 @@
    package org.fortiss.tooling.ext.variability.analysis;
    import static java.util.Arrays.asList;
    import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickInstanceOf;
    import java.util.ArrayList;
    import java.util.Collection;
    import java.util.List;
    import org.eclipse.emf.ecore.EClass;
    import org.eclipse.emf.ecore.EObject;
    import org.fortiss.tooling.base.model.layout.LayoutPackage;
    import org.fortiss.tooling.kernel.model.IProjectRootElement;
    import org.fortiss.variability.analysis.ProductLineBaseAnalysis;
    import org.fortiss.variability.analysis.ProductLineBaseTranslation;
    import org.fortiss.variability.analysis.ProductLineConstraintViolation;
    /**
    * Base class for all tooling kernel based product-line analyses.
    *
    * @author bayha
    */
    public class ProductLineAnalysis extends ProductLineBaseAnalysis {
    /**
    * @param model
    * Constructor.
    */
    public ProductLineAnalysis(EObject model) {
    this(model, new ProductLineTranslation());
    ......@@ -38,10 +47,45 @@ public class ProductLineAnalysis extends ProductLineBaseAnalysis {
    }
    /**
    * @param model
    * @param translation
    * Constructor.
    */
    protected ProductLineAnalysis(EObject model, ProductLineBaseTranslation translation) {
    super(model, translation);
    }
    /** {@inheritDoc} */
    @Override
    public List<ProductLineConstraintViolation> doCheck() {
    List<Class<? extends IProjectRootElement>> scope = getScope();
    Collection<EClass> excludedClasses = new ArrayList<EClass>();
    for(IProjectRootElement rootElement : pickInstanceOf(IProjectRootElement.class,
    model.eContents())) {
    for(Class<?> c : scope) {
    if(!c.isAssignableFrom(rootElement.getClass())) {
    excludedClasses.add(rootElement.eClass());
    }
    }
    }
    translation.addExcludedClasses(excludedClasses);
    return super.doCheck();
    }
    /**
    * Determines the scope of this analysis. I.e. which subclasses of {@link IProjectRootElement}
    * are translated and included to the check.
    *
    * The default implementation will translate all {@link IProjectRootElement}.
    * This method might be overwritten in order to optimize the analysis and runtime.
    *
    * @return A {@link List} of {@link Class} elements for subclasses of
    * {@link IProjectRootElement}.
    */
    protected List<Class<? extends IProjectRootElement>> getScope() {
    return asList(IProjectRootElement.class);
    }
    }
    ......@@ -63,7 +63,7 @@ public class ProductLineBaseAnalysis {
    * @return 'true' if all constraints are fulfilled for all variants of the product-line
    * analysis. 'false' otherwise.
    */
    public final List<ProductLineConstraintViolation> doCheck() {
    public List<ProductLineConstraintViolation> doCheck() {
    final long start = System.currentTimeMillis();
    translation.doTranslate(model);
    ......
    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