Browse Source

fixed bug 728: FlowOptimizer fails on histories without initial step (outgoing transition)

terfloth@itemis.de 12 years ago
parent
commit
04ae373ec8
21 changed files with 5787 additions and 5787 deletions
  1. 2 2
      plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/FlowCode.xtend
  2. 2 2
      plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/FlowCode.xtend
  3. 1 1
      plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/transformation/FlowOptimizer.xtend
  4. BIN
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/.BehaviorMapping.java._trace
  5. BIN
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/.FlowOptimizer.java._trace
  6. BIN
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/.ModelSequencer.java._trace
  7. BIN
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/.ReactionBuilder.java._trace
  8. BIN
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/.SequenceBuilder.java._trace
  9. BIN
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/.SexecElementMapping.java._trace
  10. BIN
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/.StatechartExtensions.java._trace
  11. BIN
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/.StextExtensions.java._trace
  12. BIN
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/.StructureMapping.java._trace
  13. 1377 1377
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/BehaviorMapping.java
  14. 808 808
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/FlowOptimizer.java
  15. 265 265
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/ModelSequencer.java
  16. 580 580
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/ReactionBuilder.java
  17. 1006 1006
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/SequenceBuilder.java
  18. 900 900
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/SexecElementMapping.java
  19. 459 459
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/StatechartExtensions.java
  20. 53 53
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/StextExtensions.java
  21. 334 334
      plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/StructureMapping.java

+ 2 - 2
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/FlowCode.xtend

@@ -43,9 +43,9 @@ class FlowCode {
 		«stepComment»
 		if («scHandle»->historyVector[«region.historyVector.offset»] != «last_state») {
 			«historyStep.code»
-		} else {
+		} «IF initialStep != null»else {
 			«initialStep.code»
-		}
+		} «ENDIF»
 	'''
 
 	def dispatch code(StateSwitch it) '''

+ 2 - 2
plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/FlowCode.xtend

@@ -123,9 +123,9 @@ class FlowCode {
 		«stepComment»
 		if (historyVector[«region.historyVector.offset»] != State.$NullState$) {
 			«historyStep.code»
-		} else {
+		} «IF initialStep != null»else {
 			«initialStep.code»
-		}
+		} «ENDIF»
 	'''
 	
 	def dispatch code(SaveHistory it) '''

+ 1 - 1
plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/transformation/FlowOptimizer.xtend

