Search in sources :

Example 1 with EventSpec

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

the class STextJavaValidator method checkReactionTriggerRegularEvent.

@Check(CheckType.FAST)
public void checkReactionTriggerRegularEvent(ReactionTrigger reactionTrigger) {
    for (int i = 0; i < reactionTrigger.getTriggers().size(); i++) {
        EventSpec eventSpec = reactionTrigger.getTriggers().get(i);
        if (eventSpec instanceof RegularEventSpec) {
            EObject element = unwrap(((RegularEventSpec) eventSpec).getEvent());
            if (element != null && (!(element instanceof Event))) {
                String elementName = "";
                if (element instanceof NamedElement) {
                    elementName = "'" + ((NamedElement) element).getName() + "' ";
                }
                error("Trigger " + elementName + "is no event.", StextPackage.Literals.REACTION_TRIGGER__TRIGGERS, i, TRIGGER_IS_NO_EVENT);
            }
        }
    }
}
Also used : TimeEventSpec(org.yakindu.sct.model.stext.stext.TimeEventSpec) RegularEventSpec(org.yakindu.sct.model.stext.stext.RegularEventSpec) EventSpec(org.yakindu.sct.model.stext.stext.EventSpec) 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) NamedElement(org.yakindu.base.base.NamedElement) RegularEventSpec(org.yakindu.sct.model.stext.stext.RegularEventSpec) Check(org.eclipse.xtext.validation.Check)

Example 2 with EventSpec

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

the class RefactoringHelper method getFirstEntryActions.

/**
 * Returns the entry actions of a state. Returns null if no entry block is
 * defined. If multiple entry blocks are defined, only the actions of the first
 * one are returned.
 *
 * @param state
 * @return list of actions of the first entry block defined in the specified
 *         state
 */
public EList<Expression> getFirstEntryActions(State state) {
    EList<Reaction> localReactions = state.getLocalReactions();
    for (Reaction reaction : localReactions) {
        Trigger trigger = reaction.getTrigger();
        if (trigger instanceof ReactionTrigger) {
            ReactionTrigger reactionTrigger = (ReactionTrigger) trigger;
            EList<EventSpec> triggers = reactionTrigger.getTriggers();
            for (EventSpec eventSpec : triggers) {
                if (eventSpec instanceof EntryEvent && reaction.getEffect() instanceof ReactionEffect) {
                    return ((ReactionEffect) reaction.getEffect()).getActions();
                }
            }
        }
    }
    return null;
}
Also used : ReactionTrigger(org.yakindu.sct.model.stext.stext.ReactionTrigger) Trigger(org.yakindu.sct.model.sgraph.Trigger) EventSpec(org.yakindu.sct.model.stext.stext.EventSpec) ReactionTrigger(org.yakindu.sct.model.stext.stext.ReactionTrigger) EntryEvent(org.yakindu.sct.model.stext.stext.EntryEvent) ReactionEffect(org.yakindu.sct.model.stext.stext.ReactionEffect) Reaction(org.yakindu.sct.model.sgraph.Reaction)

Example 3 with EventSpec

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

the class RefactoringHelper method getFirstExitActions.

/**
 * Returns the exit actions of a state. Returns null if no exit block is
 * defined. If multiple exit blocks are defined, only the actions of the first
 * one are returned.
 *
 * @param state
 * @return list of actions of the first exit block defined in the specified
 *         state
 */
public EList<Expression> getFirstExitActions(State state) {
    EList<Reaction> localReactions = state.getLocalReactions();
    for (Reaction reaction : localReactions) {
        Trigger trigger = reaction.getTrigger();
        if (trigger instanceof ReactionTrigger) {
            ReactionTrigger reactionTrigger = (ReactionTrigger) trigger;
            EList<EventSpec> triggers = reactionTrigger.getTriggers();
            for (EventSpec eventSpec : triggers) {
                if (eventSpec instanceof ExitEvent && reaction.getEffect() instanceof ReactionEffect) {
                    return ((ReactionEffect) reaction.getEffect()).getActions();
                }
            }
        }
    }
    return null;
}
Also used : ReactionTrigger(org.yakindu.sct.model.stext.stext.ReactionTrigger) Trigger(org.yakindu.sct.model.sgraph.Trigger) EventSpec(org.yakindu.sct.model.stext.stext.EventSpec) ReactionTrigger(org.yakindu.sct.model.stext.stext.ReactionTrigger) ReactionEffect(org.yakindu.sct.model.stext.stext.ReactionEffect) Reaction(org.yakindu.sct.model.sgraph.Reaction) ExitEvent(org.yakindu.sct.model.stext.stext.ExitEvent)

Aggregations

EventSpec (org.yakindu.sct.model.stext.stext.EventSpec)3 Reaction (org.yakindu.sct.model.sgraph.Reaction)2 Trigger (org.yakindu.sct.model.sgraph.Trigger)2 EntryEvent (org.yakindu.sct.model.stext.stext.EntryEvent)2 ExitEvent (org.yakindu.sct.model.stext.stext.ExitEvent)2 ReactionEffect (org.yakindu.sct.model.stext.stext.ReactionEffect)2 ReactionTrigger (org.yakindu.sct.model.stext.stext.ReactionTrigger)2 EObject (org.eclipse.emf.ecore.EObject)1 Check (org.eclipse.xtext.validation.Check)1 NamedElement (org.yakindu.base.base.NamedElement)1 Event (org.yakindu.base.types.Event)1 RegularEventSpec (org.yakindu.sct.model.stext.stext.RegularEventSpec)1 TimeEventSpec (org.yakindu.sct.model.stext.stext.TimeEventSpec)1