Search in sources :

Example 1 with EventValueReferenceExpression

use of org.yakindu.sct.model.stext.stext.EventValueReferenceExpression in project statecharts by Yakindu.

the class STextJavaValidator method checkValueOfNoEvent.

@Check(CheckType.FAST)
public void checkValueOfNoEvent(EventValueReferenceExpression exp) {
    Expression eventExpr = exp.getValue();
    EObject element = null;
    if (eventExpr instanceof ElementReferenceExpression) {
        element = ((ElementReferenceExpression) eventExpr).getReference();
    } else if (eventExpr instanceof FeatureCall) {
        element = ((FeatureCall) eventExpr).getFeature();
    }
    if (element != null && (!(element instanceof Event))) {
        String elementName = "";
        if (element instanceof NamedElement) {
            elementName = "'" + ((NamedElement) element).getName() + "' ";
        }
        error(elementName + "is no event.", StextPackage.Literals.EVENT_VALUE_REFERENCE_EXPRESSION__VALUE, 0, VALUE_OF_REQUIRES_EVENT);
    }
}
Also used : EventRaisingExpression(org.yakindu.sct.model.stext.stext.EventRaisingExpression) Expression(org.yakindu.base.expressions.expressions.Expression) AssignmentExpression(org.yakindu.base.expressions.expressions.AssignmentExpression) EventValueReferenceExpression(org.yakindu.sct.model.stext.stext.EventValueReferenceExpression) ElementReferenceExpression(org.yakindu.base.expressions.expressions.ElementReferenceExpression) PostFixUnaryExpression(org.yakindu.base.expressions.expressions.PostFixUnaryExpression) EObject(org.eclipse.emf.ecore.EObject) ExitEvent(org.yakindu.sct.model.stext.stext.ExitEvent) EntryEvent(org.yakindu.sct.model.stext.stext.EntryEvent) Event(org.yakindu.base.types.Event) ElementReferenceExpression(org.yakindu.base.expressions.expressions.ElementReferenceExpression) FeatureCall(org.yakindu.base.expressions.expressions.FeatureCall) NamedElement(org.yakindu.base.base.NamedElement) Check(org.eclipse.xtext.validation.Check)

Aggregations

EObject (org.eclipse.emf.ecore.EObject)1 Check (org.eclipse.xtext.validation.Check)1 NamedElement (org.yakindu.base.base.NamedElement)1 AssignmentExpression (org.yakindu.base.expressions.expressions.AssignmentExpression)1 ElementReferenceExpression (org.yakindu.base.expressions.expressions.ElementReferenceExpression)1 Expression (org.yakindu.base.expressions.expressions.Expression)1 FeatureCall (org.yakindu.base.expressions.expressions.FeatureCall)1 PostFixUnaryExpression (org.yakindu.base.expressions.expressions.PostFixUnaryExpression)1 Event (org.yakindu.base.types.Event)1 EntryEvent (org.yakindu.sct.model.stext.stext.EntryEvent)1 EventRaisingExpression (org.yakindu.sct.model.stext.stext.EventRaisingExpression)1 EventValueReferenceExpression (org.yakindu.sct.model.stext.stext.EventValueReferenceExpression)1 ExitEvent (org.yakindu.sct.model.stext.stext.ExitEvent)1