@Check(CheckType.FAST) public void checkUnusedExit(final Exit exit) { if (exit.getParentRegion().getComposite() instanceof org.yakindu.sct.model.sgraph.State && exit.getOutgoingTransitions().isEmpty()) { org.yakindu.sct.model.sgraph.State state = (org.yakindu.sct.model.sgraph.State) exit.getParentRegion().getComposite(); if (!STextValidationModelUtils.isDefault(exit)) { boolean hasOutgoingTransition = false; Iterator<Transition> transitionIt = state.getOutgoingTransitions().iterator(); while (transitionIt.hasNext() && !hasOutgoingTransition) { Transition transition = transitionIt.next(); hasOutgoingTransition = STextValidationModelUtils.isDefaultExitTransition(transition) ? true : STextValidationModelUtils.isNamedExitTransition(transition, exit.getName()); } if (!hasOutgoingTransition) { error(EXIT_UNUSED, exit, null, -1); } } else { boolean hasOutgoingTransition = false; Iterator<Transition> transitionIt = state.getOutgoingTransitions().iterator(); while (transitionIt.hasNext() && !hasOutgoingTransition) { hasOutgoingTransition = STextValidationModelUtils.isDefaultExitTransition(transitionIt.next()); } if (!hasOutgoingTransition) { error(EXIT_DEFAULT_UNUSED, exit, null, -1); } } } }
@Check(CheckType.FAST) public void checkTransitionPropertySpec(final Transition transition) { for (ReactionProperty property : transition.getProperties()) { if (property instanceof EntryPointSpec) { if (transition.getTarget() instanceof org.yakindu.sct.model.sgraph.State) { org.yakindu.sct.model.sgraph.State state = (org.yakindu.sct.model.sgraph.State) transition.getTarget(); if (!state.isComposite()) { warning(TRANSITION_ENTRY_SPEC_NOT_COMPOSITE, transition, null, -1); } } } else if (property instanceof ExitPointSpec) { final ExitPointSpec exitPointSpec = (ExitPointSpec) property; if (transition.getSource() instanceof org.yakindu.sct.model.sgraph.State) { org.yakindu.sct.model.sgraph.State state = (org.yakindu.sct.model.sgraph.State) transition.getSource(); if (!state.isComposite()) { warning(TRANSITION_EXIT_SPEC_NOT_COMPOSITE, transition, null, -1); } else { // Validate an exit point is continued on one transition // only. for (Transition t : state.getOutgoingTransitions()) { if (transition != t && STextValidationModelUtils.isNamedExitTransition( t, exitPointSpec.getExitpoint())) { warning(TRANSITION_EXIT_SPEC_ON_MULTIPLE_SIBLINGS, transition, null, -1); } } // Validate the state has minimally one named exit // region boolean hasExit = false; Iterator<Region> regionIter = state.getRegions().iterator(); while (regionIter.hasNext() && !hasExit) { Iterator<Exit> exitIter = STextValidationModelUtils.getExits(regionIter.next().eContents()).iterator(); while (exitIter.hasNext() && !hasExit) { Exit exit = exitIter.next(); hasExit = exitPointSpec.getExitpoint().equals(exit.getName()); } } if (!hasExit) { error(TRANSITION_NOT_EXISTING_NAMED_EXIT_POINT, transition, null, -1); } } } } } }
private void addExitPointSpec(Transition transition, Exit exitPoint) { EList<ReactionProperty> properties = transition.getProperties(); ExitPointSpec exitPointSpec = StextFactory.eINSTANCE.createExitPointSpec(); // A transition can only have one exit point so alter the existing for (ReactionProperty reactionProperty : properties) { if (reactionProperty instanceof ExitPointSpec) { exitPointSpec = (ExitPointSpec) reactionProperty; } } exitPointSpec.setExitpoint(exitPoint.getName()); properties.add(exitPointSpec); }
private Exit createSemanticExitPoint(Transition transition) { Region exitPointContainer = getExitPointContainer(transition); String name = getExitPointName(transition); Exit exitPoint = null; Iterator<Vertex> iterator = exitPointContainer.getVertices().iterator(); while (iterator.hasNext()) { Vertex next = iterator.next(); if (next instanceof Exit) { Exit current = (Exit) next; if (name.equals(current.getName())) { // Do nothing, there already exists an entry point return current; } } } exitPoint = SGraphFactory.eINSTANCE.createExit(); exitPoint.setName(name); exitPointContainer.getVertices().add(exitPoint); return exitPoint; }
/** * Exit nodes in top level regions are not supported. * * @param exit */ @Check(CheckType.FAST) public void exitOnStatechart(Exit exit) { if (exit.getParentRegion().getComposite() instanceof Statechart) { error(ISSUE_EXIT_ON_STATECHART, exit, null, -1); } }
@Check(CheckType.FAST) public void exitWithOutgoingTransition(Exit exit) { if (exit.getOutgoingTransitions().size() > 0) { error(ISSUE_EXIT_WITH_OUT_TRANS, exit, null, -1); } }
@Check(CheckType.FAST) public void exitWithoutIncomingTransition(Exit exit) { if (exit.getIncomingTransitions().size() == 0) { warning(ISSUE_EXIT_WITHOUT_IN_TRANS, exit, null, -1); } }