Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuergen Haug2019-06-25 15:25:22 +0000
committerHenrik Rentz-Reichert2019-08-09 13:18:06 +0000
commit39770a85b966fb491193f45da4d743724b248c71 (patch)
treea300c2c1f2c374de44d8f8048111cb1bb8f35ced /plugins/org.eclipse.etrice.core.genmodel.fsm
parent733680d60939f3ae14c23d01a7e91a4343106517 (diff)
downloadorg.eclipse.etrice-39770a85b966fb491193f45da4d743724b248c71.tar.gz
org.eclipse.etrice-39770a85b966fb491193f45da4d743724b248c71.tar.xz
org.eclipse.etrice-39770a85b966fb491193f45da4d743724b248c71.zip
Bug 541775 - [generator.fsm] State machine without initial transition
causes null pointer exception in generator * added test * fixed NPE * added validation on genmodel level Change-Id: Ib4f66e88ad995a7a1178312e5a39873bfaf37544
Diffstat (limited to 'plugins/org.eclipse.etrice.core.genmodel.fsm')
-rw-r--r--plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/ExtendedFsmGenBuilder.xtend32
1 files changed, 32 insertions, 0 deletions
diff --git a/plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/ExtendedFsmGenBuilder.xtend b/plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/ExtendedFsmGenBuilder.xtend
index 5dd9c54f9..a26ee681f 100644
--- a/plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/ExtendedFsmGenBuilder.xtend
+++ b/plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/ExtendedFsmGenBuilder.xtend
@@ -32,6 +32,8 @@ import org.eclipse.etrice.core.genmodel.fsm.fsmgen.Node
import static extension org.eclipse.etrice.core.genmodel.fsm.FsmGenExtensions.*
import org.eclipse.etrice.core.fsm.util.FSMHelpers
+import org.eclipse.etrice.core.fsm.fSM.ModelComponent
+import org.eclipse.etrice.core.genmodel.fsm.fsmgen.Graph
class ExtendedFsmGenBuilder extends BasicFsmGenBuilder {
@@ -49,6 +51,10 @@ class ExtendedFsmGenBuilder extends BasicFsmGenBuilder {
this.validator = if(validator === null) new NullDiagnostician else validator
}
+ override GraphContainer createTransformedModel(ModelComponent mc) {
+ super.createTransformedModel(mc).check(mc)
+ }
+
/**
* computes the available triggers for all leaf states
*/
@@ -229,6 +235,32 @@ class ExtendedFsmGenBuilder extends BasicFsmGenBuilder {
return it
}
+ def protected check(GraphContainer gc, ModelComponent mc) {
+ if (!mc.isAbstract) {
+ gc.eAllContents.toIterable.filter(Graph).forEach[checkInitialTransition(mc)]
+ }
+ return gc
+ }
+
+ def protected checkInitialTransition(Graph graph, ModelComponent mc) {
+ if (graph.initialTransition!==null) {
+ // graph has an initial transition
+ return
+ }
+
+ if (graph.eContainer instanceof GraphContainer) {
+ validationError("Top level state graph must have an initial transition", mc, FSMPackage.Literals.MODEL_COMPONENT__STATE_MACHINE);
+ return;
+ }
+
+ // in the super state graph search for a transition which points to our parent state
+ val parentState = graph.eContainer as Node
+ val parentGraph = parentState.eContainer as Graph
+ if (!parentGraph.links.filter[target==parentState].empty) {
+ validationError("The state graph has transitions to history in its parent graph, thus it must have an initial transition", parentState.stateGraphNode, FSMPackage.Literals.STATE__SUBGRAPH);
+ }
+ }
+
protected def void validationError(String msg, EObject obj, EStructuralFeature feature) {
validationError(msg, obj, feature, IDiagnostician.INSIGNIFICANT_INDEX)
}

Back to the top