use of org.osate.xtext.aadl2.errormodel.errorModel.ConditionElement in project osate2 by osate.
the class ErrorModelValidator method checkSConditionElementType.
private void checkSConditionElementType(SConditionElement conditionElement) {
// this method handles state part of composite. The incoming propagation is handled by the ConditionElement method.
ErrorBehaviorState es = EMV2Util.getState(conditionElement);
if (es == null) {
return;
}
CompositeState compState;
EObject eo = conditionElement;
while (eo.eContainer() != null) {
eo = eo.eContainer();
if (eo instanceof CompositeState) {
break;
}
}
if (eo instanceof CompositeState) {
compState = (CompositeState) eo;
EList<TypeToken> targetTKs = compState.getTypedToken().getTypeTokens();
// marks error if target state has a typeset or multiple errors associated with it
if ((targetTKs != null && targetTKs.size() > 1) || (targetTKs.get(0).getType() != null && !(targetTKs.get(0).getType().get(0) instanceof ErrorType))) {
error(compState, "Target error type may only have a single error type");
}
}
TypeSet triggerTS = null;
String triggerName = "";
triggerTS = es.getTypeSet();
triggerName = "state " + es.getName();
TypeSet condTS = conditionElement.getConstraint();
if (condTS == null) {
return;
}
if (triggerTS == null && condTS != null) {
// it is ok for a state not to have a type set.
error(conditionElement, "Condition has type constraint but referenced " + triggerName + " does not.");
} else if (!EMV2TypeSetUtil.isNoError(condTS) && !EMV2TypeSetUtil.contains(triggerTS, condTS)) {
error(conditionElement, "Condition type constraint " + EMV2Util.getPrintName(condTS) + "is not contained in type set " + EMV2Util.getPrintName(triggerTS) + "of referenced " + triggerName);
}
}
Aggregations