@Check(CheckType.FAST) public void checkUnusedEntry(final Entry entry) { if (entry.getParentRegion().getComposite() instanceof org.yakindu.sct.model.sgraph.State && entry.getIncomingTransitions().isEmpty()) { org.yakindu.sct.model.sgraph.State state = (org.yakindu.sct.model.sgraph.State) entry.getParentRegion().getComposite(); if (!STextValidationModelUtils.isDefault(entry)) { boolean hasIncomingTransition = false; Iterator<Transition> transitionIt = state.getIncomingTransitions().iterator(); while (transitionIt.hasNext() && !hasIncomingTransition) { Iterator<ReactionProperty> propertyIt = transitionIt.next().getProperties().iterator(); while (propertyIt.hasNext() && !hasIncomingTransition) { ReactionProperty property = propertyIt.next(); if (property instanceof EntryPointSpec) { hasIncomingTransition = entry.getName().equals(((EntryPointSpec) property).getEntrypoint()); } } } if (!hasIncomingTransition) { warning(ENTRY_UNUSED, entry, null, -1); } } } }
/** * 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); } } } }