@Check(CheckType.FAST)
  public void transitionsWithNoTrigger(Transition trans) {
    if (trans.getSource() instanceof Entry
        || trans.getSource() instanceof Choice
        || trans.getSource() instanceof Synchronization) {
      return;
    }
    if (trans.getSource() instanceof org.yakindu.sct.model.sgraph.State) {
      org.yakindu.sct.model.sgraph.State state =
          (org.yakindu.sct.model.sgraph.State) trans.getSource();
      if (state.isComposite()) {
        for (Region r : state.getRegions()) {
          for (Vertex v : r.getVertices()) {
            if (v instanceof Exit) {
              return;
            }
          }
        }
      }
    }

    if (!STextValidationModelUtils.getExitPointSpecs(trans.getProperties()).isEmpty()) {
      return;
    }

    if (trans.getTrigger() == null) {
      warning(ISSUE_TRANSITION_WITHOUT_TRIGGER, trans, null, -1);
    }
  }
 protected String getExitPointName(Transition transition) {
   StringBuilder stringBuilder = new StringBuilder();
   stringBuilder.append("exit_");
   stringBuilder.append(transition.getSource().getName());
   int index = transition.getSource().getOutgoingTransitions().indexOf(transition);
   stringBuilder.append(index);
   return stringBuilder.toString();
 }
  @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);
            }
          }
        }
      }
    }
  }
 @Check(CheckType.FAST)
 public void checkExitPointSpecWithTrigger(Transition t) {
   if (!STextValidationModelUtils.getExitPointSpecs(t.getProperties()).isEmpty()
       && t.getTrigger() != null
       && t.getSource() instanceof org.yakindu.sct.model.sgraph.State) {
     error(EXITPOINTSPEC_WITH_TRIGGER, t, null, -1);
   }
 }
  @Check
  public void orthogonalTransition(Transition transition) {

    Vertex source = transition.getSource();
    Vertex target = transition.getTarget();

    if ((source instanceof Synchronization) || (target instanceof Synchronization))
      return; // ... the check does not apply.

    EObject commonAncestor = commonAncestor(source, target);

    if (commonAncestor instanceof CompositeElement) {

      error(ISSUE_TRANSITION_ORTHOGONAL, transition, null, -1);
    }
  }
  @Check
  public void orthogonalSynchronizedTransition(Synchronization sync) {

    List<Transition> incoming = sync.getIncomingTransitions();
    List<List<EObject>> inAncestorsList = new ArrayList<List<EObject>>();
    for (Transition trans : incoming) {
      inAncestorsList.add(collectAncestors(trans.getSource(), new ArrayList<EObject>()));
    }

    List<Transition> outgoing = sync.getOutgoingTransitions();
    List<List<EObject>> outAncestorsList = new ArrayList<List<EObject>>();
    for (Transition trans : outgoing) {
      outAncestorsList.add(collectAncestors(trans.getTarget(), new ArrayList<EObject>()));
    }

    Set<Transition> inOrthogonal = new HashSet<Transition>(incoming);
    Set<Transition> outOrthogonal = new HashSet<Transition>(outgoing);

    for (int i = 0; i < incoming.size(); i++) {
      for (int j = 0; j < outgoing.size(); j++) {

        EObject commonAncestor =
            findCommonAncestor(inAncestorsList.get(i), outAncestorsList.get(j));

        if (commonAncestor instanceof Region) {
          inOrthogonal.remove(incoming.get(i));
          outOrthogonal.remove(outgoing.get(j));
        }
      }
    }

    for (Transition trans : inOrthogonal) {
      error(ISSUE_SYNCHRONIZATION_SOURCE_STATES_NOT_WITHIN_SAME_PARENTSTATE, trans, null, -1);
    }

    for (Transition trans : outOrthogonal) {
      error(ISSUE_SYNCHRONIZATION_TARGET_STATES_NOT_WITHIN_SAME_PARENTSTATE, trans, null, -1);
    }
  }
 private Region getExitPointContainer(Transition transition) {
   // exit point container is the subdiagram's state's region which
   // contains the transition source
   EObject firstParentRegion = transition.getSource().getParentRegion();
   return getOutermostParentRegion(firstParentRegion);
 }
 @Check(CheckType.FAST)
 public void initialEntryWithTransitionToContainer(Transition t) {
   if (t.getSource() instanceof Entry && !isChildOrSibling(t.getSource(), t.getTarget())) {
     error(ISSUE_INITIAL_ENTRY_WITH_TRANSITION_TO_CONTAINER, t, null, -1);
   }
 }