@@ -280,7 +280,7 @@ class FlowOptimizer {
 		_copy.comment = cref.comment
 		_copy.deep =  cref.deep
 		_copy.region =  cref.region
-		_copy.initialStep =  cref.initialStep.stepCopy
+		_copy.initialStep =  cref.initialStep?.stepCopy
 		_copy.historyStep =  cref.historyStep.stepCopy
 
 		_copy

BIN
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/.BehaviorMapping.java._trace


BIN
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/.FlowOptimizer.java._trace


BIN
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/.ModelSequencer.java._trace


BIN
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/.ReactionBuilder.java._trace


BIN
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/.SequenceBuilder.java._trace


BIN
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/.SexecElementMapping.java._trace


BIN
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/.StatechartExtensions.java._trace


BIN
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/.StextExtensions.java._trace


BIN
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/.StructureMapping.java._trace


File diff suppressed because it is too large
+ 1377 - 1377
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/BehaviorMapping.java


File diff suppressed because it is too large
+ 808 - 808
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/FlowOptimizer.java


+ 265 - 265
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/ModelSequencer.java

@@ -1,265 +1,265 @@
-package org.yakindu.sct.model.sexec.transformation;
-
-import com.google.common.base.Objects;
-import com.google.common.collect.Iterables;
-import com.google.inject.Inject;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-import java.util.Set;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogConfigurationException;
-import org.apache.commons.logging.LogFactory;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.xtext.EcoreUtil2;
-import org.eclipse.xtext.naming.IQualifiedNameProvider;
-import org.eclipse.xtext.naming.QualifiedName;
-import org.eclipse.xtext.xbase.lib.Exceptions;
-import org.eclipse.xtext.xbase.lib.Functions.Function1;
-import org.eclipse.xtext.xbase.lib.InputOutput;
-import org.eclipse.xtext.xbase.lib.IterableExtensions;
-import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
-import org.yakindu.base.types.Feature;
-import org.yakindu.sct.model.sexec.ExecutionFlow;
-import org.yakindu.sct.model.sexec.TimeEvent;
-import org.yakindu.sct.model.sexec.transformation.BehaviorMapping;
-import org.yakindu.sct.model.sexec.transformation.ReactionBuilder;
-import org.yakindu.sct.model.sexec.transformation.SequenceBuilder;
-import org.yakindu.sct.model.sexec.transformation.SexecElementMapping;
-import org.yakindu.sct.model.sexec.transformation.StateVectorBuilder;
-import org.yakindu.sct.model.sexec.transformation.StructureMapping;
-import org.yakindu.sct.model.sgraph.Declaration;
-import org.yakindu.sct.model.sgraph.Statechart;
-import org.yakindu.sct.model.stext.stext.ElementReferenceExpression;
-import org.yakindu.sct.model.stext.stext.EventDefinition;
-import org.yakindu.sct.model.stext.stext.FeatureCall;
-import org.yakindu.sct.model.stext.stext.OperationDefinition;
-import org.yakindu.sct.model.stext.stext.VariableDefinition;
-
-@SuppressWarnings("all")
-public class ModelSequencer {
-  @Inject
-  private IQualifiedNameProvider qfnProvider;
-  
-  @Inject
-  private SexecElementMapping mapping;
-  
-  @Inject
-  private StructureMapping structureMapping;
-  
-  @Inject
-  private BehaviorMapping behaviorMapping;
-  
-  @Inject
-  private ReactionBuilder reactBuilder;
-  
-  @Inject
-  private SequenceBuilder seqBuilder;
-  
-  @Inject
-  private StateVectorBuilder svBuilder;
-  
-  /**
-   * ==========================================================================
-   * TRANSFORMATION ROOT
-   */
-  public ExecutionFlow transform(final Statechart sc) {
-    final ExecutionFlow ef = this.mapping.create(sc);
-    this.structureMapping.mapScopes(sc, ef);
-    this.structureMapping.mapRegularStates(sc, ef);
-    this.structureMapping.mapPseudoStates(sc, ef);
-    this.structureMapping.mapRegions(sc, ef);
-    this.structureMapping.mapTimeEvents(sc, ef);
-    this.svBuilder.defineStateVector(ef, sc);
-    this.svBuilder.defineHistoryVector(ef, sc);
-    this.behaviorMapping.mapEntryActions(sc, ef);
-    this.behaviorMapping.mapExitActions(sc, ef);
-    this.seqBuilder.defineStateEnterSequences(ef, sc);
-    this.seqBuilder.defineStateExitSequences(ef, sc);
-    this.seqBuilder.defineDeepEnterSequences(ef, sc);
-    this.seqBuilder.defineShallowEnterSequences(ef, sc);
-    this.seqBuilder.defineStatechartEnterSequence(ef, sc);
-    this.seqBuilder.defineStatechartExitSequence(ef, sc);
-    this.seqBuilder.defineStatechartInitSequence(ef, sc);
-    this.behaviorMapping.mapTransitions(sc, ef);
-    this.behaviorMapping.mapEntries(sc, ef);
-    this.behaviorMapping.mapLocalReactions(sc, ef);
-    this.behaviorMapping.mapChoiceTransitions(sc, ef);
-    this.behaviorMapping.mapSyncTransitions(sc, ef);
-    this.reactBuilder.defineEntryReactions(sc, ef);
-    this.reactBuilder.defineRegularStateReactions(ef, sc);
-    this.reactBuilder.definePseudoStateReactions(ef, sc);
-    this.reactBuilder.defineStatechartReaction(ef, sc);
-    this.retargetDeclRefs(ef);
-    this.mapping.cleanup();
-    return ef;
-  }
-  
-  /**
-   * retarget declaration refs
-   */
-  public void retargetDeclRefs(final ExecutionFlow flow) {
-    final List<EObject> allContent = EcoreUtil2.eAllContentsAsList(flow);
-    final Function1<EObject,Boolean> _function = new Function1<EObject,Boolean>() {
-        public Boolean apply(final EObject e) {
-          boolean _or = false;
-          boolean _or_1 = false;
-          if ((e instanceof EventDefinition)) {
-            _or_1 = true;
-          } else {
-            _or_1 = ((e instanceof EventDefinition) || (e instanceof VariableDefinition));
-          }
-          if (_or_1) {
-            _or = true;
-          } else {
-            _or = (_or_1 || (e instanceof OperationDefinition));
-          }
-          return Boolean.valueOf(_or);
-        }
-      };
-    Iterable<EObject> _filter = IterableExtensions.<EObject>filter(allContent, _function);
-    final Set<EObject> declared = IterableExtensions.<EObject>toSet(_filter);
-    Iterable<ElementReferenceExpression> _filter_1 = Iterables.<ElementReferenceExpression>filter(allContent, ElementReferenceExpression.class);
-    final Procedure1<ElementReferenceExpression> _function_1 = new Procedure1<ElementReferenceExpression>() {
-        public void apply(final ElementReferenceExpression ere) {
-          ModelSequencer.this.retarget(ere, declared);
-        }
-      };
-    IterableExtensions.<ElementReferenceExpression>forEach(_filter_1, _function_1);
-    Iterable<FeatureCall> _filter_2 = Iterables.<FeatureCall>filter(allContent, FeatureCall.class);
-    final Procedure1<FeatureCall> _function_2 = new Procedure1<FeatureCall>() {
-        public void apply(final FeatureCall call) {
-          ModelSequencer.this.retarget(call, declared);
-        }
-      };
-    IterableExtensions.<FeatureCall>forEach(_filter_2, _function_2);
-  }
-  
-  public void retarget(final ElementReferenceExpression ere, final Collection<EObject> declared) {
-    boolean _and = false;
-    EObject _reference = ere.getReference();
-    boolean _notEquals = (!Objects.equal(_reference, null));
-    if (!_notEquals) {
-      _and = false;
-    } else {
-      EObject _reference_1 = ere.getReference();
-      boolean _contains = declared.contains(_reference_1);
-      boolean _not = (!_contains);
-      _and = (_notEquals && _not);
-    }
-    if (_and) {
-      EObject _reference_2 = ere.getReference();
-      final Declaration r = this.replaced(_reference_2);
-      boolean _notEquals_1 = (!Objects.equal(r, null));
-      if (_notEquals_1) {
-        ere.setReference(r);
-      }
-    }
-  }
-  
-  public void retarget(final FeatureCall call, final Collection<EObject> declared) {
-    boolean _and = false;
-    EObject _feature = call.getFeature();
-    boolean _notEquals = (!Objects.equal(_feature, null));
-    if (!_notEquals) {
-      _and = false;
-    } else {
-      EObject _feature_1 = call.getFeature();
-      boolean _contains = declared.contains(_feature_1);
-      boolean _not = (!_contains);
-      _and = (_notEquals && _not);
-    }
-    if (_and) {
-      EObject _feature_2 = call.getFeature();
-      final Declaration r = this.replaced(_feature_2);
-      boolean _notEquals_1 = (!Objects.equal(r, null));
-      if (_notEquals_1) {
-        call.setFeature(((Feature) r));
-      }
-    }
-  }
-  
-  protected Declaration _replaced(final EObject ne) {
-    Declaration _xblockexpression = null;
-    {
-      try {
-        Comparable<? extends Object> _xifexpression = null;
-        boolean _equals = Objects.equal(ne, null);
-        if (_equals) {
-          _xifexpression = "null";
-        } else {
-          QualifiedName _fullyQualifiedName = this.qfnProvider.getFullyQualifiedName(ne);
-          _xifexpression = _fullyQualifiedName;
-        }
-        String _plus = ("Replace with unknown eObject called: " + _xifexpression);
-        InputOutput.<String>println(_plus);
-        Log _log = LogFactory.getLog(ModelSequencer.class);
-        Comparable<? extends Object> _xifexpression_1 = null;
-        boolean _equals_1 = Objects.equal(ne, null);
-        if (_equals_1) {
-          _xifexpression_1 = "null";
-        } else {
-          QualifiedName _fullyQualifiedName_1 = this.qfnProvider.getFullyQualifiedName(ne);
-          _xifexpression_1 = _fullyQualifiedName_1;
-        }
-        String _plus_1 = ("Replace with unknown NamedElement called: " + _xifexpression_1);
-        _log.error(_plus_1);
-      } catch (final Throwable _t) {
-        if (_t instanceof LogConfigurationException) {
-          final LogConfigurationException e = (LogConfigurationException)_t;
-          e.printStackTrace();
-          Comparable<? extends Object> _xifexpression_2 = null;
-          boolean _equals_2 = Objects.equal(ne, null);
-          if (_equals_2) {
-            _xifexpression_2 = "null";
-          } else {
-            QualifiedName _fullyQualifiedName_2 = this.qfnProvider.getFullyQualifiedName(ne);
-            _xifexpression_2 = _fullyQualifiedName_2;
-          }
-          String _plus_2 = ("Replace with unknown NamedElement called: " + _xifexpression_2);
-          InputOutput.<String>println(_plus_2);
-        } else {
-          throw Exceptions.sneakyThrow(_t);
-        }
-      }
-      _xblockexpression = (null);
-    }
-    return _xblockexpression;
-  }
-  
-  protected Declaration _replaced(final VariableDefinition vd) {
-    VariableDefinition _create = this.mapping.create(vd);
-    return _create;
-  }
-  
-  protected Declaration _replaced(final OperationDefinition vd) {
-    OperationDefinition _create = this.mapping.create(vd);
-    return _create;
-  }
-  
-  protected Declaration _replaced(final EventDefinition ed) {
-    EventDefinition _create = this.mapping.create(ed);
-    return _create;
-  }
-  
-  protected Declaration _replaced(final TimeEvent ed) {
-    return ed;
-  }
-  
-  public Declaration replaced(final EObject ed) {
-    if (ed instanceof TimeEvent) {
-      return _replaced((TimeEvent)ed);
-    } else if (ed instanceof EventDefinition) {
-      return _replaced((EventDefinition)ed);
-    } else if (ed instanceof OperationDefinition) {
-      return _replaced((OperationDefinition)ed);
-    } else if (ed instanceof VariableDefinition) {
-      return _replaced((VariableDefinition)ed);
-    } else if (ed != null) {
-      return _replaced(ed);
-    } else {
-      throw new IllegalArgumentException("Unhandled parameter types: " +
-        Arrays.<Object>asList(ed).toString());
-    }
-  }
-}
+package org.yakindu.sct.model.sexec.transformation;
+
+import com.google.common.base.Objects;
+import com.google.common.collect.Iterables;
+import com.google.inject.Inject;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogConfigurationException;
+import org.apache.commons.logging.LogFactory;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.xtext.EcoreUtil2;
+import org.eclipse.xtext.naming.IQualifiedNameProvider;
+import org.eclipse.xtext.naming.QualifiedName;
+import org.eclipse.xtext.xbase.lib.Exceptions;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.InputOutput;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
+import org.yakindu.base.types.Feature;
+import org.yakindu.sct.model.sexec.ExecutionFlow;
+import org.yakindu.sct.model.sexec.TimeEvent;
+import org.yakindu.sct.model.sexec.transformation.BehaviorMapping;
+import org.yakindu.sct.model.sexec.transformation.ReactionBuilder;
+import org.yakindu.sct.model.sexec.transformation.SequenceBuilder;
+import org.yakindu.sct.model.sexec.transformation.SexecElementMapping;
+import org.yakindu.sct.model.sexec.transformation.StateVectorBuilder;
+import org.yakindu.sct.model.sexec.transformation.StructureMapping;
+import org.yakindu.sct.model.sgraph.Declaration;
+import org.yakindu.sct.model.sgraph.Statechart;
+import org.yakindu.sct.model.stext.stext.ElementReferenceExpression;
+import org.yakindu.sct.model.stext.stext.EventDefinition;
+import org.yakindu.sct.model.stext.stext.FeatureCall;
+import org.yakindu.sct.model.stext.stext.OperationDefinition;
+import org.yakindu.sct.model.stext.stext.VariableDefinition;
+
+@SuppressWarnings("all")
+public class ModelSequencer {
+  @Inject
+  private IQualifiedNameProvider qfnProvider;
+  
+  @Inject
+  private SexecElementMapping mapping;
+  
+  @Inject
+  private StructureMapping structureMapping;
+  
+  @Inject
+  private BehaviorMapping behaviorMapping;
+  
+  @Inject
+  private ReactionBuilder reactBuilder;
+  
+  @Inject
+  private SequenceBuilder seqBuilder;
+  
+  @Inject
+  private StateVectorBuilder svBuilder;
+  
+  /**
+   * ==========================================================================
+   * TRANSFORMATION ROOT
+   */
+  public ExecutionFlow transform(final Statechart sc) {
+    final ExecutionFlow ef = this.mapping.create(sc);
+    this.structureMapping.mapScopes(sc, ef);
+    this.structureMapping.mapRegularStates(sc, ef);
+    this.structureMapping.mapPseudoStates(sc, ef);
+    this.structureMapping.mapRegions(sc, ef);
+    this.structureMapping.mapTimeEvents(sc, ef);
+    this.svBuilder.defineStateVector(ef, sc);
+    this.svBuilder.defineHistoryVector(ef, sc);
+    this.behaviorMapping.mapEntryActions(sc, ef);
+    this.behaviorMapping.mapExitActions(sc, ef);
+    this.seqBuilder.defineStateEnterSequences(ef, sc);
+    this.seqBuilder.defineStateExitSequences(ef, sc);
+    this.seqBuilder.defineDeepEnterSequences(ef, sc);
+    this.seqBuilder.defineShallowEnterSequences(ef, sc);
+    this.seqBuilder.defineStatechartEnterSequence(ef, sc);
+    this.seqBuilder.defineStatechartExitSequence(ef, sc);
+    this.seqBuilder.defineStatechartInitSequence(ef, sc);
+    this.behaviorMapping.mapTransitions(sc, ef);
+    this.behaviorMapping.mapEntries(sc, ef);
+    this.behaviorMapping.mapLocalReactions(sc, ef);
+    this.behaviorMapping.mapChoiceTransitions(sc, ef);
+    this.behaviorMapping.mapSyncTransitions(sc, ef);
+    this.reactBuilder.defineEntryReactions(sc, ef);
+    this.reactBuilder.defineRegularStateReactions(ef, sc);
+    this.reactBuilder.definePseudoStateReactions(ef, sc);
+    this.reactBuilder.defineStatechartReaction(ef, sc);
+    this.retargetDeclRefs(ef);
+    this.mapping.cleanup();
+    return ef;
+  }
+  
+  /**
+   * retarget declaration refs
+   */
+  public void retargetDeclRefs(final ExecutionFlow flow) {
+    final List<EObject> allContent = EcoreUtil2.eAllContentsAsList(flow);
+    final Function1<EObject,Boolean> _function = new Function1<EObject,Boolean>() {
+        public Boolean apply(final EObject e) {
+          boolean _or = false;
+          boolean _or_1 = false;
+          if ((e instanceof EventDefinition)) {
+            _or_1 = true;
+          } else {
+            _or_1 = ((e instanceof EventDefinition) || (e instanceof VariableDefinition));
+          }
+          if (_or_1) {
+            _or = true;
+          } else {
+            _or = (_or_1 || (e instanceof OperationDefinition));
+          }
+          return Boolean.valueOf(_or);
+        }
+      };
+    Iterable<EObject> _filter = IterableExtensions.<EObject>filter(allContent, _function);
+    final Set<EObject> declared = IterableExtensions.<EObject>toSet(_filter);
+    Iterable<ElementReferenceExpression> _filter_1 = Iterables.<ElementReferenceExpression>filter(allContent, ElementReferenceExpression.class);
+    final Procedure1<ElementReferenceExpression> _function_1 = new Procedure1<ElementReferenceExpression>() {
+        public void apply(final ElementReferenceExpression ere) {
+          ModelSequencer.this.retarget(ere, declared);
+        }
+      };
+    IterableExtensions.<ElementReferenceExpression>forEach(_filter_1, _function_1);
+    Iterable<FeatureCall> _filter_2 = Iterables.<FeatureCall>filter(allContent, FeatureCall.class);
+    final Procedure1<FeatureCall> _function_2 = new Procedure1<FeatureCall>() {
+        public void apply(final FeatureCall call) {
+          ModelSequencer.this.retarget(call, declared);
+        }
+      };
+    IterableExtensions.<FeatureCall>forEach(_filter_2, _function_2);
+  }
+  
+  public void retarget(final ElementReferenceExpression ere, final Collection<EObject> declared) {
+    boolean _and = false;
+    EObject _reference = ere.getReference();
+    boolean _notEquals = (!Objects.equal(_reference, null));
+    if (!_notEquals) {
+      _and = false;
+    } else {
+      EObject _reference_1 = ere.getReference();
+      boolean _contains = declared.contains(_reference_1);
+      boolean _not = (!_contains);
+      _and = (_notEquals && _not);
+    }
+    if (_and) {
+      EObject _reference_2 = ere.getReference();
+      final Declaration r = this.replaced(_reference_2);
+      boolean _notEquals_1 = (!Objects.equal(r, null));
+      if (_notEquals_1) {
+        ere.setReference(r);
+      }
+    }
+  }
+  
+  public void retarget(final FeatureCall call, final Collection<EObject> declared) {
+    boolean _and = false;
+    EObject _feature = call.getFeature();
+    boolean _notEquals = (!Objects.equal(_feature, null));
+    if (!_notEquals) {
+      _and = false;
+    } else {
+      EObject _feature_1 = call.getFeature();
+      boolean _contains = declared.contains(_feature_1);
+      boolean _not = (!_contains);
+      _and = (_notEquals && _not);
+    }
+    if (_and) {
+      EObject _feature_2 = call.getFeature();
+      final Declaration r = this.replaced(_feature_2);
+      boolean _notEquals_1 = (!Objects.equal(r, null));
+      if (_notEquals_1) {
+        call.setFeature(((Feature) r));
+      }
+    }
+  }
+  
+  protected Declaration _replaced(final EObject ne) {
+    Declaration _xblockexpression = null;
+    {
+      try {
+        Comparable<? extends Object> _xifexpression = null;
+        boolean _equals = Objects.equal(ne, null);
+        if (_equals) {
+          _xifexpression = "null";
+        } else {
+          QualifiedName _fullyQualifiedName = this.qfnProvider.getFullyQualifiedName(ne);
+          _xifexpression = _fullyQualifiedName;
+        }
+        String _plus = ("Replace with unknown eObject called: " + _xifexpression);
+        InputOutput.<String>println(_plus);
+        Log _log = LogFactory.getLog(ModelSequencer.class);
+        Comparable<? extends Object> _xifexpression_1 = null;
+        boolean _equals_1 = Objects.equal(ne, null);
+        if (_equals_1) {
+          _xifexpression_1 = "null";
+        } else {
+          QualifiedName _fullyQualifiedName_1 = this.qfnProvider.getFullyQualifiedName(ne);
+          _xifexpression_1 = _fullyQualifiedName_1;
+        }
+        String _plus_1 = ("Replace with unknown NamedElement called: " + _xifexpression_1);
+        _log.error(_plus_1);
+      } catch (final Throwable _t) {
+        if (_t instanceof LogConfigurationException) {
+          final LogConfigurationException e = (LogConfigurationException)_t;
+          e.printStackTrace();
+          Comparable<? extends Object> _xifexpression_2 = null;
+          boolean _equals_2 = Objects.equal(ne, null);
+          if (_equals_2) {
+            _xifexpression_2 = "null";
+          } else {
+            QualifiedName _fullyQualifiedName_2 = this.qfnProvider.getFullyQualifiedName(ne);
+            _xifexpression_2 = _fullyQualifiedName_2;
+          }
+          String _plus_2 = ("Replace with unknown NamedElement called: " + _xifexpression_2);
+          InputOutput.<String>println(_plus_2);
+        } else {
+          throw Exceptions.sneakyThrow(_t);
+        }
+      }
+      _xblockexpression = (null);
+    }
+    return _xblockexpression;
+  }
+  
+  protected Declaration _replaced(final VariableDefinition vd) {
+    VariableDefinition _create = this.mapping.create(vd);
+    return _create;
+  }
+  
+  protected Declaration _replaced(final OperationDefinition vd) {
+    OperationDefinition _create = this.mapping.create(vd);
+    return _create;
+  }
+  
+  protected Declaration _replaced(final EventDefinition ed) {
+    EventDefinition _create = this.mapping.create(ed);
+    return _create;
+  }
+  
+  protected Declaration _replaced(final TimeEvent ed) {
+    return ed;
+  }
+  
+  public Declaration replaced(final EObject ed) {
+    if (ed instanceof TimeEvent) {
+      return _replaced((TimeEvent)ed);
+    } else if (ed instanceof EventDefinition) {
+      return _replaced((EventDefinition)ed);
+    } else if (ed instanceof OperationDefinition) {
+      return _replaced((OperationDefinition)ed);
+    } else if (ed instanceof VariableDefinition) {
+      return _replaced((VariableDefinition)ed);
+    } else if (ed != null) {
+      return _replaced(ed);
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        Arrays.<Object>asList(ed).toString());
+    }
+  }
+}

