use of org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorState in project osate2 by osate.
the class ErrorModelValidator method checkAssociationAppliesTo.
private void checkAssociationAppliesTo(final EMV2PropertyAssociation pa) {
final Property pn = pa.getProperty();
final EList<EMV2Path> appliesTo = pa.getEmv2Path();
if (appliesTo == null || appliesTo.size() == 0) {
Element element = pa.getOwner();
if (element instanceof NamedElement) {
final boolean applies = ((NamedElement) element).acceptsProperty(pn);
if (!applies) {
error(pa, "Property " + pa.getProperty().getQualifiedName() + " does not apply to " + ((NamedElement) element).getName());
// error(pa,
// "Property " + pa.getQualifiedName() +
// " does not apply to " + element.eClass().getName());
}
}
} else {
for (EMV2Path cna : appliesTo) {
EMV2PathElement path = cna.getEmv2Target();
if (path != null) {
// only the last value is interesting to us
final EMV2PathElement ph = EMV2Util.getLast(path);
NamedElement ne = ph.getNamedElement();
if (ne instanceof ErrorTypes) {
ErrorTypes et = (ErrorTypes) ne;
EObject prev = ph.eContainer();
if (prev instanceof EMV2PathElement) {
ne = ((EMV2PathElement) prev).getNamedElement();
boolean noMatch = false;
if (ne instanceof ErrorBehaviorState) {
TypeSet ts = ((ErrorBehaviorState) ne).getTypeSet();
noMatch = ts != null && !EMV2TypeSetUtil.contains(ts, et);
} else if (ne instanceof ErrorPropagation) {
String epname = EMV2Util.getPrintName((ErrorPropagation) ne);
EList<ErrorPropagation> eplist = EMV2Util.getContainingErrorModelSubclause(ne).getPropagations();
Boolean foundType = false;
for (ErrorPropagation ep : eplist) {
if (epname.equalsIgnoreCase(EMV2Util.getPrintName(ep))) {
TypeSet ts = ep.getTypeSet();
if (EMV2TypeSetUtil.contains(ts, et)) {
foundType = true;
break;
}
}
}
noMatch = !foundType;
} else if (ne instanceof ErrorEvent) {
TypeSet ts = ((ErrorEvent) ne).getTypeSet();
noMatch = ts != null && !EMV2TypeSetUtil.contains(ts, et);
}
if (noMatch) {
error(pa, "Property " + pa.getProperty().getQualifiedName() + " applies to refers to type " + EMV2Util.getPrintName(et) + " not contained in type set of error propagation " + EMV2Util.getPrintName(ne));
}
}
}
if (!Aadl2Util.isNull(ne)) {
final boolean applies = ph.getNamedElement().acceptsProperty(pn);
if (!applies) {
error(pa, "Property " + pa.getProperty().getQualifiedName() + " does not apply to " + EMV2Util.getPrintName(cna));
}
}
}
}
}
}
use of org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorState in project osate2 by osate.
the class ErrorModelValidator method checkTransitionSourceTypes.
private void checkTransitionSourceTypes(ErrorBehaviorTransition ebt) {
ErrorBehaviorState ebs = ebt.getSource();
if (ebs == null) {
return;
}
TypeSet ebsTS = ebs.getTypeSet();
TypeSet srcTS = ebt.getTypeTokenConstraint();
if (srcTS == null) {
return;
}
if (ebsTS == null && srcTS != null) {
error(ebt, "Source state " + ebs.getName() + " does not have a type set declared but the transition source specifies " + EMV2Util.getPrintName(srcTS));
} else if (!EMV2TypeSetUtil.contains(ebsTS, srcTS)) {
error(ebt, "Source type " + EMV2Util.getPrintName(srcTS) + " is not contained in type set of error behavior state \'" + ebs.getName() + "\'");
}
}
use of org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorState in project osate2 by osate.
the class ErrorModelValidator method checkOutgoingConditionSourceTypes.
private void checkOutgoingConditionSourceTypes(OutgoingPropagationCondition opc) {
ErrorBehaviorState ebs = opc.getState();
if (ebs == null) {
return;
}
TypeSet ebsTS = ebs.getTypeSet();
TypeSet srcTS = opc.getTypeTokenConstraint();
if (srcTS == null) {
return;
}
if (ebsTS == null && srcTS != null) {
error(opc, "Error state " + ebs.getName() + " does not have a type set declared but the outgoing propagation condition has type token " + EMV2Util.getPrintName(srcTS));
} else if (!EMV2TypeSetUtil.contains(ebsTS, srcTS)) {
error(opc, "Outgoing condition state type set " + EMV2Util.getPrintName(srcTS) + " is not contained in type set of error behavior state \'" + ebs.getName() + "\'");
}
}
use of org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorState in project osate2 by osate.
the class EMV2Util method getAllErrorBehaviorStates.
/**
* return list of ErrorBehaviorStates including those inherited from classifiers being extended
* @param cl Classifier
* @return Collection<ErrorBehaviorState> list of ErrorBehaviorStates as HashMap for quick lookup of names
*/
public static Collection<ErrorBehaviorState> getAllErrorBehaviorStates(Classifier cl) {
HashMap<String, ErrorBehaviorState> result = new LinkedHashMap<>();
EList<ErrorModelSubclause> emslist = getAllContainingClassifierEMV2Subclauses(cl);
for (ErrorModelSubclause errorModelSubclause : emslist) {
ErrorBehaviorStateMachine ebsm = errorModelSubclause.getUseBehavior();
if (ebsm != null) {
EList<ErrorBehaviorState> eflist = ebsm.getStates();
for (ErrorBehaviorState ebs : eflist) {
if (!result.containsKey(ebs.getName())) {
result.put(ebs.getName(), ebs);
}
}
return result.values();
}
}
return Collections.emptyList();
}
use of org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorState in project osate2 by osate.
the class ErrorModelValidator method checkTransitionTargetTypes.
private void checkTransitionTargetTypes(TransitionBranch ebt) {
if (ebt.isSteadyState()) {
return;
}
ErrorBehaviorState ebs = ebt.getTarget();
if (ebs != null) {
TypeSet ebsTS = ebs.getTypeSet();
TypeSet tt = ebt.getTargetToken();
if (tt == null || tt.getTypeTokens().isEmpty()) {
return;
}
TypeToken ebtargetTS = tt.getTypeTokens().get(0);
if (ebtargetTS == null) {
return;
}
if (ebsTS == null && ebtargetTS != null) {
error(ebt, "Target state " + ebs.getName() + " does not have a type set declared but the transition target specifies " + EMV2Util.getPrintName(ebtargetTS));
} else if (!EMV2TypeSetUtil.contains(ebsTS, ebtargetTS)) {
error(ebt, "Target type " + EMV2Util.getPrintName(ebt.getTargetToken()) + " is not contained in type set of error behavior state \'" + ebs.getName() + "\'");
}
}
}
Aggregations