use of org.osate.xtext.aadl2.errormodel.errorModel.TypeMappingSet in project osate2 by osate.
the class ErrorModelValidator method checkConnectionErrorTypes.
private void checkConnectionErrorTypes(Connection conn) {
ComponentImplementation cimpl = conn.getContainingComponentImpl();
ConnectionEnd src = conn.getAllSource();
Context srcCxt = conn.getAllSourceContext();
ErrorPropagation srcprop = null;
ErrorPropagation srccontain = null;
Classifier srccl = null;
String srcname = (src instanceof Subcomponent) ? "access" : src.getName();
if (srcCxt instanceof Subcomponent) {
srccl = ((Subcomponent) srcCxt).getClassifier();
} else if (src instanceof Subcomponent) {
srccl = ((Subcomponent) src).getClassifier();
} else {
srccl = cimpl;
}
if (srccl != null) {
if (AadlUtil.isIncomingConnection(conn)) {
srcprop = EMV2Util.findIncomingErrorPropagation(srccl, srcname);
srccontain = EMV2Util.findIncomingErrorContainment(srccl, srcname);
} else {
srcprop = EMV2Util.findOutgoingErrorPropagation(srccl, srcname);
srccontain = EMV2Util.findOutgoingErrorContainment(srccl, srcname);
}
}
ConnectionEnd dst = conn.getAllDestination();
Context dstCxt = conn.getAllDestinationContext();
Classifier dstcl = null;
ErrorPropagation dstprop = null;
ErrorPropagation dstcontain = null;
String dstname = (dst instanceof Subcomponent) ? "access" : dst.getName();
if (dstCxt instanceof Subcomponent) {
dstcl = ((Subcomponent) dstCxt).getClassifier();
} else if (dst instanceof Subcomponent) {
dstcl = ((Subcomponent) dst).getClassifier();
} else {
dstcl = cimpl;
}
if (dstcl != null) {
if (AadlUtil.isOutgoingConnection(conn)) {
dstprop = EMV2Util.findOutgoingErrorPropagation(dstcl, dstname);
dstcontain = EMV2Util.findOutgoingErrorContainment(dstcl, dstname);
} else {
dstprop = EMV2Util.findIncomingErrorPropagation(dstcl, dstname);
dstcontain = EMV2Util.findIncomingErrorContainment(dstcl, dstname);
}
}
if (srcprop != null && dstprop != null) {
if (!EMV2TypeSetUtil.contains(dstprop.getTypeSet(), srcprop.getTypeSet())) {
TypeMappingSet typeEquivalence = EMV2Util.getAllTypeEquivalenceMapping(cimpl);
if (typeEquivalence != null) {
TypeToken mappedtt = EMV2TypeSetUtil.mapTypeToken(srcprop.getTypeSet(), typeEquivalence);
if (mappedtt != null) {
if (!EMV2TypeSetUtil.contains(dstprop.getTypeSet(), mappedtt)) {
error(conn, "Source propagation " + EMV2Util.getPrintName(srcprop) + EMV2Util.getPrintName(srcprop.getTypeSet()) + " has error types not handled by destination propagation " + EMV2Util.getPrintName(dstprop) + EMV2Util.getPrintName(dstprop.getTypeSet()));
}
}
} else {
error(conn, "Source propagation " + EMV2Util.getPrintName(srcprop) + EMV2Util.getPrintName(srcprop.getTypeSet()) + " has error types not handled by destination propagation " + EMV2Util.getPrintName(dstprop) + EMV2Util.getPrintName(dstprop.getTypeSet()));
}
}
}
if (srccontain != null && dstcontain != null) {
if (!EMV2TypeSetUtil.contains(srcprop.getTypeSet(), dstprop.getTypeSet())) {
error(conn, "Source containment " + EMV2Util.getPrintName(srcprop) + EMV2Util.getPrintName(srcprop.getTypeSet()) + " does not contain error types listed by Source containment " + EMV2Util.getPrintName(dstprop) + EMV2Util.getPrintName(dstprop.getTypeSet()));
}
}
// instance level
if (srcCxt instanceof Subcomponent && dstCxt instanceof Subcomponent) {
// only when going across
if (srccontain == null && dstcontain != null) {
EList<ErrorModelSubclause> srcsubclauses = EMV2Util.getAllContainingClassifierEMV2Subclauses(srccl);
if (!srcsubclauses.isEmpty()) {
warning(conn, "No outgoing containment from " + srcCxt.getName() + " for incoming containment " + EMV2Util.getPrintName(dstcontain) + EMV2Util.getPrintName(dstcontain.getTypeSet()) + ". Check for Unhandled Faults.");
}
}
if (srcprop != null && dstprop == null) {
EList<ErrorModelSubclause> dstsubclauses = EMV2Util.getAllContainingClassifierEMV2Subclauses(dstcl);
if (!dstsubclauses.isEmpty()) {
warning(conn, "No incoming error propagation from " + dstCxt.getName() + " for outgoing propagation " + EMV2Util.getPrintName(srcprop) + EMV2Util.getPrintName(srcprop.getTypeSet()) + ". Check for Unhandled Faults.");
}
}
}
if (conn.isAllBidirectional()) {
// check for error flow in the opposite direction
if (srccl != null) {
if (AadlUtil.isIncomingConnection(conn)) {
dstprop = EMV2Util.findOutgoingErrorPropagation(srccl, srcname);
dstcontain = EMV2Util.findOutgoingErrorContainment(srccl, srcname);
} else {
dstprop = EMV2Util.findIncomingErrorPropagation(srccl, srcname);
dstcontain = EMV2Util.findIncomingErrorContainment(srccl, srcname);
}
} else {
dstprop = null;
dstcontain = null;
}
if (dstcl != null) {
if (AadlUtil.isOutgoingConnection(conn)) {
srcprop = EMV2Util.findIncomingErrorPropagation(dstcl, dstname);
srccontain = EMV2Util.findIncomingErrorContainment(dstcl, dstname);
} else {
srcprop = EMV2Util.findOutgoingErrorPropagation(dstcl, dstname);
srccontain = EMV2Util.findOutgoingErrorContainment(dstcl, dstname);
}
} else {
srcprop = null;
srccontain = null;
}
if (srcprop != null && dstprop != null) {
if (!EMV2TypeSetUtil.contains(dstprop.getTypeSet(), srcprop.getTypeSet())) {
error(conn, "Reverse direction: Destination propagation " + EMV2Util.getPrintName(srcprop) + EMV2Util.getPrintName(srcprop.getTypeSet()) + " has error types not handled by source propagation " + EMV2Util.getPrintName(dstprop) + EMV2Util.getPrintName(dstprop.getTypeSet()));
}
}
if (srccontain != null && dstcontain != null) {
if (!EMV2TypeSetUtil.contains(srcprop.getTypeSet(), dstprop.getTypeSet())) {
error(conn, "Reverse direction: Destination containment " + EMV2Util.getPrintName(srcprop) + EMV2Util.getPrintName(srcprop.getTypeSet()) + " does not contain error types listed by source containment " + EMV2Util.getPrintName(dstprop) + EMV2Util.getPrintName(dstprop.getTypeSet()));
}
}
// instance level
if (srcCxt instanceof Subcomponent && dstCxt instanceof Subcomponent) {
// only when going across
if (srccontain == null && dstcontain != null) {
warning(conn, "No outgoing containment for incoming containment " + EMV2Util.getPrintName(dstcontain) + EMV2Util.getPrintName(dstcontain.getTypeSet()));
}
if (srcprop != null && dstprop == null) {
warning(conn, "No incoming error propagation for outgoing propagation " + EMV2Util.getPrintName(srcprop) + EMV2Util.getPrintName(srcprop.getTypeSet()));
}
}
}
}
Aggregations