File diff suppressed because it is too large
+ 580 - 580
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/ReactionBuilder.java


File diff suppressed because it is too large
+ 1006 - 1006
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/SequenceBuilder.java


File diff suppressed because it is too large
+ 900 - 900
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/SexecElementMapping.java


+ 459 - 459
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/StatechartExtensions.java

@@ -1,459 +1,459 @@
-package org.yakindu.sct.model.sexec.transformation;
-
-import com.google.common.base.Objects;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Iterators;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.common.util.TreeIterator;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.xtext.EcoreUtil2;
-import org.eclipse.xtext.xbase.lib.Functions.Function1;
-import org.eclipse.xtext.xbase.lib.Functions.Function2;
-import org.eclipse.xtext.xbase.lib.IterableExtensions;
-import org.eclipse.xtext.xbase.lib.IteratorExtensions;
-import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
-import org.yakindu.base.base.NamedElement;
-import org.yakindu.sct.model.sgraph.Choice;
-import org.yakindu.sct.model.sgraph.Entry;
-import org.yakindu.sct.model.sgraph.Reaction;
-import org.yakindu.sct.model.sgraph.ReactiveElement;
-import org.yakindu.sct.model.sgraph.Region;
-import org.yakindu.sct.model.sgraph.RegularState;
-import org.yakindu.sct.model.sgraph.Scope;
-import org.yakindu.sct.model.sgraph.State;
-import org.yakindu.sct.model.sgraph.Statechart;
-import org.yakindu.sct.model.sgraph.Synchronization;
-import org.yakindu.sct.model.sgraph.Transition;
-import org.yakindu.sct.model.sgraph.Trigger;
-import org.yakindu.sct.model.sgraph.Vertex;
-import org.yakindu.sct.model.stext.stext.EntryEvent;
-import org.yakindu.sct.model.stext.stext.EventSpec;
-import org.yakindu.sct.model.stext.stext.ExitEvent;
-import org.yakindu.sct.model.stext.stext.LocalReaction;
-import org.yakindu.sct.model.stext.stext.ReactionTrigger;
-import org.yakindu.sct.model.stext.stext.StextFactory;
-import org.yakindu.sct.model.stext.stext.TimeEventSpec;
-
-@SuppressWarnings("all")
-public class StatechartExtensions {
-  /**
-   * calculates the maximum orthogonality (maximum number of possible active leaf states) of the statechart
-   */
-  protected int _maxOrthogonality(final Statechart sc) {
-    EList<Region> _regions = sc.getRegions();
-    final Function2<Integer,Region,Integer> _function = new Function2<Integer,Region,Integer>() {
-        public Integer apply(final Integer o, final Region r) {
-          int _maxOrthogonality = StatechartExtensions.this.maxOrthogonality(r);
-          int _plus = (_maxOrthogonality + (o).intValue());
-          return Integer.valueOf(_plus);
-        }
-      };
-    Integer _fold = IterableExtensions.<Region, Integer>fold(_regions, Integer.valueOf(0), _function);
-    return (_fold).intValue();
-  }
-  
-  /**
-   * calculates the maximum orthogonality (maximum number of possible active leaf states) of a region
-   */
-  protected int _maxOrthogonality(final Region r) {
-    EList<Vertex> _vertices = r.getVertices();
-    final Function2<Integer,Vertex,Integer> _function = new Function2<Integer,Vertex,Integer>() {
-        public Integer apply(final Integer s, final Vertex v) {
-          int _xblockexpression = (int) 0;
-          {
-            final int mo = StatechartExtensions.this.maxOrthogonality(v);
-            int _xifexpression = (int) 0;
-            boolean _greaterThan = (mo > (s).intValue());
-            if (_greaterThan) {
-              _xifexpression = mo;
-            } else {
-              _xifexpression = s;
-            }
-            _xblockexpression = (_xifexpression);
-          }
-          return Integer.valueOf(_xblockexpression);
-        }
-      };
-    Integer _fold = IterableExtensions.<Vertex, Integer>fold(_vertices, Integer.valueOf(0), _function);
-    return (_fold).intValue();
-  }
-  
-  /**
-   * the maximum orthogonality of all  pseudo states is 0
-   */
-  protected int _maxOrthogonality(final Vertex v) {
-    return 0;
-  }
-  
-  /**
-   * calculates the maximum orthogonality (maximum number of possible active leaf states) of a state
-   */
-  protected int _maxOrthogonality(final State s) {
-    Integer _xifexpression = null;
-    EList<Region> _regions = s.getRegions();
-    int _size = _regions.size();
-    boolean _greaterThan = (_size > 0);
-    if (_greaterThan) {
-      EList<Region> _regions_1 = s.getRegions();
-      final Function2<Integer,Region,Integer> _function = new Function2<Integer,Region,Integer>() {
-          public Integer apply(final Integer o, final Region r) {
-            int _maxOrthogonality = StatechartExtensions.this.maxOrthogonality(r);
-            int _plus = (_maxOrthogonality + (o).intValue());
-            return Integer.valueOf(_plus);
-          }
-        };
-      Integer _fold = IterableExtensions.<Region, Integer>fold(_regions_1, Integer.valueOf(0), _function);
-      _xifexpression = _fold;
-    } else {
-      _xifexpression = 1;
-    }
-    return (_xifexpression).intValue();
-  }
-  
-  public Reaction reaction(final Trigger tr) {
-    EObject _eContainer = tr.eContainer();
-    return ((Reaction) _eContainer);
-  }
-  
-  public Statechart statechart(final State state) {
-    Region _parentRegion = state.getParentRegion();
-    Statechart _statechart = this.statechart(_parentRegion);
-    return _statechart;
-  }
-  
-  public Statechart statechart(final Region region) {
-    Statechart _xifexpression = null;
-    EObject _eContainer = region.eContainer();
-    if ((_eContainer instanceof Statechart)) {
-      EObject _eContainer_1 = region.eContainer();
-      _xifexpression = ((Statechart) _eContainer_1);
-    } else {
-      EObject _eContainer_2 = region.eContainer();
-      Statechart _statechart = this.statechart(((State) _eContainer_2));
-      _xifexpression = _statechart;
-    }
-    return _xifexpression;
-  }
-  
-  /**
-   * Provides a list of all TimeEventSpecs that are defined in the context of 'statechart'.
-   */
-  public List<TimeEventSpec> timeEventSpecs(final Statechart state) {
-    ArrayList<TimeEventSpec> _arrayList = new ArrayList<TimeEventSpec>();
-    ArrayList<TimeEventSpec> tesList = _arrayList;
-    EList<Reaction> _localReactions = state.getLocalReactions();
-    final Function2<ArrayList<TimeEventSpec>,Reaction,ArrayList<TimeEventSpec>> _function = new Function2<ArrayList<TimeEventSpec>,Reaction,ArrayList<TimeEventSpec>>() {
-        public ArrayList<TimeEventSpec> apply(final ArrayList<TimeEventSpec> s, final Reaction r) {
-          ArrayList<TimeEventSpec> _xblockexpression = null;
-          {
-            List<EObject> _eAllContentsAsList = EcoreUtil2.eAllContentsAsList(r);
-            Iterable<TimeEventSpec> _filter = Iterables.<TimeEventSpec>filter(_eAllContentsAsList, TimeEventSpec.class);
-            final Procedure1<TimeEventSpec> _function = new Procedure1<TimeEventSpec>() {
-                public void apply(final TimeEventSpec tes) {
-                  s.add(tes);
-                }
-              };
-            IterableExtensions.<TimeEventSpec>forEach(_filter, _function);
-            _xblockexpression = (s);
-          }
-          return _xblockexpression;
-        }
-      };
-    IterableExtensions.<Reaction, ArrayList<TimeEventSpec>>fold(_localReactions, tesList, _function);
-    return tesList;
-  }
-  
-  /**
-   * Provides a list of all TimeEventSpecs that are defined in the context of 'state'.
-   */
-  protected List<TimeEventSpec> _timeEventSpecs(final State state) {
-    ArrayList<TimeEventSpec> _arrayList = new ArrayList<TimeEventSpec>();
-    ArrayList<TimeEventSpec> tesList = _arrayList;
-    EList<Transition> _outgoingTransitions = state.getOutgoingTransitions();
-    final Function2<ArrayList<TimeEventSpec>,Transition,ArrayList<TimeEventSpec>> _function = new Function2<ArrayList<TimeEventSpec>,Transition,ArrayList<TimeEventSpec>>() {
-        public ArrayList<TimeEventSpec> apply(final ArrayList<TimeEventSpec> s, final Transition r) {
-          ArrayList<TimeEventSpec> _xblockexpression = null;
-          {
-            List<EObject> _eAllContentsAsList = EcoreUtil2.eAllContentsAsList(r);
-            Iterable<TimeEventSpec> _filter = Iterables.<TimeEventSpec>filter(_eAllContentsAsList, TimeEventSpec.class);
-            final Procedure1<TimeEventSpec> _function = new Procedure1<TimeEventSpec>() {
-                public void apply(final TimeEventSpec tes) {
-                  s.add(tes);
-                }
-              };
-            IterableExtensions.<TimeEventSpec>forEach(_filter, _function);
-            _xblockexpression = (s);
-          }
-          return _xblockexpression;
-        }
-      };
-    IterableExtensions.<Transition, ArrayList<TimeEventSpec>>fold(_outgoingTransitions, tesList, _function);
-    EList<Reaction> _localReactions = state.getLocalReactions();
-    final Function2<ArrayList<TimeEventSpec>,Reaction,ArrayList<TimeEventSpec>> _function_1 = new Function2<ArrayList<TimeEventSpec>,Reaction,ArrayList<TimeEventSpec>>() {
-        public ArrayList<TimeEventSpec> apply(final ArrayList<TimeEventSpec> s, final Reaction r) {
-          ArrayList<TimeEventSpec> _xblockexpression = null;
-          {
-            List<EObject> _eAllContentsAsList = EcoreUtil2.eAllContentsAsList(r);
-            Iterable<TimeEventSpec> _filter = Iterables.<TimeEventSpec>filter(_eAllContentsAsList, TimeEventSpec.class);
-            final Procedure1<TimeEventSpec> _function = new Procedure1<TimeEventSpec>() {
-                public void apply(final TimeEventSpec tes) {
-                  s.add(tes);
-                }
-              };
-            IterableExtensions.<TimeEventSpec>forEach(_filter, _function);
-            _xblockexpression = (s);
-          }
-          return _xblockexpression;
-        }
-      };
-    IterableExtensions.<Reaction, ArrayList<TimeEventSpec>>fold(_localReactions, tesList, _function_1);
-    return tesList;
-  }
-  
-  /**
-   * Provides a list of all TimeEventSpecs that are defined in the context of 'state'.
-   */
-  protected List<TimeEventSpec> _timeEventSpecs(final Statechart state) {
-    ArrayList<TimeEventSpec> _arrayList = new ArrayList<TimeEventSpec>();
-    ArrayList<TimeEventSpec> tesList = _arrayList;
-    EList<Reaction> _localReactions = state.getLocalReactions();
-    final Function2<ArrayList<TimeEventSpec>,Reaction,ArrayList<TimeEventSpec>> _function = new Function2<ArrayList<TimeEventSpec>,Reaction,ArrayList<TimeEventSpec>>() {
-        public ArrayList<TimeEventSpec> apply(final ArrayList<TimeEventSpec> s, final Reaction r) {
-          ArrayList<TimeEventSpec> _xblockexpression = null;
-          {
-            List<EObject> _eAllContentsAsList = EcoreUtil2.eAllContentsAsList(r);
-            Iterable<TimeEventSpec> _filter = Iterables.<TimeEventSpec>filter(_eAllContentsAsList, TimeEventSpec.class);
-            final Procedure1<TimeEventSpec> _function = new Procedure1<TimeEventSpec>() {
-                public void apply(final TimeEventSpec tes) {
-                  s.add(tes);
-                }
-              };
-            IterableExtensions.<TimeEventSpec>forEach(_filter, _function);
-            _xblockexpression = (s);
-          }
-          return _xblockexpression;
-        }
-      };
-    IterableExtensions.<Reaction, ArrayList<TimeEventSpec>>fold(_localReactions, tesList, _function);
-    return tesList;
-  }
-  
-  protected ReactiveElement _reactiveElement(final Reaction r) {
-    Scope _scope = this.scope(r);
-    ReactiveElement _reactiveElement = this.reactiveElement(_scope);
-    return _reactiveElement;
-  }
-  
-  protected ReactiveElement _reactiveElement(final Transition tr) {
-    State _xifexpression = null;
-    Vertex _source = tr.getSource();
-    if ((_source instanceof State)) {
-      _xifexpression = ((State) tr);
-    } else {
-      _xifexpression = null;
-    }
-    return _xifexpression;
-  }
-  
-  public Scope scope(final Reaction r) {
-    Scope _xifexpression = null;
-    EObject _eContainer = r.eContainer();
-    if ((_eContainer instanceof Scope)) {
-      EObject _eContainer_1 = r.eContainer();
-      _xifexpression = ((Scope) _eContainer_1);
-    }
-    return _xifexpression;
-  }
-  
-  public ReactiveElement reactiveElement(final Scope s) {
-    ReactiveElement _xifexpression = null;
-    EObject _eContainer = s.eContainer();
-    if ((_eContainer instanceof ReactiveElement)) {
-      EObject _eContainer_1 = s.eContainer();
-      _xifexpression = ((ReactiveElement) _eContainer_1);
-    }
-    return _xifexpression;
-  }
-  
-  public List<RegularState> allRegularStates(final Statechart sc) {
-    List<EObject> content = EcoreUtil2.eAllContentsAsList(sc);
-    final Iterable<RegularState> allStates = Iterables.<RegularState>filter(content, RegularState.class);
-    return IterableExtensions.<RegularState>toList(allStates);
-  }
-  
-  public List<Region> allRegions(final Statechart sc) {
-    List<EObject> content = EcoreUtil2.eAllContentsAsList(sc);
-    final Iterable<Region> allRegions = Iterables.<Region>filter(content, Region.class);
-    return IterableExtensions.<Region>toList(allRegions);
-  }
-  
-  public Iterable<Choice> allChoices(final Statechart sc) {
-    List<EObject> content = EcoreUtil2.eAllContentsAsList(sc);
-    final Iterable<Choice> allChoices = Iterables.<Choice>filter(content, Choice.class);
-    return allChoices;
-  }
-  
-  public Iterable<Entry> allEntries(final Statechart sc) {
-    TreeIterator<EObject> _eAllContents = sc.eAllContents();
-    Iterator<Entry> _filter = Iterators.<Entry>filter(_eAllContents, Entry.class);
-    return IteratorExtensions.<Entry>toIterable(_filter);
-  }
-  
-  public Iterable<Synchronization> allSynchronizations(final Statechart sc) {
-    TreeIterator<EObject> _eAllContents = sc.eAllContents();
-    Iterator<Synchronization> _filter = Iterators.<Synchronization>filter(_eAllContents, Synchronization.class);
-    return IteratorExtensions.<Synchronization>toIterable(_filter);
-  }
-  
-  public List<LocalReaction> entryReactions(final ReactiveElement state) {
-    EList<Reaction> _localReactions = state.getLocalReactions();
-    final Function1<Reaction,Boolean> _function = new Function1<Reaction,Boolean>() {
-        public Boolean apply(final Reaction r) {
-          Trigger _trigger = ((LocalReaction) r).getTrigger();
-          EList<EventSpec> _triggers = ((ReactionTrigger) _trigger).getTriggers();
-          final Function1<EventSpec,Boolean> _function = new Function1<EventSpec,Boolean>() {
-              public Boolean apply(final EventSpec t) {
-                return Boolean.valueOf((t instanceof EntryEvent));
-              }
-            };
-          boolean _exists = IterableExtensions.<EventSpec>exists(_triggers, _function);
-          return Boolean.valueOf(_exists);
-        }
-      };
-    Iterable<Reaction> _filter = IterableExtensions.<Reaction>filter(_localReactions, _function);
-    final Function1<Reaction,LocalReaction> _function_1 = new Function1<Reaction,LocalReaction>() {
-        public LocalReaction apply(final Reaction lr) {
-          return ((LocalReaction) lr);
-        }
-      };
-    Iterable<LocalReaction> _map = IterableExtensions.<Reaction, LocalReaction>map(_filter, _function_1);
-    List<LocalReaction> _list = IterableExtensions.<LocalReaction>toList(_map);
-    return _list;
-  }
-  
-  public List<LocalReaction> exitReactions(final ReactiveElement state) {
-    EList<Reaction> _localReactions = state.getLocalReactions();
-    final Function1<Reaction,Boolean> _function = new Function1<Reaction,Boolean>() {
-        public Boolean apply(final Reaction r) {
-          Trigger _trigger = ((LocalReaction) r).getTrigger();
-          EList<EventSpec> _triggers = ((ReactionTrigger) _trigger).getTriggers();
-          final Function1<EventSpec,Boolean> _function = new Function1<EventSpec,Boolean>() {
-              public Boolean apply(final EventSpec t) {
-                return Boolean.valueOf((t instanceof ExitEvent));
-              }
-            };
-          boolean _exists = IterableExtensions.<EventSpec>exists(_triggers, _function);
-          return Boolean.valueOf(_exists);
-        }
-      };
-    Iterable<Reaction> _filter = IterableExtensions.<Reaction>filter(_localReactions, _function);
-    final Function1<Reaction,LocalReaction> _function_1 = new Function1<Reaction,LocalReaction>() {
-        public LocalReaction apply(final Reaction lr) {
-          return ((LocalReaction) lr);
-        }
-      };
-    Iterable<LocalReaction> _map = IterableExtensions.<Reaction, LocalReaction>map(_filter, _function_1);
-    List<LocalReaction> _list = IterableExtensions.<LocalReaction>toList(_map);
-    return _list;
-  }
-  
-  protected String _id(final Object obj) {
-    return null;
-  }
-  
-  /**
-   * The id of a transition is unique within the context of its source vertex.
-   */
-  protected String _id(final Transition t) {
-    Object _xifexpression = null;
-    Vertex _source = t.getSource();
-    boolean _notEquals = (!Objects.equal(_source, null));
-    if (_notEquals) {
-      Vertex _source_1 = t.getSource();
-      EList<Transition> _outgoingTransitions = _source_1.getOutgoingTransitions();
-      int _indexOf = _outgoingTransitions.indexOf(t);
-      _xifexpression = _indexOf;
-    } else {
-      _xifexpression = "";
-    }
-    String _plus = ("tr" + ((Comparable<Object>)_xifexpression));
-    return _plus;
-  }
-  
-  /**
-   * The id of a local reaction is unique within the context of its source vertex.
-   */
-  protected String _id(final LocalReaction t) {
-    Object _xifexpression = null;
-    ReactiveElement _reactiveElement = this.reactiveElement(t);
-    boolean _notEquals = (!Objects.equal(_reactiveElement, null));
-    if (_notEquals) {
-      ReactiveElement _reactiveElement_1 = this.reactiveElement(t);
-      EList<Reaction> _localReactions = _reactiveElement_1.getLocalReactions();
-      int _indexOf = _localReactions.indexOf(t);
-      _xifexpression = _indexOf;
-    } else {
-      _xifexpression = "";
-    }
-    String _plus = ("lr" + ((Comparable<Object>)_xifexpression));
-    return _plus;
-  }
-  
-  public StextFactory stextFactory() {
-    return StextFactory.eINSTANCE;
-  }
-  
-  public int maxOrthogonality(final NamedElement s) {
-    if (s instanceof State) {
-      return _maxOrthogonality((State)s);
-    } else if (s instanceof Region) {
-      return _maxOrthogonality((Region)s);
-    } else if (s instanceof Statechart) {
-      return _maxOrthogonality((Statechart)s);
-    } else if (s instanceof Vertex) {
-      return _maxOrthogonality((Vertex)s);
-    } else {
-      throw new IllegalArgumentException("Unhandled parameter types: " +
-        Arrays.<Object>asList(s).toString());
-    }
-  }
-  
-  public List<TimeEventSpec> timeEventSpecs(final EObject state) {
-    if (state instanceof State) {
-      return _timeEventSpecs((State)state);
-    } else if (state instanceof Statechart) {
-      return _timeEventSpecs((Statechart)state);
-    } else {
-      throw new IllegalArgumentException("Unhandled parameter types: " +
-        Arrays.<Object>asList(state).toString());
-    }
-  }
-  
-  public ReactiveElement reactiveElement(final Reaction tr) {
-    if (tr instanceof Transition) {
-      return _reactiveElement((Transition)tr);
-    } else if (tr != null) {
-      return _reactiveElement(tr);
-    } else {
-      throw new IllegalArgumentException("Unhandled parameter types: " +
-        Arrays.<Object>asList(tr).toString());
-    }
-  }
-  
-  public String id(final Object t) {
-    if (t instanceof LocalReaction) {
-      return _id((LocalReaction)t);
-    } else if (t instanceof Transition) {
-      return _id((Transition)t);
-    } else if (t != null) {
-      return _id(t);
-    } else {
-      throw new IllegalArgumentException("Unhandled parameter types: " +
-        Arrays.<Object>asList(t).toString());
-    }
-  }
-}
+package org.yakindu.sct.model.sexec.transformation;
+
+import com.google.common.base.Objects;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Iterators;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.TreeIterator;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.xtext.EcoreUtil2;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.Functions.Function2;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.IteratorExtensions;
+import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
+import org.yakindu.base.base.NamedElement;
+import org.yakindu.sct.model.sgraph.Choice;
+import org.yakindu.sct.model.sgraph.Entry;
+import org.yakindu.sct.model.sgraph.Reaction;
+import org.yakindu.sct.model.sgraph.ReactiveElement;
+import org.yakindu.sct.model.sgraph.Region;
+import org.yakindu.sct.model.sgraph.RegularState;
+import org.yakindu.sct.model.sgraph.Scope;
+import org.yakindu.sct.model.sgraph.State;
+import org.yakindu.sct.model.sgraph.Statechart;
+import org.yakindu.sct.model.sgraph.Synchronization;
+import org.yakindu.sct.model.sgraph.Transition;
+import org.yakindu.sct.model.sgraph.Trigger;
+import org.yakindu.sct.model.sgraph.Vertex;
+import org.yakindu.sct.model.stext.stext.EntryEvent;
+import org.yakindu.sct.model.stext.stext.EventSpec;
+import org.yakindu.sct.model.stext.stext.ExitEvent;
+import org.yakindu.sct.model.stext.stext.LocalReaction;
+import org.yakindu.sct.model.stext.stext.ReactionTrigger;
+import org.yakindu.sct.model.stext.stext.StextFactory;
+import org.yakindu.sct.model.stext.stext.TimeEventSpec;
+
+@SuppressWarnings("all")
+public class StatechartExtensions {
+  /**
+   * calculates the maximum orthogonality (maximum number of possible active leaf states) of the statechart
+   */
+  protected int _maxOrthogonality(final Statechart sc) {
+    EList<Region> _regions = sc.getRegions();
+    final Function2<Integer,Region,Integer> _function = new Function2<Integer,Region,Integer>() {
+        public Integer apply(final Integer o, final Region r) {
+          int _maxOrthogonality = StatechartExtensions.this.maxOrthogonality(r);
+          int _plus = (_maxOrthogonality + (o).intValue());
+          return Integer.valueOf(_plus);
+        }
+      };
+    Integer _fold = IterableExtensions.<Region, Integer>fold(_regions, Integer.valueOf(0), _function);
+    return (_fold).intValue();
+  }
+  
+  /**
+   * calculates the maximum orthogonality (maximum number of possible active leaf states) of a region
+   */
+  protected int _maxOrthogonality(final Region r) {
+    EList<Vertex> _vertices = r.getVertices();
+    final Function2<Integer,Vertex,Integer> _function = new Function2<Integer,Vertex,Integer>() {
+        public Integer apply(final Integer s, final Vertex v) {
+          int _xblockexpression = (int) 0;
+          {
+            final int mo = StatechartExtensions.this.maxOrthogonality(v);
+            int _xifexpression = (int) 0;
+            boolean _greaterThan = (mo > (s).intValue());
+            if (_greaterThan) {
+              _xifexpression = mo;
+            } else {
+              _xifexpression = s;
+            }
+            _xblockexpression = (_xifexpression);
+          }
+          return Integer.valueOf(_xblockexpression);
+        }
+      };
+    Integer _fold = IterableExtensions.<Vertex, Integer>fold(_vertices, Integer.valueOf(0), _function);
+    return (_fold).intValue();
+  }
+  
+  /**
+   * the maximum orthogonality of all  pseudo states is 0
+   */
+  protected int _maxOrthogonality(final Vertex v) {
+    return 0;
+  }
+  
+  /**
+   * calculates the maximum orthogonality (maximum number of possible active leaf states) of a state
+   */
+  protected int _maxOrthogonality(final State s) {
+    Integer _xifexpression = null;
+    EList<Region> _regions = s.getRegions();
+    int _size = _regions.size();
+    boolean _greaterThan = (_size > 0);
+    if (_greaterThan) {
+      EList<Region> _regions_1 = s.getRegions();
+      final Function2<Integer,Region,Integer> _function = new Function2<Integer,Region,Integer>() {
+          public Integer apply(final Integer o, final Region r) {
+            int _maxOrthogonality = StatechartExtensions.this.maxOrthogonality(r);
+            int _plus = (_maxOrthogonality + (o).intValue());
+            return Integer.valueOf(_plus);
+          }
+        };
+      Integer _fold = IterableExtensions.<Region, Integer>fold(_regions_1, Integer.valueOf(0), _function);
+      _xifexpression = _fold;
+    } else {
+      _xifexpression = 1;
+    }
+    return (_xifexpression).intValue();
+  }
+  
+  public Reaction reaction(final Trigger tr) {
+    EObject _eContainer = tr.eContainer();
+    return ((Reaction) _eContainer);
+  }
+  
+  public Statechart statechart(final State state) {
+    Region _parentRegion = state.getParentRegion();
+    Statechart _statechart = this.statechart(_parentRegion);
+    return _statechart;
+  }
+  
+  public Statechart statechart(final Region region) {
+    Statechart _xifexpression = null;
+    EObject _eContainer = region.eContainer();
+    if ((_eContainer instanceof Statechart)) {
+      EObject _eContainer_1 = region.eContainer();
+      _xifexpression = ((Statechart) _eContainer_1);
+    } else {
+      EObject _eContainer_2 = region.eContainer();
+      Statechart _statechart = this.statechart(((State) _eContainer_2));
+      _xifexpression = _statechart;
+    }
+    return _xifexpression;
+  }
+  
+  /**
+   * Provides a list of all TimeEventSpecs that are defined in the context of 'statechart'.
+   */
+  public List<TimeEventSpec> timeEventSpecs(final Statechart state) {
+    ArrayList<TimeEventSpec> _arrayList = new ArrayList<TimeEventSpec>();
+    ArrayList<TimeEventSpec> tesList = _arrayList;
+    EList<Reaction> _localReactions = state.getLocalReactions();
+    final Function2<ArrayList<TimeEventSpec>,Reaction,ArrayList<TimeEventSpec>> _function = new Function2<ArrayList<TimeEventSpec>,Reaction,ArrayList<TimeEventSpec>>() {
+        public ArrayList<TimeEventSpec> apply(final ArrayList<TimeEventSpec> s, final Reaction r) {
+          ArrayList<TimeEventSpec> _xblockexpression = null;
+          {
+            List<EObject> _eAllContentsAsList = EcoreUtil2.eAllContentsAsList(r);
+            Iterable<TimeEventSpec> _filter = Iterables.<TimeEventSpec>filter(_eAllContentsAsList, TimeEventSpec.class);
+            final Procedure1<TimeEventSpec> _function = new Procedure1<TimeEventSpec>() {
+                public void apply(final TimeEventSpec tes) {
+                  s.add(tes);
+                }
+              };
+            IterableExtensions.<TimeEventSpec>forEach(_filter, _function);
+            _xblockexpression = (s);
+          }
+          return _xblockexpression;
+        }
+      };
+    IterableExtensions.<Reaction, ArrayList<TimeEventSpec>>fold(_localReactions, tesList, _function);
+    return tesList;
+  }
+  
+  /**
+   * Provides a list of all TimeEventSpecs that are defined in the context of 'state'.
+   */
+  protected List<TimeEventSpec> _timeEventSpecs(final State state) {
+    ArrayList<TimeEventSpec> _arrayList = new ArrayList<TimeEventSpec>();
+    ArrayList<TimeEventSpec> tesList = _arrayList;
+    EList<Transition> _outgoingTransitions = state.getOutgoingTransitions();
+    final Function2<ArrayList<TimeEventSpec>,Transition,ArrayList<TimeEventSpec>> _function = new Function2<ArrayList<TimeEventSpec>,Transition,ArrayList<TimeEventSpec>>() {
+        public ArrayList<TimeEventSpec> apply(final ArrayList<TimeEventSpec> s, final Transition r) {
+          ArrayList<TimeEventSpec> _xblockexpression = null;
+          {
+            List<EObject> _eAllContentsAsList = EcoreUtil2.eAllContentsAsList(r);
+            Iterable<TimeEventSpec> _filter = Iterables.<TimeEventSpec>filter(_eAllContentsAsList, TimeEventSpec.class);
+            final Procedure1<TimeEventSpec> _function = new Procedure1<TimeEventSpec>() {
+                public void apply(final TimeEventSpec tes) {
+                  s.add(tes);
+                }
+              };
+            IterableExtensions.<TimeEventSpec>forEach(_filter, _function);
+            _xblockexpression = (s);
+          }
+          return _xblockexpression;
+        }
+      };
+    IterableExtensions.<Transition, ArrayList<TimeEventSpec>>fold(_outgoingTransitions, tesList, _function);
+    EList<Reaction> _localReactions = state.getLocalReactions();
+    final Function2<ArrayList<TimeEventSpec>,Reaction,ArrayList<TimeEventSpec>> _function_1 = new Function2<ArrayList<TimeEventSpec>,Reaction,ArrayList<TimeEventSpec>>() {
+        public ArrayList<TimeEventSpec> apply(final ArrayList<TimeEventSpec> s, final Reaction r) {
+          ArrayList<TimeEventSpec> _xblockexpression = null;
+          {
+            List<EObject> _eAllContentsAsList = EcoreUtil2.eAllContentsAsList(r);
+            Iterable<TimeEventSpec> _filter = Iterables.<TimeEventSpec>filter(_eAllContentsAsList, TimeEventSpec.class);
+            final Procedure1<TimeEventSpec> _function = new Procedure1<TimeEventSpec>() {
+                public void apply(final TimeEventSpec tes) {
+                  s.add(tes);
+                }
+              };
+            IterableExtensions.<TimeEventSpec>forEach(_filter, _function);
+            _xblockexpression = (s);
+          }
+          return _xblockexpression;
+        }
+      };
+    IterableExtensions.<Reaction, ArrayList<TimeEventSpec>>fold(_localReactions, tesList, _function_1);
+    return tesList;
+  }
+  
+  /**
+   * Provides a list of all TimeEventSpecs that are defined in the context of 'state'.
+   */
+  protected List<TimeEventSpec> _timeEventSpecs(final Statechart state) {
+    ArrayList<TimeEventSpec> _arrayList = new ArrayList<TimeEventSpec>();
+    ArrayList<TimeEventSpec> tesList = _arrayList;
+    EList<Reaction> _localReactions = state.getLocalReactions();
+    final Function2<ArrayList<TimeEventSpec>,Reaction,ArrayList<TimeEventSpec>> _function = new Function2<ArrayList<TimeEventSpec>,Reaction,ArrayList<TimeEventSpec>>() {
+        public ArrayList<TimeEventSpec> apply(final ArrayList<TimeEventSpec> s, final Reaction r) {
+          ArrayList<TimeEventSpec> _xblockexpression = null;
+          {
+            List<EObject> _eAllContentsAsList = EcoreUtil2.eAllContentsAsList(r);
+            Iterable<TimeEventSpec> _filter = Iterables.<TimeEventSpec>filter(_eAllContentsAsList, TimeEventSpec.class);
+            final Procedure1<TimeEventSpec> _function = new Procedure1<TimeEventSpec>() {
+                public void apply(final TimeEventSpec tes) {
+                  s.add(tes);
+                }
+              };
+            IterableExtensions.<TimeEventSpec>forEach(_filter, _function);
+            _xblockexpression = (s);
+          }
+          return _xblockexpression;
+        }
+      };
+    IterableExtensions.<Reaction, ArrayList<TimeEventSpec>>fold(_localReactions, tesList, _function);
+    return tesList;
+  }
+  
+  protected ReactiveElement _reactiveElement(final Reaction r) {
+    Scope _scope = this.scope(r);
+    ReactiveElement _reactiveElement = this.reactiveElement(_scope);
+    return _reactiveElement;
+  }
+  
+  protected ReactiveElement _reactiveElement(final Transition tr) {
+    State _xifexpression = null;
+    Vertex _source = tr.getSource();
+    if ((_source instanceof State)) {
+      _xifexpression = ((State) tr);
+    } else {
+      _xifexpression = null;
+    }
+    return _xifexpression;
+  }
+  
+  public Scope scope(final Reaction r) {
+    Scope _xifexpression = null;
+    EObject _eContainer = r.eContainer();
+    if ((_eContainer instanceof Scope)) {
+      EObject _eContainer_1 = r.eContainer();
+      _xifexpression = ((Scope) _eContainer_1);
+    }
+    return _xifexpression;
+  }
+  
+  public ReactiveElement reactiveElement(final Scope s) {
+    ReactiveElement _xifexpression = null;
+    EObject _eContainer = s.eContainer();
+    if ((_eContainer instanceof ReactiveElement)) {
+      EObject _eContainer_1 = s.eContainer();
+      _xifexpression = ((ReactiveElement) _eContainer_1);
+    }
+    return _xifexpression;
+  }
+  
+  public List<RegularState> allRegularStates(final Statechart sc) {
+    List<EObject> content = EcoreUtil2.eAllContentsAsList(sc);
+    final Iterable<RegularState> allStates = Iterables.<RegularState>filter(content, RegularState.class);
+    return IterableExtensions.<RegularState>toList(allStates);
+  }
+  
+  public List<Region> allRegions(final Statechart sc) {
+    List<EObject> content = EcoreUtil2.eAllContentsAsList(sc);
+    final Iterable<Region> allRegions = Iterables.<Region>filter(content, Region.class);
+    return IterableExtensions.<Region>toList(allRegions);
+  }
+  
+  public Iterable<Choice> allChoices(final Statechart sc) {
+    List<EObject> content = EcoreUtil2.eAllContentsAsList(sc);
+    final Iterable<Choice> allChoices = Iterables.<Choice>filter(content, Choice.class);
+    return allChoices;
+  }
+  
+  public Iterable<Entry> allEntries(final Statechart sc) {
+    TreeIterator<EObject> _eAllContents = sc.eAllContents();
+    Iterator<Entry> _filter = Iterators.<Entry>filter(_eAllContents, Entry.class);
+    return IteratorExtensions.<Entry>toIterable(_filter);
+  }
+  
+  public Iterable<Synchronization> allSynchronizations(final Statechart sc) {
+    TreeIterator<EObject> _eAllContents = sc.eAllContents();
+    Iterator<Synchronization> _filter = Iterators.<Synchronization>filter(_eAllContents, Synchronization.class);
+    return IteratorExtensions.<Synchronization>toIterable(_filter);
+  }
+  
+  public List<LocalReaction> entryReactions(final ReactiveElement state) {
+    EList<Reaction> _localReactions = state.getLocalReactions();
+    final Function1<Reaction,Boolean> _function = new Function1<Reaction,Boolean>() {
+        public Boolean apply(final Reaction r) {
+          Trigger _trigger = ((LocalReaction) r).getTrigger();
+          EList<EventSpec> _triggers = ((ReactionTrigger) _trigger).getTriggers();
+          final Function1<EventSpec,Boolean> _function = new Function1<EventSpec,Boolean>() {
+              public Boolean apply(final EventSpec t) {
+                return Boolean.valueOf((t instanceof EntryEvent));
+              }
+            };
+          boolean _exists = IterableExtensions.<EventSpec>exists(_triggers, _function);
+          return Boolean.valueOf(_exists);
+        }
+      };
+    Iterable<Reaction> _filter = IterableExtensions.<Reaction>filter(_localReactions, _function);
+    final Function1<Reaction,LocalReaction> _function_1 = new Function1<Reaction,LocalReaction>() {
+        public LocalReaction apply(final Reaction lr) {
+          return ((LocalReaction) lr);
+        }
+      };
+    Iterable<LocalReaction> _map = IterableExtensions.<Reaction, LocalReaction>map(_filter, _function_1);
+    List<LocalReaction> _list = IterableExtensions.<LocalReaction>toList(_map);
+    return _list;
+  }
+  
+  public List<LocalReaction> exitReactions(final ReactiveElement state) {
+    EList<Reaction> _localReactions = state.getLocalReactions();
+    final Function1<Reaction,Boolean> _function = new Function1<Reaction,Boolean>() {
+        public Boolean apply(final Reaction r) {
+          Trigger _trigger = ((LocalReaction) r).getTrigger();
+          EList<EventSpec> _triggers = ((ReactionTrigger) _trigger).getTriggers();
+          final Function1<EventSpec,Boolean> _function = new Function1<EventSpec,Boolean>() {
+              public Boolean apply(final EventSpec t) {
+                return Boolean.valueOf((t instanceof ExitEvent));
+              }
+            };
+          boolean _exists = IterableExtensions.<EventSpec>exists(_triggers, _function);
+          return Boolean.valueOf(_exists);
+        }
+      };
+    Iterable<Reaction> _filter = IterableExtensions.<Reaction>filter(_localReactions, _function);
+    final Function1<Reaction,LocalReaction> _function_1 = new Function1<Reaction,LocalReaction>() {
+        public LocalReaction apply(final Reaction lr) {
+          return ((LocalReaction) lr);
+        }
+      };
+    Iterable<LocalReaction> _map = IterableExtensions.<Reaction, LocalReaction>map(_filter, _function_1);
+    List<LocalReaction> _list = IterableExtensions.<LocalReaction>toList(_map);
+    return _list;
+  }
+  
+  protected String _id(final Object obj) {
+    return null;
+  }
+  
+  /**
+   * The id of a transition is unique within the context of its source vertex.
+   */
+  protected String _id(final Transition t) {
+    Object _xifexpression = null;
+    Vertex _source = t.getSource();
+    boolean _notEquals = (!Objects.equal(_source, null));
+    if (_notEquals) {
+      Vertex _source_1 = t.getSource();
+      EList<Transition> _outgoingTransitions = _source_1.getOutgoingTransitions();
+      int _indexOf = _outgoingTransitions.indexOf(t);
+      _xifexpression = _indexOf;
+    } else {
+      _xifexpression = "";
+    }
+    String _plus = ("tr" + ((Comparable<Object>)_xifexpression));
+    return _plus;
+  }
+  
+  /**
+   * The id of a local reaction is unique within the context of its source vertex.
+   */
+  protected String _id(final LocalReaction t) {
+    Object _xifexpression = null;
+    ReactiveElement _reactiveElement = this.reactiveElement(t);
+    boolean _notEquals = (!Objects.equal(_reactiveElement, null));
+    if (_notEquals) {
+      ReactiveElement _reactiveElement_1 = this.reactiveElement(t);
+      EList<Reaction> _localReactions = _reactiveElement_1.getLocalReactions();
+      int _indexOf = _localReactions.indexOf(t);
+      _xifexpression = _indexOf;
+    } else {
+      _xifexpression = "";
+    }
+    String _plus = ("lr" + ((Comparable<Object>)_xifexpression));
+    return _plus;
+  }
+  
+  public StextFactory stextFactory() {
+    return StextFactory.eINSTANCE;
+  }
+  
+  public int maxOrthogonality(final NamedElement s) {
+    if (s instanceof State) {
+      return _maxOrthogonality((State)s);
+    } else if (s instanceof Region) {
+      return _maxOrthogonality((Region)s);
+    } else if (s instanceof Statechart) {
+      return _maxOrthogonality((Statechart)s);
+    } else if (s instanceof Vertex) {
+      return _maxOrthogonality((Vertex)s);
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        Arrays.<Object>asList(s).toString());
+    }
+  }
+  
+  public List<TimeEventSpec> timeEventSpecs(final EObject state) {
+    if (state instanceof State) {
+      return _timeEventSpecs((State)state);
+    } else if (state instanceof Statechart) {
+      return _timeEventSpecs((Statechart)state);
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        Arrays.<Object>asList(state).toString());
+    }
+  }
+  
+  public ReactiveElement reactiveElement(final Reaction tr) {
+    if (tr instanceof Transition) {
+      return _reactiveElement((Transition)tr);
+    } else if (tr != null) {
+      return _reactiveElement(tr);
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        Arrays.<Object>asList(tr).toString());
+    }
+  }
+  
+  public String id(final Object t) {
+    if (t instanceof LocalReaction) {
+      return _id((LocalReaction)t);
+    } else if (t instanceof Transition) {
+      return _id((Transition)t);
+    } else if (t != null) {
+      return _id(t);
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        Arrays.<Object>asList(t).toString());
+    }
+  }
+}

