use of org.yakindu.sct.model.sgraph.Transition in project statecharts by Yakindu.
the class FoldIncomingActionsRefactoring method getFoldableActions.
private List<Expression> getFoldableActions() {
EList<Transition> transitions = getContextObject().getIncomingTransitions();
List<Expression> foldableActions = new ArrayList<Expression>();
Expression lastFoldableAction;
int indexFromBack = 0;
while ((lastFoldableAction = getLastFoldableAction(helper.getAllActions(transitions), indexFromBack)) != null) {
foldableActions.add(0, lastFoldableAction);
indexFromBack++;
}
removeLastActions(transitions, indexFromBack);
return foldableActions;
}
use of org.yakindu.sct.model.sgraph.Transition in project statecharts by Yakindu.
the class STextValidationModelUtils method getEntrySpecSortedTransitions.
/**
* Sorts the given elements in transition without and with
* {@link EntryPointSpec}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 EntryPointSpec}s. The
* second index contains a list of the transitions with
* {@link EntryPointSpec}s.
*/
public static List<Transition>[] getEntrySpecSortedTransitions(List<Transition> elements) {
@SuppressWarnings("unchecked") final List<Transition>[] transitions = new ArrayList[2];
// first list contains Transitions without entry spec
transitions[0] = new ArrayList<Transition>();
// second list contains Transitions with entry spec
transitions[1] = new ArrayList<Transition>();
for (Transition transition : elements) {
boolean hasEntrySpec = false;
for (ReactionProperty property : transition.getProperties()) {
if (property instanceof EntryPointSpec) {
transitions[1].add(transition);
hasEntrySpec = true;
break;
}
}
if (!hasEntrySpec) {
transitions[0].add(transition);
}
}
return transitions;
}
use of org.yakindu.sct.model.sgraph.Transition in project statecharts by Yakindu.
the class SGraphJavaValidator method vertexNotReachable.
@Check(CheckType.FAST)
public void vertexNotReachable(final Vertex vertex) {
if (!(vertex instanceof Entry)) {
final Set<Object> stateScopeSet = new HashSet<>();
for (EObject obj : EcoreUtil2.eAllContents(vertex)) {
stateScopeSet.add(obj);
}
stateScopeSet.add(vertex);
final List<Object> externalPredecessors = new ArrayList<>();
DFS dfs = new DFS() {
@Override
public Iterator<Object> getElementLinks(Object element) {
List<Object> elements = new ArrayList<>();
if (element instanceof org.yakindu.sct.model.sgraph.State) {
if (!stateScopeSet.contains(element)) {
externalPredecessors.add(element);
} else {
elements.addAll(((org.yakindu.sct.model.sgraph.State) element).getRegions());
elements.addAll(((org.yakindu.sct.model.sgraph.State) element).getIncomingTransitions());
}
} else if (element instanceof Region) {
elements.addAll(((Region) element).getVertices());
} else if (element instanceof Entry) {
if (!stateScopeSet.contains(element)) {
externalPredecessors.add(element);
} else {
elements.addAll(((Entry) element).getIncomingTransitions());
}
} else if (element instanceof Vertex) {
elements.addAll(((Vertex) element).getIncomingTransitions());
} else if (element instanceof Transition) {
elements.add(((Transition) element).getSource());
}
return elements.iterator();
}
};
dfs.perform(vertex);
if (externalPredecessors.size() == 0) {
error(ISSUE_NODE_NOT_REACHABLE, vertex, null, -1);
}
}
}
Aggregations