Search in sources :

Example 1 with DeltaClause

use of org.abs_models.frontend.ast.DeltaClause in project abstools by abstools.

the class ProductLineAnalysisHelper method wellFormedProductLine.

/*
     * Check that the 'productline' declaration is well formed. This means...
     * - after clauses do not reference any deltaIDs that do not have their own delta clause
     * - deltas named in the productline correspond to actual DeltaDecls
     */
protected static boolean wellFormedProductLine(ProductLine pl, SemanticConditionList e) {
    boolean wellformed = true;
    // preliminaries
    final Set<String> declaredDeltas = pl.getModel().getDeltaDeclsMap().keySet();
    final Set<String> referencedDeltas = new HashSet<>(pl.getDeltaClauses().getNumChild());
    for (DeltaClause clause : pl.getDeltaClauses()) referencedDeltas.add(clause.getDeltaspec().getDeltaID());
    // check
    for (DeltaClause clause : pl.getDeltaClauses()) {
        // ensure deltas in the productline correspond to actual DeltaDecls
        if (!declaredDeltas.contains(clause.getDeltaspec().getDeltaID())) {
            e.add(new SemanticError(clause, ErrorMessage.NO_DELTA_DECL, clause.getDeltaspec().getDeltaID()));
            wellformed = false;
        }
        // ensure 'after' clauses do not reference any deltaIDs that do not have their own delta clause
        for (DeltaID id : clause.getAfterDeltaIDs()) {
            String afterID = id.getName();
            if (!referencedDeltas.contains(afterID)) {
                e.add(new SemanticError(clause, ErrorMessage.MISSING_DELTA_CLAUSE_ERROR, afterID, pl.getName()));
                wellformed = false;
            }
        }
    }
    return wellformed;
}
Also used : DeltaClause(org.abs_models.frontend.ast.DeltaClause) SemanticError(org.abs_models.frontend.analyser.SemanticError) DeltaID(org.abs_models.frontend.ast.DeltaID) HashSet(java.util.HashSet)

Aggregations

HashSet (java.util.HashSet)1 SemanticError (org.abs_models.frontend.analyser.SemanticError)1 DeltaClause (org.abs_models.frontend.ast.DeltaClause)1 DeltaID (org.abs_models.frontend.ast.DeltaID)1