Search in sources :

Example 16 with ConditionElement

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);
    }
}
Also used : ErrorBehaviorState(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorState) ErrorType(org.osate.xtext.aadl2.errormodel.errorModel.ErrorType) TypeToken(org.osate.xtext.aadl2.errormodel.errorModel.TypeToken) EObject(org.eclipse.emf.ecore.EObject) TypeSet(org.osate.xtext.aadl2.errormodel.errorModel.TypeSet) CompositeState(org.osate.xtext.aadl2.errormodel.errorModel.CompositeState)

Aggregations

ErrorPropagation (org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation)10 ConditionElement (org.osate.xtext.aadl2.errormodel.errorModel.ConditionElement)9 TypeSet (org.osate.xtext.aadl2.errormodel.errorModel.TypeSet)9 ErrorBehaviorState (org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorState)8 SConditionElement (org.osate.xtext.aadl2.errormodel.errorModel.SConditionElement)6 TypeToken (org.osate.xtext.aadl2.errormodel.errorModel.TypeToken)6 EObject (org.eclipse.emf.ecore.EObject)5 ConditionExpression (org.osate.xtext.aadl2.errormodel.errorModel.ConditionExpression)5 ErrorEvent (org.osate.xtext.aadl2.errormodel.errorModel.ErrorEvent)5 EventOrPropagation (org.osate.xtext.aadl2.errormodel.errorModel.EventOrPropagation)5 NamedElement (org.osate.aadl2.NamedElement)4 AndExpression (org.osate.xtext.aadl2.errormodel.errorModel.AndExpression)4 ErrorBehaviorTransition (org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorTransition)4 OrExpression (org.osate.xtext.aadl2.errormodel.errorModel.OrExpression)4 ContainedNamedElement (org.osate.aadl2.ContainedNamedElement)3 AllExpression (org.osate.xtext.aadl2.errormodel.errorModel.AllExpression)3 EMV2PathElement (org.osate.xtext.aadl2.errormodel.errorModel.EMV2PathElement)3 OrmoreExpression (org.osate.xtext.aadl2.errormodel.errorModel.OrmoreExpression)3 QualifiedErrorBehaviorState (org.osate.xtext.aadl2.errormodel.errorModel.QualifiedErrorBehaviorState)3 LinkedList (java.util.LinkedList)2