+ 53 - 53
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/StextExtensions.java

@@ -1,53 +1,53 @@
-package org.yakindu.sct.model.sexec.transformation;
-
-import org.yakindu.sct.model.sgraph.State;
-import org.yakindu.sct.model.stext.stext.ActiveStateReferenceExpression;
-import org.yakindu.sct.model.stext.stext.Expression;
-import org.yakindu.sct.model.stext.stext.LogicalAndExpression;
-import org.yakindu.sct.model.stext.stext.LogicalOrExpression;
-import org.yakindu.sct.model.stext.stext.StextFactory;
-
-/**
- * @author Axel Terfloth added 'active' extension
- */
-@SuppressWarnings("all")
-public class StextExtensions {
-  public StextFactory factory() {
-    return StextFactory.eINSTANCE;
-  }
-  
-  public Expression or(final Expression left, final Expression right) {
-    LogicalOrExpression _xblockexpression = null;
-    {
-      StextFactory _factory = this.factory();
-      final LogicalOrExpression or = _factory.createLogicalOrExpression();
-      or.setLeftOperand(left);
-      or.setRightOperand(right);
-      _xblockexpression = (or);
-    }
-    return _xblockexpression;
-  }
-  
-  public Expression and(final Expression left, final Expression right) {
-    LogicalAndExpression _xblockexpression = null;
-    {
-      StextFactory _factory = this.factory();
-      final LogicalAndExpression and = _factory.createLogicalAndExpression();
-      and.setLeftOperand(left);
-      and.setRightOperand(right);
-      _xblockexpression = (and);
-    }
-    return _xblockexpression;
-  }
-  
-  public Expression active(final State state) {
-    ActiveStateReferenceExpression _xblockexpression = null;
-    {
-      StextFactory _factory = this.factory();
-      final ActiveStateReferenceExpression active = _factory.createActiveStateReferenceExpression();
-      active.setValue(state);
-      _xblockexpression = (active);
-    }
-    return _xblockexpression;
-  }
-}
+package org.yakindu.sct.model.sexec.transformation;
+
+import org.yakindu.sct.model.sgraph.State;
+import org.yakindu.sct.model.stext.stext.ActiveStateReferenceExpression;
+import org.yakindu.sct.model.stext.stext.Expression;
+import org.yakindu.sct.model.stext.stext.LogicalAndExpression;
+import org.yakindu.sct.model.stext.stext.LogicalOrExpression;
+import org.yakindu.sct.model.stext.stext.StextFactory;
+
+/**
+ * @author Axel Terfloth added 'active' extension
+ */
+@SuppressWarnings("all")
+public class StextExtensions {
+  public StextFactory factory() {
+    return StextFactory.eINSTANCE;
+  }
+  
+  public Expression or(final Expression left, final Expression right) {
+    LogicalOrExpression _xblockexpression = null;
+    {
+      StextFactory _factory = this.factory();
+      final LogicalOrExpression or = _factory.createLogicalOrExpression();
+      or.setLeftOperand(left);
+      or.setRightOperand(right);
+      _xblockexpression = (or);
+    }
+    return _xblockexpression;
+  }
+  
+  public Expression and(final Expression left, final Expression right) {
+    LogicalAndExpression _xblockexpression = null;
+    {
+      StextFactory _factory = this.factory();
+      final LogicalAndExpression and = _factory.createLogicalAndExpression();
+      and.setLeftOperand(left);
+      and.setRightOperand(right);
+      _xblockexpression = (and);
+    }
+    return _xblockexpression;
+  }
+  
+  public Expression active(final State state) {
+    ActiveStateReferenceExpression _xblockexpression = null;
+    {
+      StextFactory _factory = this.factory();
+      final ActiveStateReferenceExpression active = _factory.createActiveStateReferenceExpression();
+      active.setValue(state);
+      _xblockexpression = (active);
+    }
+    return _xblockexpression;
+  }
+}

