示例#1
0
  /**
   * Checks if all composite states that are siblings of a shallow history can enter their regions.
   *
   * @param e
   */
  @Check(CheckType.FAST)
  public void regionCantBeEnteredUsingShallowHistory(Entry e) {

    if (e.getKind() == EntryKind.SHALLOW_HISTORY) {

      // get all regions off all sibling states
      List<Region> regions = new ArrayList<Region>();
      for (Vertex v : e.getParentRegion().getVertices()) {
        if (v instanceof org.yakindu.sct.model.sgraph.State) {
          org.yakindu.sct.model.sgraph.State state = (org.yakindu.sct.model.sgraph.State) v;
          regions.addAll(state.getRegions());
        }
      }

      // check each region
      for (Region r : regions) {

        // first determine if the region contains a default entry
        Entry defaultEntry = null;
        for (Vertex v : r.getVertices()) {
          if (v instanceof Entry) {
            String name = v.getName().trim().toLowerCase();
            if (name != null || "".equals(name) || "default".equals(name)) {
              defaultEntry = (Entry) v;
              break;
            }
          }
        }

        // now check error conditions
        if (defaultEntry == null) {
          error(ISSUE_REGION_CANT_BE_ENTERED_USING_SHALLOW_HISTORY_NO_DEFAULT_ENTRY, r, null, -1);
        } else if (defaultEntry.getOutgoingTransitions().size() != 1) {
          error(
              ISSUE_REGION_CANT_BE_ENTERED_USING_SHALLOW_HISTORY_NON_CONNECTED_DEFAULT_ENTRY,
              r,
              null,
              -1);
        }
      }
    }
  }
示例#2
0
 @Check(CheckType.FAST)
 public void initialEntryWithoutIncomingTransitions(Entry entry) {
   if (entry.getIncomingTransitions().size() > 0 && entry.getKind().equals(EntryKind.INITIAL)) {
     warning(ISSUE_INITIAL_ENTRY_WITH_IN_TRANS, entry, null, -1);
   }
 }