use of org.yakindu.sct.model.sgraph.Exit in project statecharts by Yakindu.
the class ExtractSubdiagramRefactoring method createSemanticExitPoint.
private Exit createSemanticExitPoint(Transition transition) {
Region exitPointContainer = getExitPointContainer(transition);
String name = getExitPointName(transition);
Exit exitPoint = null;
Iterator<Vertex> iterator = exitPointContainer.getVertices().iterator();
while (iterator.hasNext()) {
Vertex next = iterator.next();
if (next instanceof Exit) {
Exit current = (Exit) next;
if (name.equals(current.getName())) {
// Do nothing, there already exists an entry point
return current;
}
}
}
exitPoint = SGraphFactory.eINSTANCE.createExit();
exitPoint.setName(name);
exitPointContainer.getVertices().add(exitPoint);
return exitPoint;
}
use of org.yakindu.sct.model.sgraph.Exit in project statecharts by Yakindu.
the class STextValidationModelUtils method getRegionsWithoutDefaultExit.
/**
* If a {@link Region} contains no 'default' named {@link exit} it is added
* as key to a map with a list of all exits of the region.
*
* @param elements
* - a list with {@link Region} elements.
* @return a map with a region (key) which contains no default {@link exit}
* and a list of all {@link exit} elements of the {@link Region}
* (value).
*/
public static Map<Region, List<Exit>> getRegionsWithoutDefaultExit(List<Region> elements) {
Map<Region, List<Exit>> regions = new HashMap<Region, List<Exit>>();
for (Region region : elements) {
boolean hasDefaultExit = false;
final List<Exit> exits = getExits(region.eContents());
if (!exits.isEmpty()) {
for (Exit exit : exits) {
if (isDefault(exit)) {
hasDefaultExit = true;
break;
}
}
} else {
hasDefaultExit = true;
}
if (!hasDefaultExit) {
regions.put(region, exits);
}
}
return regions;
}
use of org.yakindu.sct.model.sgraph.Exit in project statecharts by Yakindu.
the class SGraphJavaValidationTest method cleanExit.
/**
* Tests a scenario where no issues for an exit nodes exists.
*/
@Test
public void cleanExit() {
prepareStateTest();
Region subRegion = factory.createRegion();
state.getRegions().add(subRegion);
Exit exit = factory.createExit();
subRegion.getVertices().add(exit);
State s = factory.createState();
subRegion.getVertices().add(s);
Transition t = factory.createTransition();
t.setTarget(exit);
t.setSource(s);
assertTrue(validate(exit));
assertNoIssues(diagnostics);
}
use of org.yakindu.sct.model.sgraph.Exit in project statecharts by Yakindu.
the class SGraphJavaValidationTest method exitOnStatechart.
/**
* An exit node must not be used in top level regions.
*/
@Test
public void exitOnStatechart() {
prepareStateTest();
Exit exit = factory.createExit();
region.getVertices().add(exit);
assertFalse(validate(exit));
assertError(diagnostics, ISSUE_EXIT_ON_STATECHART);
}
use of org.yakindu.sct.model.sgraph.Exit in project statecharts by Yakindu.
the class SGraphJavaValidationTest method exitWithOutgoingTransition.
/**
* An exit node must have no outgoing transitions.
*/
@Test
public void exitWithOutgoingTransition() {
prepareStateTest();
Region subRegion = factory.createRegion();
state.getRegions().add(subRegion);
Exit exit = factory.createExit();
subRegion.getVertices().add(exit);
State s = factory.createState();
subRegion.getVertices().add(s);
Transition t = factory.createTransition();
t.setSource(exit);
t.setTarget(s);
assertFalse(validate(exit));
assertError(diagnostics, ISSUE_EXIT_WITH_OUT_TRANS);
}
Aggregations