コード例 #1
0
 private void addEntryPointSpec(Transition transition, Entry entryPoint) {
   EList<ReactionProperty> properties = transition.getProperties();
   EntryPointSpec entryPointSpec = StextFactory.eINSTANCE.createEntryPointSpec();
   // A transition can only have one entry point so alter the existing
   for (ReactionProperty reactionProperty : properties) {
     if (reactionProperty instanceof EntryPointSpec) {
       entryPointSpec = (EntryPointSpec) reactionProperty;
     }
   }
   entryPointSpec.setEntrypoint(entryPoint.getName());
   properties.add(entryPointSpec);
 }
コード例 #2
0
  @Check(CheckType.FAST)
  public void checkUnboundEntryPoints(final org.yakindu.sct.model.sgraph.State state) {
    if (state.isComposite()) {
      final List<Transition>[] transitions =
          STextValidationModelUtils.getEntrySpecSortedTransitions(state.getIncomingTransitions());
      Map<Region, List<Entry>> regions = null;

      // first list contains Transitions without entry spec
      if (!transitions[0].isEmpty()) {
        regions = STextValidationModelUtils.getRegionsWithoutDefaultEntry(state.getRegions());
        if (!regions.isEmpty()) {
          for (Transition transition : transitions[0]) {
            error(TRANSITION_UNBOUND_DEFAULT_ENTRY_POINT, transition, null, -1);
          }
          for (Region region : regions.keySet()) {
            error(REGION_UNBOUND_DEFAULT_ENTRY_POINT, region, null, -1);
          }
        }
      }

      // second list contains Transitions with entry spec
      if (!transitions[1].isEmpty()) {
        if (regions == null) {
          regions = STextValidationModelUtils.getRegionsWithoutDefaultEntry(state.getRegions());
        }
        for (Transition transition : transitions[1]) {
          boolean hasTargetEntry = true;
          for (ReactionProperty property : transition.getProperties()) {
            if (property instanceof EntryPointSpec) {
              EntryPointSpec spec = (EntryPointSpec) property;
              String specName = "'" + spec.getEntrypoint() + "'";
              for (Region region : regions.keySet()) {
                boolean hasEntry = false;
                for (Entry entry : regions.get(region)) {
                  if (entry.getName().equals(spec.getEntrypoint())) {
                    hasEntry = true;
                    break;
                  }
                }
                if (!hasEntry) {
                  error(REGION_UNBOUND_NAMED_ENTRY_POINT + specName, region, null, -1);
                  hasTargetEntry = false;
                }
              }
              if (!hasTargetEntry) {
                error(TRANSITION_UNBOUND_NAMED_ENTRY_POINT + specName, transition, null, -1);
              }
            }
          }
        }
      }
    }
  }