+ 334 - 334
plugins/org.yakindu.sct.model.sexec/xtend-gen/org/yakindu/sct/model/sexec/transformation/StructureMapping.java

@@ -1,334 +1,334 @@
-package org.yakindu.sct.model.sexec.transformation;
-
-import com.google.common.base.Objects;
-import com.google.common.collect.Iterables;
-import com.google.inject.Inject;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.xtext.EcoreUtil2;
-import org.eclipse.xtext.naming.IQualifiedNameProvider;
-import org.eclipse.xtext.naming.QualifiedName;
-import org.eclipse.xtext.xbase.lib.Functions.Function1;
-import org.eclipse.xtext.xbase.lib.IterableExtensions;
-import org.eclipse.xtext.xbase.lib.ListExtensions;
-import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
-import org.yakindu.sct.model.sexec.ExecutionChoice;
-import org.yakindu.sct.model.sexec.ExecutionEntry;
-import org.yakindu.sct.model.sexec.ExecutionFlow;
-import org.yakindu.sct.model.sexec.ExecutionNode;
-import org.yakindu.sct.model.sexec.ExecutionRegion;
-import org.yakindu.sct.model.sexec.ExecutionScope;
-import org.yakindu.sct.model.sexec.ExecutionState;
-import org.yakindu.sct.model.sexec.ExecutionSynchronization;
-import org.yakindu.sct.model.sexec.TimeEvent;
-import org.yakindu.sct.model.sexec.transformation.SexecElementMapping;
-import org.yakindu.sct.model.sexec.transformation.StatechartExtensions;
-import org.yakindu.sct.model.sgraph.Choice;
-import org.yakindu.sct.model.sgraph.CompositeElement;
-import org.yakindu.sct.model.sgraph.Declaration;
-import org.yakindu.sct.model.sgraph.Entry;
-import org.yakindu.sct.model.sgraph.FinalState;
-import org.yakindu.sct.model.sgraph.Region;
-import org.yakindu.sct.model.sgraph.RegularState;
-import org.yakindu.sct.model.sgraph.Scope;
-import org.yakindu.sct.model.sgraph.State;
-import org.yakindu.sct.model.sgraph.Statechart;
-import org.yakindu.sct.model.sgraph.Synchronization;
-import org.yakindu.sct.model.sgraph.Vertex;
-import org.yakindu.sct.model.stext.stext.EventDefinition;
-import org.yakindu.sct.model.stext.stext.OperationDefinition;
-import org.yakindu.sct.model.stext.stext.TimeEventSpec;
-import org.yakindu.sct.model.stext.stext.VariableDefinition;
-
-@SuppressWarnings("all")
-public class StructureMapping {
-  @Inject
-  private SexecElementMapping mapping;
-  
-  @Inject
-  private StatechartExtensions sct;
-  
-  @Inject
-  private IQualifiedNameProvider _iQualifiedNameProvider;
-  
-  /**
-   * maps all required scope defined in the statechart to the execution flow.
-   * This includes creating the scopes and adding all relevant declarations. Empty scopes wont be mapped.
-   */
-  public ExecutionFlow mapScopes(final Statechart sc, final ExecutionFlow flow) {
-    ExecutionFlow _xblockexpression = null;
-    {
-      EList<Scope> _scopes = flow.getScopes();
-      EList<Scope> _scopes_1 = sc.getScopes();
-      final Function1<Scope,Scope> _function = new Function1<Scope,Scope>() {
-          public Scope apply(final Scope scope) {
-            Scope _map = StructureMapping.this.map(scope);
-            return _map;
-          }
-        };
-      List<Scope> _map = ListExtensions.<Scope, Scope>map(_scopes_1, _function);
-      _scopes.addAll(_map);
-      _xblockexpression = (flow);
-    }
-    return _xblockexpression;
-  }
-  
-  public Scope map(final Scope scope) {
-    final Scope _scope = this.mapping.createScope(scope);
-    EList<Declaration> _declarations = _scope.getDeclarations();
-    EList<Declaration> _declarations_1 = scope.getDeclarations();
-    final Function1<Declaration,Declaration> _function = new Function1<Declaration,Declaration>() {
-        public Declaration apply(final Declaration decl) {
-          Declaration _map = StructureMapping.this.map(decl);
-          return _map;
-        }
-      };
-    List<Declaration> _map = ListExtensions.<Declaration, Declaration>map(_declarations_1, _function);
-    final Function1<Declaration,Boolean> _function_1 = new Function1<Declaration,Boolean>() {
-        public Boolean apply(final Declaration e) {
-          boolean _notEquals = (!Objects.equal(e, null));
-          return Boolean.valueOf(_notEquals);
-        }
-      };
-    Iterable<Declaration> _filter = IterableExtensions.<Declaration>filter(_map, _function_1);
-    Iterables.<Declaration>addAll(_declarations, _filter);
-    return _scope;
-  }
-  
-  protected Declaration _map(final Declaration decl) {
-    return null;
-  }
-  
-  protected Declaration _map(final EventDefinition e) {
-    final EventDefinition _e = this.mapping.create(e);
-    return _e;
-  }
-  
-  protected Declaration _map(final VariableDefinition v) {
-    final VariableDefinition _v = this.mapping.create(v);
-    return _v;
-  }
-  
-  protected Declaration _map(final OperationDefinition v) {
-    final OperationDefinition _v = this.mapping.create(v);
-    return _v;
-  }
-  
-  public ExecutionFlow mapRegularStates(final Statechart statechart, final ExecutionFlow r) {
-    final List<RegularState> allStates = this.sct.allRegularStates(statechart);
-    EList<ExecutionState> _states = r.getStates();
-    final Function1<RegularState,ExecutionState> _function = new Function1<RegularState,ExecutionState>() {
-        public ExecutionState apply(final RegularState s) {
-          ExecutionState _mapState = StructureMapping.this.mapState(s);
-          return _mapState;
-        }
-      };
-    List<ExecutionState> _map = ListExtensions.<RegularState, ExecutionState>map(allStates, _function);
-    _states.addAll(_map);
-    return r;
-  }
-  
-  protected ExecutionState _mapState(final FinalState state) {
-    final ExecutionState _state = this.mapping.create(state);
-    _state.setLeaf(true);
-    _state.setEntryAction(null);
-    _state.setExitAction(null);
-    return _state;
-  }
-  
-  protected ExecutionState _mapState(final State state) {
-    final ExecutionState _state = this.mapping.create(state);
-    boolean _isSimple = state.isSimple();
-    _state.setLeaf(_isSimple);
-    return _state;
-  }
-  
-  protected ExecutionState _mapState(final RegularState state) {
-    return null;
-  }
-  
-  public ExecutionFlow mapRegions(final Statechart statechart, final ExecutionFlow flow) {
-    final List<Region> allRegions = this.sct.allRegions(statechart);
-    EList<ExecutionRegion> _regions = flow.getRegions();
-    final Function1<Region,ExecutionRegion> _function = new Function1<Region,ExecutionRegion>() {
-        public ExecutionRegion apply(final Region r) {
-          ExecutionRegion _mapRegion = StructureMapping.this.mapRegion(r);
-          return _mapRegion;
-        }
-      };
-    List<ExecutionRegion> _map = ListExtensions.<Region, ExecutionRegion>map(allRegions, _function);
-    _regions.addAll(_map);
-    return flow;
-  }
-  
-  public ExecutionRegion mapRegion(final Region region) {
-    final ExecutionRegion _region = this.mapping.create(region);
-    CompositeElement _composite = region.getComposite();
-    if ((_composite instanceof Statechart)) {
-      CompositeElement _composite_1 = region.getComposite();
-      ExecutionFlow _create = this.mapping.create(((Statechart) _composite_1));
-      _region.setSuperScope(_create);
-    } else {
-      CompositeElement _composite_2 = region.getComposite();
-      ExecutionState _create_1 = this.mapping.create(((State) _composite_2));
-      _region.setSuperScope(_create_1);
-    }
-    EList<ExecutionScope> _subScopes = _region.getSubScopes();
-    EList<Vertex> _vertices = region.getVertices();
-    Iterable<RegularState> _filter = Iterables.<RegularState>filter(_vertices, RegularState.class);
-    final Function1<RegularState,ExecutionScope> _function = new Function1<RegularState,ExecutionScope>() {
-        public ExecutionScope apply(final RegularState v) {
-          ExecutionState _create = StructureMapping.this.mapping.create(v);
-          return ((ExecutionScope) _create);
-        }
-      };
-    Iterable<ExecutionScope> _map = IterableExtensions.<RegularState, ExecutionScope>map(_filter, _function);
-    Iterables.<ExecutionScope>addAll(_subScopes, _map);
-    EList<ExecutionNode> _nodes = _region.getNodes();
-    EList<Vertex> _vertices_1 = region.getVertices();
-    Iterable<Vertex> _filter_1 = Iterables.<Vertex>filter(_vertices_1, Vertex.class);
-    final Function1<Vertex,ExecutionNode> _function_1 = new Function1<Vertex,ExecutionNode>() {
-        public ExecutionNode apply(final Vertex v) {
-          ExecutionNode _mapped = StructureMapping.this.mapping.mapped(v);
-          return _mapped;
-        }
-      };
-    Iterable<ExecutionNode> _map_1 = IterableExtensions.<Vertex, ExecutionNode>map(_filter_1, _function_1);
-    Iterables.<ExecutionNode>addAll(_nodes, _map_1);
-    return _region;
-  }
-  
-  public ExecutionFlow mapPseudoStates(final Statechart statechart, final ExecutionFlow r) {
-    EList<ExecutionNode> _nodes = r.getNodes();
-    Iterable<Choice> _allChoices = this.sct.allChoices(statechart);
-    final Function1<Choice,ExecutionChoice> _function = new Function1<Choice,ExecutionChoice>() {
-        public ExecutionChoice apply(final Choice choice) {
-          ExecutionChoice _create = StructureMapping.this.mapping.create(choice);
-          return _create;
-        }
-      };
-    Iterable<ExecutionChoice> _map = IterableExtensions.<Choice, ExecutionChoice>map(_allChoices, _function);
-    Iterables.<ExecutionNode>addAll(_nodes, _map);
-    EList<ExecutionNode> _nodes_1 = r.getNodes();
-    Iterable<Entry> _allEntries = this.sct.allEntries(statechart);
-    final Function1<Entry,ExecutionEntry> _function_1 = new Function1<Entry,ExecutionEntry>() {
-        public ExecutionEntry apply(final Entry entry) {
-          ExecutionEntry _create = StructureMapping.this.mapping.create(entry);
-          return _create;
-        }
-      };
-    Iterable<ExecutionEntry> _map_1 = IterableExtensions.<Entry, ExecutionEntry>map(_allEntries, _function_1);
-    Iterables.<ExecutionNode>addAll(_nodes_1, _map_1);
-    EList<ExecutionNode> _nodes_2 = r.getNodes();
-    Iterable<Synchronization> _allSynchronizations = this.sct.allSynchronizations(statechart);
-    final Function1<Synchronization,ExecutionSynchronization> _function_2 = new Function1<Synchronization,ExecutionSynchronization>() {
-        public ExecutionSynchronization apply(final Synchronization sync) {
-          ExecutionSynchronization _create = StructureMapping.this.mapping.create(sync);
-          return _create;
-        }
-      };
-    Iterable<ExecutionSynchronization> _map_2 = IterableExtensions.<Synchronization, ExecutionSynchronization>map(_allSynchronizations, _function_2);
-    Iterables.<ExecutionNode>addAll(_nodes_2, _map_2);
-    return r;
-  }
-  
-  /**
-   * Time trigger will be mapped to execution model time events for each real state.
-   */
-  public ExecutionFlow mapTimeEvents(final Statechart statechart, final ExecutionFlow r) {
-    List<EObject> content = EcoreUtil2.eAllContentsAsList(statechart);
-    final Iterable<State> allStates = Iterables.<State>filter(content, State.class);
-    final Procedure1<State> _function = new Procedure1<State>() {
-        public void apply(final State s) {
-          StructureMapping.this.mapTimeEventSpecs(s);
-        }
-      };
-    IterableExtensions.<State>forEach(allStates, _function);
-    this.mapTimeEventSpecs(statechart);
-    return r;
-  }
-  
-  public ArrayList<TimeEvent> mapTimeEventSpecs(final State state) {
-    ArrayList<TimeEvent> _xblockexpression = null;
-    {
-      final List<TimeEventSpec> timeEventSpecs = this.sct.timeEventSpecs(state);
-      ArrayList<TimeEvent> _arrayList = new ArrayList<TimeEvent>();
-      final ArrayList<TimeEvent> result = _arrayList;
-      for (final TimeEventSpec tes : timeEventSpecs) {
-        {
-          final TimeEvent timeEvent = this.mapping.createDerivedEvent(tes);
-          QualifiedName _fullyQualifiedName = this._iQualifiedNameProvider.getFullyQualifiedName(state);
-          String _plus = (_fullyQualifiedName + "_time_event_");
-          int _indexOf = timeEventSpecs.indexOf(tes);
-          String _plus_1 = (_plus + Integer.valueOf(_indexOf));
-          timeEvent.setName(_plus_1);
-          Statechart _statechart = this.sct.statechart(state);
-          ExecutionFlow _create = this.mapping.create(_statechart);
-          Scope _timeEventScope = this.mapping.timeEventScope(_create);
-          EList<Declaration> _declarations = _timeEventScope.getDeclarations();
-          _declarations.add(timeEvent);
-          result.add(timeEvent);
-        }
-      }
-      _xblockexpression = (result);
-    }
-    return _xblockexpression;
-  }
-  
-  public ArrayList<TimeEvent> mapTimeEventSpecs(final Statechart statechart) {
-    ArrayList<TimeEvent> _xblockexpression = null;
-    {
-      final List<TimeEventSpec> timeEventSpecs = this.sct.timeEventSpecs(statechart);
-      ArrayList<TimeEvent> _arrayList = new ArrayList<TimeEvent>();
-      final ArrayList<TimeEvent> result = _arrayList;
-      for (final TimeEventSpec tes : timeEventSpecs) {
-        {
-          final TimeEvent timeEvent = this.mapping.createDerivedEvent(tes);
-          String _name = statechart.getName();
-          String _plus = (_name + "_time_event_");
-          int _indexOf = timeEventSpecs.indexOf(tes);
-          String _plus_1 = (_plus + Integer.valueOf(_indexOf));
-          timeEvent.setName(_plus_1);
-          ExecutionFlow _create = this.mapping.create(statechart);
-          Scope _timeEventScope = this.mapping.timeEventScope(_create);
-          EList<Declaration> _declarations = _timeEventScope.getDeclarations();
-          _declarations.add(timeEvent);
-          result.add(timeEvent);
-        }
-      }
-      _xblockexpression = (result);
-    }
-    return _xblockexpression;
-  }
-  
-  public Declaration map(final Declaration e) {
-    if (e instanceof EventDefinition) {
-      return _map((EventDefinition)e);
-    } else if (e instanceof OperationDefinition) {
-      return _map((OperationDefinition)e);
-    } else if (e instanceof VariableDefinition) {
-      return _map((VariableDefinition)e);
-    } else if (e != null) {
-      return _map(e);
-    } else {
-      throw new IllegalArgumentException("Unhandled parameter types: " +
-        Arrays.<Object>asList(e).toString());
-    }
-  }
-  
-  public ExecutionState mapState(final RegularState state) {
-    if (state instanceof FinalState) {
-      return _mapState((FinalState)state);
-    } else if (state instanceof State) {
-      return _mapState((State)state);
-    } else if (state != null) {
-      return _mapState(state);
-    } else {
-      throw new IllegalArgumentException("Unhandled parameter types: " +
-        Arrays.<Object>asList(state).toString());
-    }
-  }
-}
+package org.yakindu.sct.model.sexec.transformation;
+
+import com.google.common.base.Objects;
+import com.google.common.collect.Iterables;
+import com.google.inject.Inject;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.xtext.EcoreUtil2;
+import org.eclipse.xtext.naming.IQualifiedNameProvider;
+import org.eclipse.xtext.naming.QualifiedName;
+import org.eclipse.xtext.xbase.lib.Functions.Function1;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.eclipse.xtext.xbase.lib.ListExtensions;
+import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
+import org.yakindu.sct.model.sexec.ExecutionChoice;
+import org.yakindu.sct.model.sexec.ExecutionEntry;
+import org.yakindu.sct.model.sexec.ExecutionFlow;
+import org.yakindu.sct.model.sexec.ExecutionNode;
+import org.yakindu.sct.model.sexec.ExecutionRegion;
+import org.yakindu.sct.model.sexec.ExecutionScope;
+import org.yakindu.sct.model.sexec.ExecutionState;
+import org.yakindu.sct.model.sexec.ExecutionSynchronization;
+import org.yakindu.sct.model.sexec.TimeEvent;
+import org.yakindu.sct.model.sexec.transformation.SexecElementMapping;
+import org.yakindu.sct.model.sexec.transformation.StatechartExtensions;
+import org.yakindu.sct.model.sgraph.Choice;
+import org.yakindu.sct.model.sgraph.CompositeElement;
+import org.yakindu.sct.model.sgraph.Declaration;
+import org.yakindu.sct.model.sgraph.Entry;
+import org.yakindu.sct.model.sgraph.FinalState;
+import org.yakindu.sct.model.sgraph.Region;
+import org.yakindu.sct.model.sgraph.RegularState;
+import org.yakindu.sct.model.sgraph.Scope;
+import org.yakindu.sct.model.sgraph.State;
+import org.yakindu.sct.model.sgraph.Statechart;
+import org.yakindu.sct.model.sgraph.Synchronization;
+import org.yakindu.sct.model.sgraph.Vertex;
+import org.yakindu.sct.model.stext.stext.EventDefinition;
+import org.yakindu.sct.model.stext.stext.OperationDefinition;
+import org.yakindu.sct.model.stext.stext.TimeEventSpec;
+import org.yakindu.sct.model.stext.stext.VariableDefinition;
+
+@SuppressWarnings("all")
+public class StructureMapping {
+  @Inject
+  private SexecElementMapping mapping;
+  
+  @Inject
+  private StatechartExtensions sct;
+  
+  @Inject
+  private IQualifiedNameProvider _iQualifiedNameProvider;
+  
+  /**
+   * maps all required scope defined in the statechart to the execution flow.
+   * This includes creating the scopes and adding all relevant declarations. Empty scopes wont be mapped.
+   */
+  public ExecutionFlow mapScopes(final Statechart sc, final ExecutionFlow flow) {
+    ExecutionFlow _xblockexpression = null;
+    {
+      EList<Scope> _scopes = flow.getScopes();
+      EList<Scope> _scopes_1 = sc.getScopes();
+      final Function1<Scope,Scope> _function = new Function1<Scope,Scope>() {
+          public Scope apply(final Scope scope) {
+            Scope _map = StructureMapping.this.map(scope);
+            return _map;
+          }
+        };
+      List<Scope> _map = ListExtensions.<Scope, Scope>map(_scopes_1, _function);
+      _scopes.addAll(_map);
+      _xblockexpression = (flow);
+    }
+    return _xblockexpression;
+  }
+  
+  public Scope map(final Scope scope) {
+    final Scope _scope = this.mapping.createScope(scope);
+    EList<Declaration> _declarations = _scope.getDeclarations();
+    EList<Declaration> _declarations_1 = scope.getDeclarations();
+    final Function1<Declaration,Declaration> _function = new Function1<Declaration,Declaration>() {
+        public Declaration apply(final Declaration decl) {
+          Declaration _map = StructureMapping.this.map(decl);
+          return _map;
+        }
+      };
+    List<Declaration> _map = ListExtensions.<Declaration, Declaration>map(_declarations_1, _function);
+    final Function1<Declaration,Boolean> _function_1 = new Function1<Declaration,Boolean>() {
+        public Boolean apply(final Declaration e) {
+          boolean _notEquals = (!Objects.equal(e, null));
+          return Boolean.valueOf(_notEquals);
+        }
+      };
+    Iterable<Declaration> _filter = IterableExtensions.<Declaration>filter(_map, _function_1);
+    Iterables.<Declaration>addAll(_declarations, _filter);
+    return _scope;
+  }
+  
+  protected Declaration _map(final Declaration decl) {
+    return null;
+  }
+  
+  protected Declaration _map(final EventDefinition e) {
+    final EventDefinition _e = this.mapping.create(e);
+    return _e;
+  }
+  
+  protected Declaration _map(final VariableDefinition v) {
+    final VariableDefinition _v = this.mapping.create(v);
+    return _v;
+  }
+  
+  protected Declaration _map(final OperationDefinition v) {
+    final OperationDefinition _v = this.mapping.create(v);
+    return _v;
+  }
+  
+  public ExecutionFlow mapRegularStates(final Statechart statechart, final ExecutionFlow r) {
+    final List<RegularState> allStates = this.sct.allRegularStates(statechart);
+    EList<ExecutionState> _states = r.getStates();
+    final Function1<RegularState,ExecutionState> _function = new Function1<RegularState,ExecutionState>() {
+        public ExecutionState apply(final RegularState s) {
+          ExecutionState _mapState = StructureMapping.this.mapState(s);
+          return _mapState;
+        }
+      };
+    List<ExecutionState> _map = ListExtensions.<RegularState, ExecutionState>map(allStates, _function);
+    _states.addAll(_map);
+    return r;
+  }
+  
+  protected ExecutionState _mapState(final FinalState state) {
+    final ExecutionState _state = this.mapping.create(state);
+    _state.setLeaf(true);
+    _state.setEntryAction(null);
+    _state.setExitAction(null);
+    return _state;
+  }
+  
+  protected ExecutionState _mapState(final State state) {
+    final ExecutionState _state = this.mapping.create(state);
+    boolean _isSimple = state.isSimple();
+    _state.setLeaf(_isSimple);
+    return _state;
+  }
+  
+  protected ExecutionState _mapState(final RegularState state) {
+    return null;
+  }
+  
+  public ExecutionFlow mapRegions(final Statechart statechart, final ExecutionFlow flow) {
+    final List<Region> allRegions = this.sct.allRegions(statechart);
+    EList<ExecutionRegion> _regions = flow.getRegions();
+    final Function1<Region,ExecutionRegion> _function = new Function1<Region,ExecutionRegion>() {
+        public ExecutionRegion apply(final Region r) {
+          ExecutionRegion _mapRegion = StructureMapping.this.mapRegion(r);
+          return _mapRegion;
+        }
+      };
+    List<ExecutionRegion> _map = ListExtensions.<Region, ExecutionRegion>map(allRegions, _function);
+    _regions.addAll(_map);
+    return flow;
+  }
+  
+  public ExecutionRegion mapRegion(final Region region) {
+    final ExecutionRegion _region = this.mapping.create(region);
+    CompositeElement _composite = region.getComposite();
+    if ((_composite instanceof Statechart)) {
+      CompositeElement _composite_1 = region.getComposite();
+      ExecutionFlow _create = this.mapping.create(((Statechart) _composite_1));
+      _region.setSuperScope(_create);
+    } else {
+      CompositeElement _composite_2 = region.getComposite();
+      ExecutionState _create_1 = this.mapping.create(((State) _composite_2));
+      _region.setSuperScope(_create_1);
+    }
+    EList<ExecutionScope> _subScopes = _region.getSubScopes();
+    EList<Vertex> _vertices = region.getVertices();
+    Iterable<RegularState> _filter = Iterables.<RegularState>filter(_vertices, RegularState.class);
+    final Function1<RegularState,ExecutionScope> _function = new Function1<RegularState,ExecutionScope>() {
+        public ExecutionScope apply(final RegularState v) {
+          ExecutionState _create = StructureMapping.this.mapping.create(v);
+          return ((ExecutionScope) _create);
+        }
+      };
+    Iterable<ExecutionScope> _map = IterableExtensions.<RegularState, ExecutionScope>map(_filter, _function);
+    Iterables.<ExecutionScope>addAll(_subScopes, _map);
+    EList<ExecutionNode> _nodes = _region.getNodes();
+    EList<Vertex> _vertices_1 = region.getVertices();
+    Iterable<Vertex> _filter_1 = Iterables.<Vertex>filter(_vertices_1, Vertex.class);
+    final Function1<Vertex,ExecutionNode> _function_1 = new Function1<Vertex,ExecutionNode>() {
+        public ExecutionNode apply(final Vertex v) {
+          ExecutionNode _mapped = StructureMapping.this.mapping.mapped(v);
+          return _mapped;
+        }
+      };
+    Iterable<ExecutionNode> _map_1 = IterableExtensions.<Vertex, ExecutionNode>map(_filter_1, _function_1);
+    Iterables.<ExecutionNode>addAll(_nodes, _map_1);
+    return _region;
+  }
+  
+  public ExecutionFlow mapPseudoStates(final Statechart statechart, final ExecutionFlow r) {
+    EList<ExecutionNode> _nodes = r.getNodes();
+    Iterable<Choice> _allChoices = this.sct.allChoices(statechart);
+    final Function1<Choice,ExecutionChoice> _function = new Function1<Choice,ExecutionChoice>() {
+        public ExecutionChoice apply(final Choice choice) {
+          ExecutionChoice _create = StructureMapping.this.mapping.create(choice);
+          return _create;
+        }
+      };
+    Iterable<ExecutionChoice> _map = IterableExtensions.<Choice, ExecutionChoice>map(_allChoices, _function);
+    Iterables.<ExecutionNode>addAll(_nodes, _map);
+    EList<ExecutionNode> _nodes_1 = r.getNodes();
+    Iterable<Entry> _allEntries = this.sct.allEntries(statechart);
+    final Function1<Entry,ExecutionEntry> _function_1 = new Function1<Entry,ExecutionEntry>() {
+        public ExecutionEntry apply(final Entry entry) {
+          ExecutionEntry _create = StructureMapping.this.mapping.create(entry);
+          return _create;
+        }
+      };
+    Iterable<ExecutionEntry> _map_1 = IterableExtensions.<Entry, ExecutionEntry>map(_allEntries, _function_1);
+    Iterables.<ExecutionNode>addAll(_nodes_1, _map_1);
+    EList<ExecutionNode> _nodes_2 = r.getNodes();
+    Iterable<Synchronization> _allSynchronizations = this.sct.allSynchronizations(statechart);
+    final Function1<Synchronization,ExecutionSynchronization> _function_2 = new Function1<Synchronization,ExecutionSynchronization>() {
+        public ExecutionSynchronization apply(final Synchronization sync) {
+          ExecutionSynchronization _create = StructureMapping.this.mapping.create(sync);
+          return _create;
+        }
+      };
+    Iterable<ExecutionSynchronization> _map_2 = IterableExtensions.<Synchronization, ExecutionSynchronization>map(_allSynchronizations, _function_2);
+    Iterables.<ExecutionNode>addAll(_nodes_2, _map_2);
+    return r;
+  }
+  
+  /**
+   * Time trigger will be mapped to execution model time events for each real state.
+   */
+  public ExecutionFlow mapTimeEvents(final Statechart statechart, final ExecutionFlow r) {
+    List<EObject> content = EcoreUtil2.eAllContentsAsList(statechart);
+    final Iterable<State> allStates = Iterables.<State>filter(content, State.class);
+    final Procedure1<State> _function = new Procedure1<State>() {
+        public void apply(final State s) {
+          StructureMapping.this.mapTimeEventSpecs(s);
+        }
+      };
+    IterableExtensions.<State>forEach(allStates, _function);
+    this.mapTimeEventSpecs(statechart);
+    return r;
+  }
+  
+  public ArrayList<TimeEvent> mapTimeEventSpecs(final State state) {
+    ArrayList<TimeEvent> _xblockexpression = null;
+    {
+      final List<TimeEventSpec> timeEventSpecs = this.sct.timeEventSpecs(state);
+      ArrayList<TimeEvent> _arrayList = new ArrayList<TimeEvent>();
+      final ArrayList<TimeEvent> result = _arrayList;
+      for (final TimeEventSpec tes : timeEventSpecs) {
+        {
+          final TimeEvent timeEvent = this.mapping.createDerivedEvent(tes);
+          QualifiedName _fullyQualifiedName = this._iQualifiedNameProvider.getFullyQualifiedName(state);
+          String _plus = (_fullyQualifiedName + "_time_event_");
+          int _indexOf = timeEventSpecs.indexOf(tes);
+          String _plus_1 = (_plus + Integer.valueOf(_indexOf));
+          timeEvent.setName(_plus_1);
+          Statechart _statechart = this.sct.statechart(state);
+          ExecutionFlow _create = this.mapping.create(_statechart);
+          Scope _timeEventScope = this.mapping.timeEventScope(_create);
+          EList<Declaration> _declarations = _timeEventScope.getDeclarations();
+          _declarations.add(timeEvent);
+          result.add(timeEvent);
+        }
+      }
+      _xblockexpression = (result);
+    }
+    return _xblockexpression;
+  }
+  
+  public ArrayList<TimeEvent> mapTimeEventSpecs(final Statechart statechart) {
+    ArrayList<TimeEvent> _xblockexpression = null;
+    {
+      final List<TimeEventSpec> timeEventSpecs = this.sct.timeEventSpecs(statechart);
+      ArrayList<TimeEvent> _arrayList = new ArrayList<TimeEvent>();
+      final ArrayList<TimeEvent> result = _arrayList;
+      for (final TimeEventSpec tes : timeEventSpecs) {
+        {
+          final TimeEvent timeEvent = this.mapping.createDerivedEvent(tes);
+          String _name = statechart.getName();
+          String _plus = (_name + "_time_event_");
+          int _indexOf = timeEventSpecs.indexOf(tes);
+          String _plus_1 = (_plus + Integer.valueOf(_indexOf));
+          timeEvent.setName(_plus_1);
+          ExecutionFlow _create = this.mapping.create(statechart);
+          Scope _timeEventScope = this.mapping.timeEventScope(_create);
+          EList<Declaration> _declarations = _timeEventScope.getDeclarations();
+          _declarations.add(timeEvent);
+          result.add(timeEvent);
+        }
+      }
+      _xblockexpression = (result);
+    }
+    return _xblockexpression;
+  }
+  
+  public Declaration map(final Declaration e) {
+    if (e instanceof EventDefinition) {
+      return _map((EventDefinition)e);
+    } else if (e instanceof OperationDefinition) {
+      return _map((OperationDefinition)e);
+    } else if (e instanceof VariableDefinition) {
+      return _map((VariableDefinition)e);
+    } else if (e != null) {
+      return _map(e);
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        Arrays.<Object>asList(e).toString());
+    }
+  }
+  
+  public ExecutionState mapState(final RegularState state) {
+    if (state instanceof FinalState) {
+      return _mapState((FinalState)state);
+    } else if (state instanceof State) {
+      return _mapState((State)state);
+    } else if (state != null) {
+      return _mapState(state);
+    } else {
+      throw new IllegalArgumentException("Unhandled parameter types: " +
+        Arrays.<Object>asList(state).toString());
+    }
+  }
+}