use of org.yakindu.sct.model.sgraph.Transition in project statecharts by Yakindu.
the class STextJavaValidator method checkUnusedEntry.
@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);
}
}
}
}
use of org.yakindu.sct.model.sgraph.Transition in project statecharts by Yakindu.
the class STextJavaValidator method checkUnusedExit.
@Check(CheckType.NORMAL)
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);
}
}
}
}
use of org.yakindu.sct.model.sgraph.Transition in project statecharts by Yakindu.
the class STextValidationModelUtils method getExitSpecSortedTransitions.
/**
* Sorts the given elements in transition without and with
* {@link ExitPointSpec}s
*
* @param elements
* - list of transitions to sort
* @return an array with the sorted elements. The first index contains a
* list of the transitions without {@link ExitPointSpec}s. The
* second index contains a list of the transitions with
* {@link ExitPointSpec}s.
*/
public static List<Transition>[] getExitSpecSortedTransitions(List<Transition> elements) {
@SuppressWarnings("unchecked") final List<Transition>[] transitions = new ArrayList[2];
// first list contains Transitions without exit spec
transitions[0] = new ArrayList<Transition>();
// second list contains Transitions with exit spec
transitions[1] = new ArrayList<Transition>();
for (Transition transition : elements) {
boolean hasExitSpec = false;
for (ReactionProperty property : transition.getProperties()) {
if (property instanceof ExitPointSpec) {
transitions[1].add(transition);
hasExitSpec = true;
break;
}
}
if (!hasExitSpec) {
transitions[0].add(transition);
}
}
return transitions;
}
use of org.yakindu.sct.model.sgraph.Transition in project statecharts by Yakindu.
the class SGraphJavaValidator method orthogonalSynchronizedTransition.
@Check
public void orthogonalSynchronizedTransition(Synchronization sync) {
List<Transition> incoming = sync.getIncomingTransitions();
List<List<EObject>> inAncestorsList = new ArrayList<>();
for (Transition trans : incoming) {
inAncestorsList.add(collectAncestors(trans.getSource(), new ArrayList<EObject>()));
}
List<Transition> outgoing = sync.getOutgoingTransitions();
List<List<EObject>> outAncestorsList = new ArrayList<>();
for (Transition trans : outgoing) {
outAncestorsList.add(collectAncestors(trans.getTarget(), new ArrayList<EObject>()));
}
Set<Transition> inOrthogonal = new HashSet<>();
Set<Transition> outOrthogonal = new HashSet<>();
if (incoming.size() == 0 || outgoing.size() == 0) {
return;
}
for (int i = 0; i < incoming.size(); i++) {
for (int j = 0; j < outgoing.size(); j++) {
List<Vertex> states = new ArrayList<>(Arrays.asList(incoming.get(i).getSource(), outgoing.get(j).getTarget()));
if (areOrthogonal(states)) {
inOrthogonal.add(incoming.get(i));
outOrthogonal.add(outgoing.get(j));
}
}
}
for (Transition trans : inOrthogonal) {
error(ISSUE_SYNCHRONIZATION_SOURCE_TARGET_STATES_PARENT_REGION, trans, null, -1);
}
for (Transition trans : outOrthogonal) {
error(ISSUE_SYNCHRONIZATION_SOURCE_TARGET_STATES_PARENT_REGION, trans, null, -1);
}
}
use of org.yakindu.sct.model.sgraph.Transition in project statecharts by Yakindu.
the class TransitionItemProvider method getText.
/**
* This returns the label text for the adapted class. <!-- begin-user-doc
* --> <!-- end-user-doc -->
*
* @generated NOT
*/
@Override
public String getText(Object object) {
Transition transition = (Transition) object;
String specification = transition.getSpecification() != null ? " (" + transition.getSpecification() + ")" : "";
return getVertexName(transition.getSource()) + " -> " + getVertexName(transition.getTarget()) + specification;
}
Aggregations