use of org.softlang.metalib.emf.fsml.fsml.FSMTransition in project metalib by softlang.
the class FSMStateImpl method isReachable.
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated NOT
*/
public boolean isReachable(DiagnosticChain diagnostics, Map<Object, Object> context) {
FSM fsm = (FSM) eContainer();
Set<FSMState> reachable = new HashSet<>();
Stack<FSMState> currents = new Stack<FSMState>();
currents.addAll(fsm.getStates().stream().filter(x -> x.isInitial()).collect(Collectors.toSet()));
while (!currents.isEmpty()) {
FSMState current = currents.pop();
if (current == this)
return true;
if (reachable.contains(current))
continue;
reachable.add(current);
for (FSMTransition transition : current.getTransitions()) if (transition.getTarget() != null)
currents.push(transition.getTarget());
}
if (diagnostics != null) {
diagnostics.add(new BasicDiagnostic(Diagnostic.ERROR, FsmlValidator.DIAGNOSTIC_SOURCE, FsmlValidator.FSM_STATE__IS_REACHABLE, EcorePlugin.INSTANCE.getString("_UI_GenericInvariant_diagnostic", new Object[] { "isReachable", EObjectValidator.getObjectLabel(this, context) }), new Object[] { this }));
}
return false;
}
use of org.softlang.metalib.emf.fsml.fsml.FSMTransition in project metalib by softlang.
the class FSMTransitionItemProvider 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) {
FSMTransition transition = (FSMTransition) object;
StringBuilder sb = new StringBuilder();
sb.append((transition.getInput() != null && !"".equals(transition.getInput())) ? transition.getInput() : "undefined");
if (transition.getAction() != null && !"".equals(transition.getAction())) {
sb.append("/");
sb.append(transition.getAction());
}
if (transition.getTarget() != null) {
sb.append("->");
sb.append(transition.getTarget().getName());
}
return sb.toString();
}
Aggregations