use of org.abs_models.frontend.ast.DeltaID in project abstools by abstools.
the class TopologicalSortingTest method init0_1.
/**
***********************************************************************
*/
private TopologicalSorting<DeltaID> init0_1() {
numNodes = 0;
deltas = new DeltaID[numNodes];
TopologicalSorting<DeltaID> sorter = new TopologicalSorting<>(new HashSet<>(Arrays.asList(deltas)));
sorter.addEdge(new DeltaID("D0"), new DeltaID("D1"));
return sorter;
}
use of org.abs_models.frontend.ast.DeltaID 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;
}
use of org.abs_models.frontend.ast.DeltaID in project abstools by abstools.
the class TopologicalSortingTest method testCycle2.
@Test(expected = DeltaModellingException.class)
public void testCycle2() {
numNodes = 1;
deltas = new DeltaID[numNodes];
deltas[0] = new DeltaID("D0");
TopologicalSorting<DeltaID> sorter = new TopologicalSorting<>(new HashSet<>(Arrays.asList(deltas)));
// cycle
sorter.addEdge(deltas[0], deltas[0]);
sorter.sort();
}
Aggregations