use of com.rockwellcollins.atc.agree.agree.CalenStatement in project AGREE by loonwerks.
the class AgreeValidator method checkNameOverlap.
@Check(CheckType.FAST)
public void checkNameOverlap(AgreeContract contract) {
Set<SynchStatement> syncs = new HashSet<>();
Set<InitialStatement> inits = new HashSet<>();
List<ConnectionStatement> conns = new ArrayList<>();
// check that there are zero or more synchrony statements
for (SpecStatement spec : contract.getSpecs()) {
if (spec instanceof SynchStatement) {
syncs.add((SynchStatement) spec);
} else if (spec instanceof CalenStatement) {
syncs.add((CalenStatement) spec);
} else if (spec instanceof InitialStatement) {
inits.add((InitialStatement) spec);
} else if (spec instanceof ConnectionStatement) {
conns.add((ConnectionStatement) spec);
}
}
if (syncs.size() > 1) {
for (SynchStatement sync : syncs) {
error(sync, "Multiple synchrony or calender statements in a single contract");
}
}
if (inits.size() > 1) {
for (InitialStatement init : inits) {
error(init, "Multiple initially statements in a single contract");
}
}
for (int i = 0; i < conns.size(); i++) {
ConnectionStatement connStat0 = conns.get(i);
NamedElement conn0 = connStat0.getConn();
for (int j = i + 1; j < conns.size(); j++) {
ConnectionStatement connStat1 = conns.get(j);
NamedElement conn1 = connStat1.getConn();
if (conn0 == null || conn1 == null) {
break;
}
if (conn0.equals(conn1)) {
error(connStat0, "Multiple connection overrides for connection: '" + conn0.getName() + "'");
error(connStat1, "Multiple connection overrides for connection: '" + conn1.getName() + "'");
}
}
}
ComponentImplementation ci = EcoreUtil2.getContainerOfType(contract, ComponentImplementation.class);
if (ci == null) {
return;
}
Set<String> parentNames = getParentNames(ci);
for (AgreeSubclause subclause : EcoreUtil2.getAllContentsOfType(ci, AgreeSubclause.class)) {
List<NamedElement> es = EcoreUtil2.getAllContentsOfType(subclause, NamedElement.class);
for (NamedElement e : es) {
if (!(e.eContainer() instanceof NodeDef || e instanceof NamedSpecStatement)) {
// ignore elements in node defs
if (parentNames.contains(e.getName())) {
// =======
// if (!(e.eContainer() instanceof NodeDefExpr)) { // ignore elements in node defs
// if (e.getName() != null && parentNames.contains(e.getName())) {
// >>>>>>> origin/develop
error(e, e.getName() + " already defined in component type contract");
}
}
}
}
}
use of com.rockwellcollins.atc.agree.agree.CalenStatement in project AGREE by loonwerks.
the class AgreeValidator method checkSynchStatement.
@Check(CheckType.FAST)
public void checkSynchStatement(SynchStatement sync) {
Classifier container = sync.getContainingClassifier();
if (!(container instanceof ComponentImplementation)) {
error(sync, "Synchrony statements can appear only in component implementations");
}
if (sync instanceof CalenStatement || sync instanceof MNSynchStatement || sync instanceof AsynchStatement || sync instanceof LatchedStatement) {
return;
}
// So this may be redundant
if (Integer.valueOf(sync.getVal()) < 0) {
error(sync, "The value of synchrony statments must be positive");
}
String val2 = sync.getVal2();
if (val2 != null) {
if (Integer.valueOf(val2) <= 0) {
error(sync, "The second value of a synchrony statment must be greater than zero");
}
if (Integer.valueOf(sync.getVal()) <= Integer.valueOf(val2)) {
error(sync, "The second value of a synchrony argument must be less than the first");
}
}
}
Aggregations