浏览代码

Formatting, license & author, clean-up #194

Rene Beckmann 9 年之前
父节点
当前提交
4139f4d30d

+ 24 - 16
plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/naming/ElementNameProvider.xtend

@@ -1,3 +1,14 @@
+/**
+ *   Copyright (c) 2016 committers of YAKINDU Statechart Tools.
+ *   All rights reserved. This program and the accompanying materials
+ *   are made available under the terms of the Eclipse Public License v1.0
+ *   which accompanies this distribution, and is available at
+ *   http://www.eclipse.org/legal/epl-v10.html
+ *   
+ *   Contributors:
+ * 		@author René Beckmann (beckmann@itemis.de)
+ */
+
 package org.yakindu.sct.model.sexec.naming
 
 import javax.inject.Inject
@@ -18,25 +29,23 @@ import java.util.ArrayList
 
 class ElementNameProvider {
 	@Inject private StextNameProvider provider
-	
-	def protected List<String> elementNameSegments(NamedElement e)
-	{
+
+	def protected List<String> elementNameSegments(NamedElement e) {
 		val name = elementName(e);
 		var ArrayList<String> l;
-		if(name != null) {
+		if (name != null) {
 			l = new ArrayList<String>(name.getSegments());
-		}
-		else {
+		} else {
 			l = new ArrayList<String>();
 		}
-		
+
 		return l;
 	}
-	
+
 	def protected dispatch QualifiedName elementName(ExecutionFlow it) {
 		return null;
 	}
-	
+
 	def protected dispatch QualifiedName elementName(ExecutionScope it) {
 		return sourceElement.elementName()
 	}
@@ -44,7 +53,7 @@ class ElementNameProvider {
 	def protected dispatch QualifiedName elementName(ExecutionState it) {
 		return sourceElement.elementName()
 	}
-	
+
 	def protected dispatch QualifiedName elementName(EObject it) {
 		eContainer?.elementName()
 	}
@@ -57,15 +66,15 @@ class ElementNameProvider {
 	def protected dispatch QualifiedName elementName(NamedElement it) {
 		return provider.getFullyQualifiedName(it).skipFirst(2)
 	}
-	
+
 	def protected dispatch QualifiedName elementName(Reaction it) {
 		return provider.getFullyQualifiedName(it).skipFirst(2)
 	}
-	
+
 	def protected dispatch QualifiedName elementName(Region it) {
 		return provider.getFullyQualifiedName(it).skipFirst(1)
 	}
-	
+
 	def protected dispatch QualifiedName elementName(Step it) {
 		return eContainer.elementName()
 	}
@@ -73,6 +82,5 @@ class ElementNameProvider {
 	def protected dispatch QualifiedName elementName(Vertex it) {
 		return provider.getFullyQualifiedName(it).skipFirst(1)
 	}
-	
-	
-}
+
+}

+ 76 - 88
plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/naming/ShortString.xtend

@@ -1,3 +1,14 @@
+/**
+ *   Copyright (c) 2016 committers of YAKINDU Statechart Tools.
+ *   All rights reserved. This program and the accompanying materials
+ *   are made available under the terms of the Eclipse Public License v1.0
+ *   which accompanies this distribution, and is available at
+ *   http://www.eclipse.org/legal/epl-v10.html
+ *   
+ *   Contributors:
+ * 		@author René Beckmann (beckmann@itemis.de)
+ */
+
 package org.yakindu.sct.model.sexec.naming
 
 import java.lang.String
@@ -7,10 +18,9 @@ class ShortString {
 	 * Class that manages a string and shortened versions of it.
 	 */
 	private String originalString;
-	
+
 	private int[] cutArray; // holds information if char is cut or not
 	private int[] previous_cutArray; // holds previous state for rollback / undo possibility
-	
 	// cost of cutting operations
 	final static public int COST_LOWERCASE_VOCALS = 1;
 	final static public int COST_UNDERSCORE = 1;
@@ -18,11 +28,9 @@ class ShortString {
 	final static public int COST_UPPERCASE = 3;
 	final static public int COST_DIGIT = 10;
 	final static public int COST_FIRSTLETTER = 10;
-	
-	
-	new(String s)
-	{
-		if(s == null) {
+
+	new(String s) {
+		if (s == null) {
 			originalString = "";
 		} else {
 			originalString = s;
@@ -32,164 +40,144 @@ class ShortString {
 		reset();
 		saveCurrentToPrevious();
 	}
-	
-	def public getOriginalString()
-	{
+
+	def public getOriginalString() {
 		originalString
 	}
-	
-	def private int size()
-	{
+
+	def private int size() {
 		// instead of saving originalString.length as an own member
 		originalString.length
 	}
-	
-	def public reset()
-	{
+
+	def public reset() {
 		// Reset cut_array so that the shortened String is equal to the original String.
 		saveCurrentToPrevious();
-		for(var i=0; i<size; i++) {
+		for (var i = 0; i < size; i++) {
 			cutArray.set(i, 1);
 		}
 	}
-	
-	def private saveCurrentToPrevious()
-	{
+
+	def private saveCurrentToPrevious() {
 		// save current cut-state to previous_cutArray.
-		for(var i=0; i<size; i++) {
+		for (var i = 0; i < size; i++) {
 			previous_cutArray.set(i, cutArray.get(i));
 		}
 	}
-	
-	def public rollback()
-	{
+
+	def public rollback() {
 		// return to previous state
-		for(var i=0; i<size; i++) {
+		for (var i = 0; i < size; i++) {
 			cutArray.set(i, previous_cutArray.get(i));
 		}
 	}
-	
-	def public String getShortenedString()
-	{
+
+	def public String getShortenedString() {
 		// return the current version of the shortened string according to cutArray
 		var sb = new StringBuilder();
-		
-		for(var i=0; i<size; i++) {
-			if(cutArray.get(i) != 0) {
+
+		for (var i = 0; i < size; i++) {
+			if (cutArray.get(i) != 0) {
 				sb.append(originalString.charAt(i));
 			}
 		}
-		
+
 		sb.toString;
 	}
-	
-	def public int getShortenedSize()
-	{
+
+	def public int getShortenedSize() {
 		var length = 0;
-		for(var i=0; i<size; i++)
-		{
-			if(cutArray.get(i) != 0) {
+		for (var i = 0; i < size; i++) {
+			if (cutArray.get(i) != 0) {
 				length += 1;
 			}
 		}
-		
+
 		return length;
 	}
-	
-	def public int getCutCostFactor()
-	{
+
+	def public int getCutCostFactor() {
 		// factor that takes into account how much of the string is already cut, so that cutting away more characters get's more expensive
-		return 10 + (getCutRatio()*10) as int;
+		return 10 + (getCutRatio() * 10) as int;
 	}
-	
-	def public int getCutCost()
-	{
+
+	def public int getCutCost() {
 		// returns the current cutting cost of the ShortString by iterating over the cutArray and accumulating cost per index
-		if(1.0 - getCutRatio() < 0.001) {
+		if (1.0 - getCutRatio() < 0.001) {
 			return Integer.MAX_VALUE;
 		}
 		var cost = 0;
-		
-		for(var i=0; i<size; i++) {
-			if(cutArray.get(i) == 0) {
+
+		for (var i = 0; i < size; i++) {
+			if (cutArray.get(i) == 0) {
 				cost += getBaseCutCost(i);
 			}
 		}
-		
+
 		return cost * getCutCostFactor;
 	}
-	
-	def public int getBaseCutCost(int index)
-	{
+
+	def public int getBaseCutCost(int index) {
 		// returns the cut cost of this char, independent of its cut state.
 		var cost = 0;
-		
+
 		var c = originalString.charAt(index);
-		
-		if(index == 0) {
+
+		if (index == 0) {
 			cost += org.yakindu.sct.model.sexec.naming.ShortString.COST_FIRSTLETTER;
 		}
-		if(Character.isDigit(c)) {
+		if (Character.isDigit(c)) {
 			cost += org.yakindu.sct.model.sexec.naming.ShortString.COST_DIGIT;
-		}
-		else if(Character.isUpperCase(c)) {
+		} else if (Character.isUpperCase(c)) {
 			cost += org.yakindu.sct.model.sexec.naming.ShortString.COST_UPPERCASE;
-		}
-		else if(isLowercaseVocal(c)) {
+		} else if (isLowercaseVocal(c)) {
 			cost += org.yakindu.sct.model.sexec.naming.ShortString.COST_LOWERCASE_VOCALS;
-		} 
-		else if(c.toString().equals("_")) {
+		} else if (c.toString().equals("_")) {
 			cost += org.yakindu.sct.model.sexec.naming.ShortString.COST_UNDERSCORE;
-		}
-		else {
+		} else {
 			cost += org.yakindu.sct.model.sexec.naming.ShortString.COST_LOWERCASE_CONSONANTS;
 		}
-		
+
 		return cost;
 	}
-	
-	def public removeCheapestChar()
-	{
+
+	def public removeCheapestChar() {
 		// of all possible characters that aren't cut yet, remove the one with the lowest cutting cost.
 		// saveCurrentToPrevious(); - done in removeIndex(i);
 		var cheapestOperation_cost = Integer.MAX_VALUE;
 		var cheapestOperation_index = 0;
-		for(var i=0; i<size; i++) {
-			if(cutArray.get(i) != 0) {
+		for (var i = 0; i < size; i++) {
+			if (cutArray.get(i) != 0) {
 				var cost = getBaseCutCost(i);
-				if(cost < cheapestOperation_cost) {
+				if (cost < cheapestOperation_cost) {
 					cheapestOperation_cost = cost;
 					cheapestOperation_index = i;
 				}
 			}
 		}
-		
+
 		removeIndex(cheapestOperation_index);
 	}
-	
-	
-	def public float getCutRatio()
-	{
+
+	def public float getCutRatio() {
 		// returns the ratio of characters that are cut.
 		1 - ((getShortenedSize as float) / (size as float))
 	}
-	
-	def public removeIndex(int index)
-	{
+
+	def public removeIndex(int index) {
 		saveCurrentToPrevious();
-		if(index < size) {
+		if (index < size) {
 			cutArray.set(index, 0);
 		}
 	}
-	
+
 	def private boolean isLowercaseVocal(int i) {
 		var c = originalString.charAt(i);
 		return isLowercaseVocal(c);
 	}
-	
-	def private boolean isLowercaseVocal(char c) 
-	{
+
+	def private boolean isLowercaseVocal(char c) {
 		val s = c.toString();
-		return (s == "a"|| s == "e" || s == "i" || s == "o" || s == "u");
+		return (s == "a" || s == "e" || s == "i" || s == "o" || s == "u");
 	}
-}
+}

+ 39 - 43
plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/naming/StringTreeNode.xtend

@@ -1,15 +1,24 @@
+/**
+ *   Copyright (c) 2016 committers of YAKINDU Statechart Tools.
+ *   All rights reserved. This program and the accompanying materials
+ *   are made available under the terms of the Eclipse Public License v1.0
+ *   which accompanies this distribution, and is available at
+ *   http://www.eclipse.org/legal/epl-v10.html
+ *   
+ *   Contributors:
+ * 		@author René Beckmann (beckmann@itemis.de)
+ */
+
 package org.yakindu.sct.model.sexec.naming
 
 import java.util.ArrayList
 import java.util.List
 import java.util.Comparator
 
-class StringTreeNodeDepthComparator implements Comparator<StringTreeNode>
-{
+class StringTreeNodeDepthComparator implements Comparator<StringTreeNode> {
 	override compare(StringTreeNode o1, StringTreeNode o2) {
 		return o1.getDepth() - o2.getDepth();
 	}
-	
 }
 
 class StringTreeNode {
@@ -127,16 +136,14 @@ class StringTreeNode {
 
 		return nodelist;
 	}
-	
-	def public int getWeight()
-	{
+
+	def public int getWeight() {
 		var weight = 0;
-		
-		for(c : children)
-		{
+
+		for (c : children) {
 			weight += c.getWeight() + 1; // + 1: count children as well
 		}
-		
+
 		return weight;
 	}
 
@@ -229,23 +236,20 @@ class StringTreeNode {
 
 		return ret;
 	}
-	
-	def public void delete()
-	{
+
+	def public void delete() {
 		/*
 		 * All nodes have a reference to their parent (except the root node, where it's null) and their children.
 		 * Thus, when we want to delete a node, we need to cut it from its parent's children and
 		 * delete the reference to the parent. The rest of the tree is then 'floating' and will be garbage collected.
 		 */
-		if(!isRoot())
-		{
+		if (!isRoot()) {
 			this.parent.deleteChild(this);
 			this.parent = null;
 		}
 	}
-	
-	def public deleteChild(StringTreeNode child)
-	{
+
+	def public deleteChild(StringTreeNode child) {
 		this.children.removeAll(child);
 	}
 
@@ -270,20 +274,18 @@ class StringTreeNode {
 				maxEqualNode = child;
 			}
 		}
-		
-		if(maxEqualNode == null)
-		{
+
+		if (maxEqualNode == null) {
 			return null;
 		}
 
 		var rest = name.substring(maxEquality);
 
 		nodeChain.add(maxEqualNode);
-		
+
 		val childrenNodeChain = maxEqualNode.getNodeChain(rest);
-		
-		if(childrenNodeChain == null)
-		{
+
+		if (childrenNodeChain == null) {
 			return null;
 		}
 
@@ -291,34 +293,28 @@ class StringTreeNode {
 
 		return nodeChain;
 	}
-	
-	def public StringTreeNode navigate(String content)
-	{
-		for(child: children)
-		{
-			if(content.equals(child.getData()))
-			{
+
+	def public StringTreeNode navigate(String content) {
+		for (child : children) {
+			if (content.equals(child.getData())) {
 				return child;
 			}
 		}
-		
+
 		return null;
 	}
-	
-	def public StringTreeNode getParent()
-	{
+
+	def public StringTreeNode getParent() {
 		return parent;
 	}
-	
-	def public List<String> getChildrenContents()
-	{
+
+	def public List<String> getChildrenContents() {
 		var returnList = new ArrayList<String>();
-		
-		for(child : children)
-		{
+
+		for (child : children) {
 			returnList.add(child.getData());
 		}
-		
+
 		return returnList;
 	}
 

+ 201 - 243
plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/naming/TreeNamingService.xtend

@@ -1,67 +1,50 @@
 /**
- *   Copyright (c) 2014-2015 committers of YAKINDU Statechart Tools.
+ *   Copyright (c) 2016 committers of YAKINDU Statechart Tools.
  *   All rights reserved. This program and the accompanying materials
  *   are made available under the terms of the Eclipse Public License v1.0
  *   which accompanies this distribution, and is available at
  *   http://www.eclipse.org/legal/epl-v10.html
  *   
  *   Contributors:
- *   	Markus Mühlbrandt - Initial contribution and API
- *   	Axel Terfloth - Extensions
+ * 		@author René Beckmann (beckmann@itemis.de)
  */
 
-
 package org.yakindu.sct.model.sexec.naming
 
 import java.util.ArrayList
-import java.util.Comparator
 import java.util.HashMap
 import java.util.List
 import java.util.Map
 import javax.inject.Inject
-import org.eclipse.emf.ecore.EObject
 import org.eclipse.xtext.naming.IQualifiedNameProvider
 import org.yakindu.base.base.NamedElement
 import org.yakindu.sct.model.sexec.ExecutionFlow
-import org.yakindu.sct.model.sexec.ExecutionNode
 import org.yakindu.sct.model.sexec.ExecutionScope
 import org.yakindu.sct.model.sexec.ExecutionState
 import org.yakindu.sct.model.sexec.Step
 import org.yakindu.sct.model.sexec.extensions.SExecExtensions
-import org.yakindu.sct.model.sexec.transformation.SgraphExtensions
 import org.yakindu.sct.model.sexec.transformation.StatechartExtensions
 import org.yakindu.sct.model.sgraph.CompositeElement
 import org.yakindu.sct.model.sgraph.Region
 import org.yakindu.sct.model.sgraph.State
 import org.yakindu.sct.model.sgraph.Statechart
 import org.yakindu.sct.model.sgraph.Vertex
-import org.yakindu.sct.model.stext.naming.StextNameProvider
 import org.yakindu.sct.model.stext.stext.TimeEventSpec
-import org.yakindu.sct.model.sexec.Reaction
-import org.eclipse.xtext.naming.QualifiedName
-import org.yakindu.sct.model.sexec.ExecutionRegion
-import org.yakindu.sct.model.stext.stext.LocalReaction
 import com.google.common.collect.Maps
 
-/** Default implementation of the naming service for various identifiers used in the generated code. 
+/** New implementation of the naming service for various identifiers used in the generated code. 
  * It is responsible for identifier construction depending on the thing to be named including different strategies 
  * which also include name shortening.
  */
 class TreeNamingService implements INamingService {
 
 	@Inject extension SExecExtensions
-	//@Inject extension SgraphExtensions
 	@Inject extension StatechartExtensions
 	@Inject extension IQualifiedNameProvider
-	//@Inject extension StepDepthComparator stepDepthComparator
-	//@Inject extension ExecutionScopeDepthComparator executionScopeDepthComparator
-	//@Inject extension NamingHelper
-	
+
 	@Inject extension ElementNameProvider
-	
-	@Inject private StringTreeNodeDepthComparator stringTreeNodeDepthComparator
 
-	//@Inject private StextNameProvider provider
+	@Inject private StringTreeNodeDepthComparator stringTreeNodeDepthComparator
 
 	// from public class org.yakindu.sct.generator.c.features.CDefaultFeatureValueProvider extends		
 	private static final String VALID_IDENTIFIER_REGEX = "[_a-zA-Z][_a-zA-Z0-9]*";
@@ -74,26 +57,24 @@ class TreeNamingService implements INamingService {
 	 * Holds the name of each element whose name was requested.
 	 */
 	var protected Map<NamedElement, String> map;
-	
+
 	/*
 	 * Holds the end node in the tree for each NamedElement that was added.
 	 */
 	var protected Map<NamedElement, StringTreeNode> treeMap;
-	
+
 	/*
 	 * For each node in the tree, there is a mapping to a short string managing the shortening of the name.
 	 */
 	var protected Map<StringTreeNode, ShortString> node_shortString_map;
-	
+
 	/*
 	 * For each end node, individualMap holds a List of Nodes which make this name individual. (a subset of the tree basically)
 	 */
 	var protected Map<StringTreeNode, ArrayList<StringTreeNode>> individualMap;
-	
+
 	var protected boolean shortNamesValid; // marker to remember if the names are currently correctly shortened
-	
 	var protected StringTreeNode tree; // the tree which holds the added names
-	
 	// if the naming service is initialized with a flow, activeStatechart is null, and vice versa.
 	var protected ExecutionFlow activeFlow;
 
@@ -108,33 +89,30 @@ class TreeNamingService implements INamingService {
 		this.maxLength = 0
 		this.separator = '_'
 	}
-	
-	override initializeNamingService(Statechart statechart) 
-	{
-		if(tree == null || activeStatechart != statechart)
-		{
+
+	override initializeNamingService(Statechart statechart) {
+		if (tree == null || activeStatechart != statechart) {
 			map = Maps.newHashMap
 			treeMap = Maps.newHashMap
 			shortNamesValid = false;
-		
+
 			activeFlow = null;
 			activeStatechart = statechart;
 			createNameTree(statechart);
-			
+
 			individualMap = constructIndividualNames();
 			node_shortString_map = createShortStringMapping();
-			
+
 			shortenNames();
 		}
 	}
-	
-	def private void createNameTree(Statechart statechart)
-	{
+
+	def private void createNameTree(Statechart statechart) {
 		tree = new StringTreeNode();
-		
+
 		addShortVertexNames(statechart);
 	}
-	
+
 	def protected void addShortVertexNames(CompositeElement element) {
 		for (region : element.regions) {
 			addElement(region, new ArrayList<String>(), new ArrayList<String>());
@@ -155,78 +133,66 @@ class TreeNamingService implements INamingService {
 			}
 		}
 	}
-	
-	override initializeNamingService(ExecutionFlow flow) 
-	{
-		if(tree == null || activeFlow != flow)
-		{
+
+	override initializeNamingService(ExecutionFlow flow) {
+		if (tree == null || activeFlow != flow) {
 			map = Maps.newHashMap
 			treeMap = Maps.newHashMap
 			shortNamesValid = false;
-			
+
 			activeFlow = flow;
 			activeStatechart = null;
-			
+
 			createNameTree(flow);
 			individualMap = constructIndividualNames();
 			node_shortString_map = createShortStringMapping();
-			
+
 			shortenNames();
 		}
 	}
-	
-	def private void createNameTree(ExecutionFlow flow)
-	{
+
+	def private void createNameTree(ExecutionFlow flow) {
 		// Initialize tree
 		tree = new StringTreeNode();
-		
-		for(region : flow.regions)
-		{
+
+		for (region : flow.regions) {
 			addElement(region, new ArrayList<String>(), new ArrayList<String>());
-			for(node : region.nodes) {
+			for (node : region.nodes) {
 				addElement(node, new ArrayList<String>(), new ArrayList<String>());
 			}
 		}
-		
-		for(state : flow.states)
-		{
+
+		for (state : flow.states) {
 			addElement(state, state.prefix, state.suffix);
 		}
-		for(func : flow.allFunctions)
-		{
+		for (func : flow.allFunctions) {
 			addElement(func, func.prefix, func.suffix);
 		}
-		
+
 		// Create short name for time events of statechart
-		if (flow.sourceElement instanceof Statechart) 
-		{
+		if (flow.sourceElement instanceof Statechart) {
 			val statechart = flow.sourceElement as Statechart
 			addShortTimeEventName(flow, statechart)
 		}
 
 		// Create short name for time events of states
-		for (executionState : flow.states)
-		{
-			if (executionState.sourceElement instanceof State) 
-			{
+		for (executionState : flow.states) {
+			if (executionState.sourceElement instanceof State) {
 				val state = executionState.sourceElement as State
 				addShortTimeEventName(executionState, state)
 			}
 		}
 	}
-	
-	def public test_printTreeContents()
-	{
-		for(s : tree.getContents())
-		{
+
+	def public test_printTreeContents() {
+		for (s : tree.getContents()) {
 			System.out.println(s);
 		}
-		
+
 		System.out.println();
 	}
-	
-	def protected addShortTimeEventName(NamedElement executionFlowElement, NamedElement sgraphElement) 
-	{
+
+	def protected addShortTimeEventName(NamedElement executionFlowElement, NamedElement sgraphElement) {
 		var timeEventSpecs = sgraphElement.timeEventSpecs;
 		for (tes : timeEventSpecs) {
 			val timeEvent = executionFlowElement.flow.getTimeEvent(sgraphElement.fullyQualifiedName + "_time_event_" +
@@ -236,25 +202,22 @@ class TreeNamingService implements INamingService {
 			}
 		}
 	}
-	
-	def private void addElement(NamedElement elem, List<String> prefix, List<String> suffix)
-	{
+
+	def private void addElement(NamedElement elem, List<String> prefix, List<String> suffix) {
 		val name = new ArrayList<String>(elem.elementNameSegments());
 		val segments = new ArrayList<String>();
 		segments.addAll(prefix);
 		segments.addAll(name);
 		segments.addAll(suffix);
-		if(!segments.isEmpty()) {
+		if (!segments.isEmpty()) {
 			val addedNode = tree.addStringList(segments);
-			
+
 			treeMap.put(elem, addedNode); // remember for later access
-			
 			shortNamesValid = false;
 		}
-		//System.out.println(name);
-	
+	// System.out.println(name);
 	}
-	
+
 	def protected asIndexPosition(ExecutionScope it) {
 		superScope.subScopes.indexOf(it).toString;
 	}
@@ -274,7 +237,7 @@ class TreeNamingService implements INamingService {
 	def protected removeVowels(String it) {
 		replaceAll('[aeiou]', '')
 	}
-	
+
 	def protected removeSmallLetters(String it) {
 		replaceAll('[a-z]', '');
 	}
@@ -299,31 +262,28 @@ class TreeNamingService implements INamingService {
 	override public getSeparator() {
 		return separator
 	}
-	
+
 	override getShortName(NamedElement element) {
-		if(map.containsKey(element)) {
+		if (map.containsKey(element)) {
 			return map.get(element);
 		}
-		if(!treeMap.containsKey(element)) {
+		if (!treeMap.containsKey(element)) {
 			addElement(element, new ArrayList<String>(), new ArrayList<String>());
 		}
-		
-		if(!shortNamesValid) {
+
+		if (!shortNamesValid) {
 			shortenNames();
 		}
-		
+
 		val name = getShortenedName(element);
-		
+
 		map.put(element, name);
 		return name;
 	}
-	
-	def private Map<StringTreeNode, ArrayList<StringTreeNode>> constructIndividualNames()
-	{
+
+	def private Map<StringTreeNode, ArrayList<StringTreeNode>> constructIndividualNames() {
 		val nodes = tree.getEndNodes().sortWith(stringTreeNodeDepthComparator);
-		
-		val names = new ArrayList<String>();
-		
+
 		/*
 		 * The map doublets is a three dimensional construct.
 		 * For each end-node-name in the tree, it holds a list of lists describing that name.
@@ -357,13 +317,12 @@ class TreeNamingService implements INamingService {
 		 * 
 		 */
 		var doublets = new HashMap<String, ArrayList<ArrayList<StringTreeNode>>>();
-		
+
 		val mapping = new HashMap<StringTreeNode, ArrayList<StringTreeNode>>();
-		
+
 		// Initialization
-		for(node : nodes)
-		{
-			if(!doublets.containsKey(node.data)) {
+		for (node : nodes) {
+			if (!doublets.containsKey(node.data)) {
 				doublets.put(node.data, new ArrayList<ArrayList<StringTreeNode>>());
 			}
 			val list = new ArrayList<StringTreeNode>();
@@ -371,254 +330,230 @@ class TreeNamingService implements INamingService {
 			mapping.put(node, list);
 			list.add(node);
 		}
-		
+
 		var abort = false;
 		// Iteration
-		while(!abort)
-		{
+		while (!abort) {
 			// Phase 1
-			for(name : doublets.keySet)
-			{
-				if(doublets.get(name).length > 1)
-				{
-					for(nodelist : doublets.get(name))
-					{
+			for (name : doublets.keySet) {
+				if (doublets.get(name).length > 1) {
+					for (nodelist : doublets.get(name)) {
 						nodelist.add(0, nodelist.get(0).parent);
 					}
 				}
 			}
-			
+
 			// Phase 2
 			val newDoublets = new HashMap<String, ArrayList<ArrayList<StringTreeNode>>>();
-			
-			for(name : doublets.keySet) // for all keys
+
+			for (name : doublets.keySet) // for all keys
 			{
-				for(nodelist : doublets.get(name)) // for inner lists
+				for (nodelist : doublets.get(name)) // for inner lists
 				{
 					val sb = new StringBuilder();
-					
-					for(var i=0; i<nodelist.length;i++)
-					{
-						if(i != 0) {
+
+					for (var i = 0; i < nodelist.length; i++) {
+						if (i != 0) {
 							sb.append(separator)
 						}
 						sb.append(nodelist.get(i).getData())
 					}
-					
-					if(!newDoublets.containsKey(sb.toString)) {
+
+					if (!newDoublets.containsKey(sb.toString)) {
 						newDoublets.put(sb.toString, new ArrayList<ArrayList<StringTreeNode>>());
 					}
-					
+
 					newDoublets.get(sb.toString).add(nodelist);
 				}
 			}
-			
+
 			doublets = newDoublets;
-			
+
 			// Abort criterion
 			abort = true;
-			for(name : doublets.keySet)
-			{
+			for (name : doublets.keySet) {
 				if(doublets.get(name).length > 1) abort = false;
 			}
 		}
-		
-		
+
 		return mapping;
 	}
-	
-	def private shortenNames()
-	{
-		if(this.maxLength == 0) {
+
+	def private shortenNames() {
+		if (this.maxLength == 0) {
 			return;
 		}
-		
-		if(individualMap == null || individualMap.isEmpty()) {
+
+		if (individualMap == null || individualMap.isEmpty()) {
 			constructIndividualNames();
-		}		
-		
+		}
+
 		val max_weight = tree.getWeight();
-		
-		while(shortenOneCharacter(tree.getEndNodes(), max_weight)) {}
-		
+
+		while (shortenOneCharacter(tree.getEndNodes(), max_weight)) {
+		}
+
 		shortNamesValid = true;
 	}
-	
-	def private boolean shortenOneCharacter(ArrayList<StringTreeNode> endnodes, int max_weight)
-	{
+
+	def private boolean shortenOneCharacter(ArrayList<StringTreeNode> endnodes, int max_weight) {
 		/*
 		 * takes all end-nodes of the tree, finds their attached individual chain of nodes, their shortstring and shortens the
 		 * longest chain's cheapest shortstring.
 		 */
 		var max_length = 0;
 		var StringTreeNode max_length_node;
-		
+
 		var names = new ArrayList<String>();
-		
-		for(node : endnodes)
-		{
+
+		for (node : endnodes) {
 			// iterates over all endnodes and returns the maximum length of all names.
 			var newname = node.getIndividualName.joinShortStrings();
 			names.add(newname);
 			var length = newname.length();
-			if(length > max_length)
-			{
+			if (length > max_length) {
 				max_length = length;
 				max_length_node = node;
 			}
 		}
-		
-		if(max_length < this.maxLength) {
+
+		if (max_length < this.maxLength) {
 			return false;
 		}
-		
+
 		var min_cost = Integer.MAX_VALUE;
 		var ShortString best_cut;
-		
-		for(node : max_length_node.getIndividualName) // all nodes describing the individual name of this end node
+
+		for (node : max_length_node.getIndividualName) // all nodes describing the individual name of this end node
 		{
 			val shortstr = node.shortStringForNode;
 			val current_cost = shortstr.getCutCost();
-			
+
 			var noDoubles = false;
-			
+
 			val node_cost_factor = max_weight - node.getWeight() + 1;
-			
+
 			shortstr.removeCheapestChar();
-			
+
 			val cut_cost = (shortstr.getCutCost() - current_cost) * node_cost_factor;
-			
+
 			val current_name = max_length_node.getIndividualName.joinShortStrings;
-			
-			if(!names.contains(current_name)) {
+
+			if (!names.contains(current_name)) {
 				noDoubles = true;
 				// do further check to avoid double names only when quick check is okay
 				var doubleCheckArray = new ArrayList<String>();
-				for(n : endnodes)
-				{
+				for (n : endnodes) {
 					var newname = n.getIndividualName.joinShortStrings();
-					if(doubleCheckArray.contains(newname)) {
+					if (doubleCheckArray.contains(newname)) {
 						noDoubles = false;
 					}
 					doubleCheckArray.add(newname);
 				}
 			}
-			
-			if(noDoubles && cut_cost > 0 && cut_cost < min_cost) {
+
+			if (noDoubles && cut_cost > 0 && cut_cost < min_cost) {
 				min_cost = cut_cost;
 				best_cut = shortstr;
 			}
-			
+
 			shortstr.rollback(); // revert changes
 		}
-		
-		if(best_cut == null) {
+
+		if (best_cut == null) {
 			return false;
 		}
 		best_cut.removeCheapestChar(); // reapply best change
 		return true;
 	}
-	
-	def private Map<StringTreeNode, ShortString> createShortStringMapping()
-	{
+
+	def private Map<StringTreeNode, ShortString> createShortStringMapping() {
 		val HashMap<StringTreeNode, ShortString> mapping = newHashMap;
-		for(node : tree.getNodes()) {
+		for (node : tree.getNodes()) {
 			mapping.put(
 				node,
 				new ShortString(node.getData())
 			);
 		}
-		
+
 		return mapping;
 	}
-	
-	def private StringTreeNode getNodeForElement(NamedElement elem)
-	{
+
+	def private StringTreeNode getNodeForElement(NamedElement elem) {
 		return treeMap.get(elem);
 	}
-	
-	def private ShortString getShortStringForNode(StringTreeNode node)
-	{
-		if(node_shortString_map == null || node_shortString_map.isEmpty())
-		{
+
+	def private ShortString getShortStringForNode(StringTreeNode node) {
+		if (node_shortString_map == null || node_shortString_map.isEmpty()) {
 			createShortStringMapping();
 		}
 		return node_shortString_map.get(node);
 	}
-	
-	def private ArrayList<StringTreeNode> getIndividualName(StringTreeNode node)
-	{
-		if(individualMap.isEmpty())
-		{
+
+	def private ArrayList<StringTreeNode> getIndividualName(StringTreeNode node) {
+		if (individualMap.isEmpty()) {
 			constructIndividualNames();
 		}
 		return individualMap.get(node);
 	}
-	
-	def private getShortenedName(StringTreeNode node)
-	{
+
+	def private getShortenedName(StringTreeNode node) {
 		return joinShortStrings(getIndividualName(node));
 	}
-	
-	def private getShortenedName(NamedElement elem)
-	{
+
+	def private getShortenedName(NamedElement elem) {
 		return getShortenedName(getNodeForElement(elem));
 	}
-	
+
 	override asEscapedIdentifier(String string) {
 		asIdentifier(string);
 	}
-	
+
 	override asIdentifier(String string) {
 		string.replaceAll('[^a-z&&[^A-Z&&[^0-9]]]', separator.toString)
 	}
-	
+
 	override isKeyword(String string) {
 		return false;
 	}
-	
+
 	override getShortNameMap(Statechart statechart) {
 		throw new UnsupportedOperationException("TODO: auto-generated method stub")
 	}
-	
+
 	override getShortNameMap(ExecutionFlow flow) {
 		throw new UnsupportedOperationException("TODO: auto-generated method stub")
 	}
-	
-	def public getTreeContents()
-	{
+
+	def public getTreeContents() {
 		return tree.getContents();
 	}
-	
-	def private List<NamedElement> getNodeElements(StringTreeNode node)
-	{
+
+	def private List<NamedElement> getNodeElements(StringTreeNode node) {
 		val ArrayList<NamedElement> list = new ArrayList<NamedElement>();
-		
-		for(elem : treeMap.keySet())
-		{
-			if(treeMap.get(elem) == node) {
+
+		for (elem : treeMap.keySet()) {
+			if (treeMap.get(elem) == node) {
 				list.add(elem);
 			}
 		}
-		
+
 		return list;
 	}
-	
-	def private String joinShortStrings(ArrayList list)
-	{
+
+	def private String joinShortStrings(ArrayList list) {
 		val sb = new StringBuilder();
 		var first = true;
-		
-		for(s : list)
-		{
+
+		for (s : list) {
 			var String shortened;
-			if(s instanceof ShortString) {
-				shortened = s.getShortenedString(); 
-			} else if(s instanceof StringTreeNode) {
+			if (s instanceof ShortString) {
+				shortened = s.getShortenedString();
+			} else if (s instanceof StringTreeNode) {
 				shortened = s.getShortStringForNode.getShortenedString();
 			}
-			if(shortened.length > 0) {
-				if(first) {
+			if (shortened.length > 0) {
+				if (first) {
 					sb.append(shortened);
 					first = false;
 				} else {
@@ -627,36 +562,55 @@ class TreeNamingService implements INamingService {
 				}
 			}
 		}
-		
+
 		return sb.toString();
 	}
-	
+
 	def protected suffix(Step it) {
 		var l = new ArrayList<String>();
-		
+
 		switch (it) {
-			case isCheckFunction: { l.add("check"); }
-			case isEntryAction: { l.add("enact"); }
-			case isExitAction: { l.add("exact"); }
-			case isEffect: { l.add("effect"); }
-			case isEnterSequence: { l.add("enseq"); }
-			case isDeepEnterSequence: { l.add("dhenseq"); }
-			case isShallowEnterSequence: { l.add("shenseq"); }
-			case isExitSequence: { l.add("exseq"); }
-			case isReactSequence: { l.add("react"); }
-			default: {}
-		}
-		
+			case isCheckFunction: {
+				l.add("check");
+			}
+			case isEntryAction: {
+				l.add("enact");
+			}
+			case isExitAction: {
+				l.add("exact");
+			}
+			case isEffect: {
+				l.add("effect");
+			}
+			case isEnterSequence: {
+				l.add("enseq");
+			}
+			case isDeepEnterSequence: {
+				l.add("dhenseq");
+			}
+			case isShallowEnterSequence: {
+				l.add("shenseq");
+			}
+			case isExitSequence: {
+				l.add("exseq");
+			}
+			case isReactSequence: {
+				l.add("react");
+			}
+			default: {
+			}
+		}
+
 		return l;
 	}
 
-	def protected prefix(Step it){
+	def protected prefix(Step it) {
 		return new ArrayList<String>();
 	}
 
 	def protected prefix(ExecutionState it) {
 		var l = new ArrayList<String>();
-		//l.add(flow.name);
+		// l.add(flow.name);
 		return l;
 	}
 
@@ -666,22 +620,26 @@ class TreeNamingService implements INamingService {
 
 	def protected prefix(TimeEventSpec it, NamedElement element) {
 		var l = new ArrayList<String>();
-		//l.add(activeFlow.name);
+		// l.add(activeFlow.name);
 		return l;
 	}
 
 	def protected suffix(TimeEventSpec it, NamedElement element) {
 		var l = new ArrayList<String>();
 		switch (element) {
-			Statechart: { l.add("tev" + element.timeEventSpecs.indexOf(it)); }
-			State: { l.add("tev" + element.timeEventSpecs.indexOf(it)); }
+			Statechart: {
+				l.add("tev" + element.timeEventSpecs.indexOf(it));
+			}
+			State: {
+				l.add("tev" + element.timeEventSpecs.indexOf(it));
+			}
 		}
 		return l;
 	}
 
 	def protected prefix(State it) {
 		var l = new ArrayList<String>();
-		//l.add(activeStatechart.name);
+		// l.add(activeStatechart.name);
 		return l;
 	}
 

+ 1 - 1
test-plugins/org.yakindu.sct.model.sexec.test/src/org/yakindu/sct/model/sexec/transformation/test/AllTests.java

@@ -1,5 +1,5 @@
 /** 
- * Copyright (c) 2015 committers of YAKINDU and others. 
+ * Copyright (c) 2016 committers of YAKINDU and others. 
  * All rights reserved. This program and the accompanying materials 
  * are made available under the terms of the Eclipse Public License v1.0 
  * which accompanies this distribution, and is available at 

+ 11 - 0
test-plugins/org.yakindu.sct.model.sexec.test/src/org/yakindu/sct/model/sexec/transformation/test/ShortStringTest.java

@@ -1,3 +1,14 @@
+/** 
+ * Copyright (c) 2016 committers of YAKINDU and others. 
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html 
+ * Contributors:
+ * @author René Beckmann (beckmann@itemis.de)
+ *
+*/
+
 package org.yakindu.sct.model.sexec.transformation.test;
 
 import static org.junit.Assert.assertEquals;

+ 113 - 163
test-plugins/org.yakindu.sct.model.sexec.test/src/org/yakindu/sct/model/sexec/transformation/test/StringTreeNodeTest.java

@@ -1,11 +1,11 @@
 /** 
- * Copyright (c) 2015 committers of YAKINDU and others. 
+ * Copyright (c) 2016 committers of YAKINDU and others. 
  * All rights reserved. This program and the accompanying materials 
  * are made available under the terms of the Eclipse Public License v1.0 
  * which accompanies this distribution, and is available at 
  * http://www.eclipse.org/legal/epl-v10.html 
  * Contributors:
- * René Beckmann - initial API and implementation
+ * @author René Beckmann (beckmann@itemis.de)
  *
 */
 package org.yakindu.sct.model.sexec.transformation.test;
@@ -25,297 +25,247 @@ import java.util.List;
 
 public class StringTreeNodeTest {
 	private StringTreeNode tree;
-	
+
 	@Before
-	public void setupStringTreeNode()
-	{
+	public void setupStringTreeNode() {
 		tree = new StringTreeNode();
 	}
-	
+
 	@Test
-	public void stringAddTest()
-	{
+	public void stringAddTest() {
 		/*
-		 * Add a few strings where some are substrings of others and check if they all exist in the tree.
+		 * Add a few strings where some are substrings of others and check if
+		 * they all exist in the tree.
 		 */
-		
+
 		List<String> testStrings = new ArrayList<String>();
-		
+
 		testStrings.add("Statechart1");
 		testStrings.add("Statechart2");
 		testStrings.add("Statechart1.Region1");
 		testStrings.add("Statechart1.Region2");
 		testStrings.add("Statechart1.Region1.StateA");
 		testStrings.add("Statechart1.Region2.StateA");
-		
-		for(String s : testStrings)
-		{
+
+		for (String s : testStrings) {
 			tree.addString(s);
 		}
-		
+
 		List<String> treeContents = tree.getContents();
-		
+
 		stringListsEqual(testStrings, treeContents);
 	}
-	
+
 	@Test
-	public void noDoublesTest()
-	{
+	public void noDoublesTest() {
 		// Add the same string twice, expect it to be in the tree only once.
 		tree.addString("DoubleString");
 		tree.addString("DoubleString");
-		
+
 		assertEquals(1, tree.getContents().size());
 	}
-	
+
 	@Test
-	public void compressTest()
-	{
-		// Add data to the tree, compress it, and compare contents before and after compressing.
+	public void compressTest() {
+		// Add data to the tree, compress it, and compare contents before and
+		// after compressing.
 		tree.addString("PartOne");
 		tree.addString("PartTwo");
-		
+
 		List<String> beforeContents = tree.getContents();
-		
+
 		tree.compress();
-		
+
 		List<String> afterContents = tree.getContents();
-		
+
 		stringListsEqual(beforeContents, afterContents);
 	}
-	
+
 	@Test
-	public void compressNodeTest()
-	{
-		// Add data to the tree, compress it, and check if the nodes match the expectation.
+	public void compressNodeTest() {
+		// Add data to the tree, compress it, and check if the nodes match the
+		// expectation.
 		tree.addString("PartOne");
 		tree.addString("PartTwo");
-		
+
 		tree.compress();
-		
+
 		List<StringTreeNode> nodelist = tree.getNodes();
 		List<String> nodecontents = new ArrayList<String>();
 		List<String> expectednodecontents = new ArrayList<String>();
-		
+
 		expectednodecontents.add("Part");
 		expectednodecontents.add("One");
 		expectednodecontents.add("Two");
-		expectednodecontents.add(""); //two end nodes should be present
+		expectednodecontents.add(""); // two end nodes should be present
 		expectednodecontents.add("");
-		
-		for(StringTreeNode node : nodelist)
-		{
-			if(node.getData() != null)
-			{
+
+		for (StringTreeNode node : nodelist) {
+			if (node.getData() != null) {
 				nodecontents.add(node.getData());
 			}
 		}
-		
+
 		stringListsEqual(nodecontents, expectednodecontents);
 	}
-	
+
 	@Test
-	public void hasSiblingsTest()
-	{
-		testSiblings("Sc1Reg1StateA", new ArrayList<String>(
-				Arrays.asList("StateB", "StateC")));
+	public void hasSiblingsTest() {
+		testSiblings("Sc1Reg1StateA", new ArrayList<String>(Arrays.asList("StateB", "StateC")));
 	}
-	
+
 	@Test
-	public void hasNoSiblingsTest()
-	{
+	public void hasNoSiblingsTest() {
 		testSiblings("Sc1Reg2StateA", new ArrayList<String>());
 	}
-	
+
 	@Test
-	public void nodeChainContainedTest()
-	{
+	public void nodeChainContainedTest() {
 		buildStandardTestTree();
 		String testString = new String("Sc1Reg1StateA");
 		List<StringTreeNode> nodes = tree.getNodeChain(testString);
-		
+
 		StringBuilder builder = new StringBuilder();
-		
-		for(StringTreeNode node : nodes)
-		{
+
+		for (StringTreeNode node : nodes) {
 			builder.append(node.getData());
 		}
-		
+
 		assertEquals(testString, builder.toString());
 	}
-	
+
 	@Test
-	public void nodeChainNotContainedTest()
-	{
+	public void nodeChainNotContainedTest() {
 		buildStandardTestTree();
 		String testString = new String("Sc1Reg3StateA");
 		List<StringTreeNode> nodes = tree.getNodeChain(testString);
-		
+
 		assertEquals(nodes, null);
 	}
-	
+
 	@Test
-	public void endNodesTest()
-	{
+	public void endNodesTest() {
 		buildStandardTestTree();
-		tree.addStringList(new ArrayList<String>(
-				Arrays.asList("Sc1", "Reg1")
-		));
-		
+		tree.addStringList(new ArrayList<String>(Arrays.asList("Sc1", "Reg1")));
+
 		assertEquals(6, tree.getEndNodes().size());
 	}
-	
+
 	@Test
-	public void distanceTest()
-	{
+	public void distanceTest() {
 		buildStandardTestTree();
 		List<StringTreeNode> nodes1, nodes2, nodes3, nodes4;
-		StringTreeNode testNode1, testNode2, testNode3, testNode4; 
-		
+		StringTreeNode testNode1, testNode2, testNode3, testNode4;
+
 		nodes1 = tree.getNodeChain("Sc1Reg1StateA");
 		nodes2 = tree.getNodeChain("Sc1Reg1StateB");
 		nodes3 = tree.getNodeChain("Sc1Reg2StateA");
 		nodes4 = tree.getNodeChain("Sc2Reg1StateA");
-		
+
 		testNode1 = nodes1.get(nodes1.size() - 1); // (Sc1Reg1)State A
 		testNode2 = nodes2.get(nodes2.size() - 1); // (Sc1Reg1)State B
 		testNode3 = nodes3.get(nodes3.size() - 1); // (Sc1Reg2)State A
 		testNode4 = nodes4.get(nodes4.size() - 1); // (Sc2Reg1)State A
-		
+
 		assertEquals(2, testNode1.getDistance(testNode2));
 		assertEquals(4, testNode1.getDistance(testNode3));
 		assertEquals(6, testNode1.getDistance(testNode4));
 	}
-	
+
 	@Test
-	public void navigateTest()
-	{
+	public void navigateTest() {
 		buildStandardTestTree();
-		
+
 		StringTreeNode nextnode = tree.navigate("Sc1");
-		
-		assertEquals(true, nextnode!=null);
+
+		assertEquals(true, nextnode != null);
 		assertEquals("Sc1", nextnode.getData());
-		
+
 		nextnode = nextnode.navigate("Reg2");
-		
-		assertEquals(true, nextnode!=null);
+
+		assertEquals(true, nextnode != null);
 		assertEquals("Reg2", nextnode.getData());
-		
+
 		nextnode = nextnode.navigate("StateA");
-		
-		assertEquals(true, nextnode!=null);
+
+		assertEquals(true, nextnode != null);
 		assertEquals("StateA", nextnode.getData());
-		
+
 		nextnode = nextnode.getParent().getParent();
-		
-		assertEquals(true, nextnode!=null);
+
+		assertEquals(true, nextnode != null);
 		assertEquals("Sc1", nextnode.getData());
 	}
-	
+
 	@Test
-	public void childrenContentTest()
-	{
+	public void childrenContentTest() {
 		buildStandardTestTree();
-		
+
 		StringTreeNode nextnode = tree.navigate("Sc1");
-		
+
 		ArrayList<String> expectedChildren = new ArrayList<String>(Arrays.asList("Reg1", "Reg2"));
-		
+
 		stringListsEqual(expectedChildren, nextnode.getChildrenContents());
 	}
-	
+
 	@Test
-	public void deletionTest()
-	{
+	public void deletionTest() {
 		buildStandardTestTree();
-		
+
 		tree.navigate("Sc1").navigate("Reg2").delete();
-		
+
 		ArrayList<String> expectedContents = new ArrayList<String>(
-				Arrays.asList(
-						"Sc1Reg1StateA",
-						"Sc1Reg1StateB",
-						"Sc1Reg1StateC",
-						"Sc2Reg1StateA"
-						));
-		
+				Arrays.asList("Sc1Reg1StateA", "Sc1Reg1StateB", "Sc1Reg1StateC", "Sc2Reg1StateA"));
+
 		stringListsEqual(expectedContents, tree.getContents());
 	}
-	
+
 	@Test
-	public void addStringListReturnTest1()
-	{
-		List<String> list = new ArrayList<String>(
-				Arrays.asList("Un", "Deux", "Trois", "Quatre")
-				);
+	public void addStringListReturnTest1() {
+		List<String> list = new ArrayList<String>(Arrays.asList("Un", "Deux", "Trois", "Quatre"));
 		StringTreeNode testNode = tree.addStringList(list);
-		
+
 		assertEquals("UnDeuxTroisQuatre", testNode.getContentUpwards());
 	}
-	
+
 	@Test
-	public void addStringListReturnTest2()
-	{
-		List<String> list1 = new ArrayList<String>(
-				Arrays.asList("Un", "Deux", "Trois", "Quatre")
-				);
+	public void addStringListReturnTest2() {
+		List<String> list1 = new ArrayList<String>(Arrays.asList("Un", "Deux", "Trois", "Quatre"));
 		List<String> list2 = new ArrayList<String>(list1);
 		list2.add("Cinq");
-		
+
 		tree.addStringList(list2);
-		
+
 		StringTreeNode testNode = tree.addStringList(list1);
-		
+
 		assertEquals("UnDeuxTroisQuatre", testNode.getContentUpwards());
 	}
-	
+
 	@Test
-	public void weightTest()
-	{
+	public void weightTest() {
 		buildStandardTestTree();
-		
+
 		assertEquals(15, tree.getWeight());
 	}
-	
-	private void testSiblings(String testString, List<String> expectedSiblings)
-	{
+
+	private void testSiblings(String testString, List<String> expectedSiblings) {
 		buildStandardTestTree();
 		stringListsEqual(tree.getSiblings(testString), expectedSiblings);
 	}
-	
-	private void buildStandardTestTree()
-	{
+
+	private void buildStandardTestTree() {
 		/*
-		 * 				 StateA
-		 *              /
-		 * root-Sc1-Reg1-StateB
-		 *  \     \     \
-		 *   \     \     StateC
-		 *    \     \
-		 *     \     Reg2-StateA
-		 *      \
-		 *       Sc2-Reg1-StateA
-		 */      
-		tree.addStringList(new ArrayList<String>(
-				Arrays.asList("Sc1", "Reg1", "StateA")
-		));
-		tree.addStringList(new ArrayList<String>(
-				Arrays.asList("Sc1", "Reg1", "StateB")
-		));
-		tree.addStringList(new ArrayList<String>(
-				Arrays.asList("Sc1", "Reg1", "StateC")
-		));
-		tree.addStringList(new ArrayList<String>(
-				Arrays.asList("Sc1", "Reg2", "StateA")
-		));
-		tree.addStringList(new ArrayList<String>(
-				Arrays.asList("Sc2", "Reg1", "StateA")
-		));
+		 * StateA / root-Sc1-Reg1-StateB \ \ \ \ \ StateC \ \ \ Reg2-StateA \
+		 * Sc2-Reg1-StateA
+		 */
+		tree.addStringList(new ArrayList<String>(Arrays.asList("Sc1", "Reg1", "StateA")));
+		tree.addStringList(new ArrayList<String>(Arrays.asList("Sc1", "Reg1", "StateB")));
+		tree.addStringList(new ArrayList<String>(Arrays.asList("Sc1", "Reg1", "StateC")));
+		tree.addStringList(new ArrayList<String>(Arrays.asList("Sc1", "Reg2", "StateA")));
+		tree.addStringList(new ArrayList<String>(Arrays.asList("Sc2", "Reg1", "StateA")));
 	}
-	
-	private void stringListsEqual(List<String> onelist, List<String> otherlist)
-	{
+
+	private void stringListsEqual(List<String> onelist, List<String> otherlist) {
 		java.util.Collections.sort(onelist, Collator.getInstance());
 		java.util.Collections.sort(otherlist, Collator.getInstance());
 		assertEquals(onelist, otherlist);

+ 77 - 123
test-plugins/org.yakindu.sct.model.sexec.test/src/org/yakindu/sct/model/sexec/transformation/test/TreeNamingServiceTest.java

@@ -1,11 +1,11 @@
 /** 
- * Copyright (c) 2015 committers of YAKINDU and others. 
+ * Copyright (c) 2016 committers of YAKINDU and others. 
  * All rights reserved. This program and the accompanying materials 
  * are made available under the terms of the Eclipse Public License v1.0 
  * which accompanies this distribution, and is available at 
  * http://www.eclipse.org/legal/epl-v10.html 
  * Contributors:
- * committers of YAKINDU - initial API and implementation
+ * @author René Beckmann (beckmann@itemis.de)
  *
 */
 package org.yakindu.sct.model.sexec.transformation.test;
@@ -43,8 +43,8 @@ public class TreeNamingServiceTest extends ModelSequencerTest {
 
 	@Inject
 	protected TreeNamingService statechartNamingService;
-	
-	@Inject 
+
+	@Inject
 	protected TreeNamingService executionflowNamingService;
 
 	private List<Statechart> statecharts;
@@ -78,7 +78,7 @@ public class TreeNamingServiceTest extends ModelSequencerTest {
 		}
 		statecharts.remove(statecharttoRemove);
 	}
-	
+
 	@Test
 	public void testDefaultNamingServiceState_NoDoubles() {
 
@@ -87,28 +87,24 @@ public class TreeNamingServiceTest extends ModelSequencerTest {
 			// Transform statechart
 			ExecutionFlow flow = sequencer.transform(statechart);
 			flow = optimizer.transform(flow);
-			
+
 			List<String> names = new ArrayList<String>();
 
-//			statechartNamingService.setMaxLength(0);
-//			statechartNamingService.setSeparator('_');
-			
 			executionflowNamingService.setMaxLength(15);
 			executionflowNamingService.setSeparator('_');
-			
+
 			// Initialize naming services for statechart and ExecutionFlow
-//			statechartNamingService.initializeNamingService(statechart);
 			long t0 = System.currentTimeMillis();
 			executionflowNamingService.initializeNamingService(flow);
 			executionflowNamingService.test_printTreeContents();
-			System.out.print("Time needed for initialization [ms]: "); System.out.println(System.currentTimeMillis() - t0);
+			System.out.print("Time needed for initialization [ms]: ");
+			System.out.println(System.currentTimeMillis() - t0);
 			System.out.println("Generated names:");
-			for(ExecutionState state : flow.getStates())
-			{
+			for (ExecutionState state : flow.getStates()) {
 				String name = executionflowNamingService.getShortName(state);
-				if(names.contains(name)) {
+				if (names.contains(name)) {
 					System.out.println("Conflicting name: " + name);
-					for(String n : names) {
+					for (String n : names) {
 						System.out.println(n);
 					}
 				}
@@ -117,71 +113,52 @@ public class TreeNamingServiceTest extends ModelSequencerTest {
 				System.out.println(name);
 			}
 			System.out.println();
-//			SExecExtensions ext = new SExecExtensions();
-//			for(Step step : ext.getAllFunctions(flow))
-//			{
-//				String name = executionflowNamingService.getShortName(step);
-//				assertEquals(names.contains(name), false);
-//				names.add(name);
-//			}
-				
-			// Check for equality
-			//checkNameEquality(flow, statechartNamingService, flowNamingService);
-//			stringListsEqual(statechartNamingService.getTreeContents(), executionflowNamingService.getTreeContents());
 		}
 	}
-	
+
 	@Test
-	public void nameLengthTest31()
-	{
+	public void nameLengthTest31() {
 		nameLengthTest(31);
 	}
-	
+
 	@Test
-	public void nameLengthTest20()
-	{
+	public void nameLengthTest20() {
 		nameLengthTest(20);
 	}
-	
+
 	@Test
-	public void nameLengthTest15()
-	{
+	public void nameLengthTest15() {
 		nameLengthTest(15);
 	}
-	
+
 	@Test
-	public void nameLengthTest10()
-	{
+	public void nameLengthTest10() {
 		nameLengthTest(10);
 	}
-	
+
 	@Test
-	public void nameLengthTest8()
-	{
+	public void nameLengthTest8() {
 		nameLengthTest(8);
 	}
-	
+
 	@Test
-	public void optimizerCombinationsTest()
-	{
+	public void optimizerCombinationsTest() {
 		Statechart toTest = null;
-		
-		for(Statechart statechart : statecharts)
-		{
-			if(statechart.getName().equals("DeepEntry")) {
+
+		for (Statechart statechart : statecharts) {
+			if (statechart.getName().equals("DeepEntry")) {
 				toTest = statechart;
 			}
 		}
-		
+
 		assertEquals(true, toTest != null);
-		
+
 		ExecutionFlow flow = sequencer.transform(toTest);
-		
+
 		executionflowNamingService.setMaxLength(0);
 		executionflowNamingService.setSeparator('_');
-		
-		for(int i=0; i < (1 << 9); i++)
-		{
+
+		for (int i = 0; i < (1 << 9); i++) {
 			optimizer.inlineReactions((i & (1)) != 0);
 			optimizer.inlineExitActions((i & (1 << 1)) != 0);
 			optimizer.inlineEntryActions((i & (1 << 2)) != 0);
@@ -191,41 +168,33 @@ public class TreeNamingServiceTest extends ModelSequencerTest {
 			optimizer.inlineEntries((i & (1 << 6)) != 0);
 			optimizer.inlineEnterRegion((i & (1 << 7)) != 0);
 			optimizer.inlineExitRegion((i & (1 << 8)) != 0);
-			
+
 			ExecutionFlow optimizedflow = optimizer.transform(flow);
-			
+
 			List<String> names = new ArrayList<String>();
 
 			executionflowNamingService.initializeNamingService(optimizedflow);
-			for(ExecutionState state : flow.getStates())
-			{
+			for (ExecutionState state : flow.getStates()) {
 				String name = executionflowNamingService.getShortName(state);
 				assertEquals(names.contains(name), false);
 				names.add(name);
 			}
 		}
 	}
-	
+
 	@Test
-	public void statechartTest1()
-	{
+	public void statechartTest1() {
 		Statechart toTest = getNamingServiceStatechart();
-		
+
 		List<String> names = new ArrayList<String>();
-		
-		List<String> expectedNames = new ArrayList<String>(Arrays.asList(
-						"main_region_StateA",
-						"main_region_StateB",
-						"second_region_StateA",
-						"third_region_StateA",
-						"second_region_StateA_AnotherRegion_StateA",
-						"second_region_StateA_AnotherRegion_StateB",
-						"third_region_StateA_AnotherRegion_StateA",
-						"third_region_StateA_AnotherRegion_StateB"
-						));
-		
+
+		List<String> expectedNames = new ArrayList<String>(
+				Arrays.asList("main_region_StateA", "main_region_StateB", "second_region_StateA", "third_region_StateA",
+						"second_region_StateA_AnotherRegion_StateA", "second_region_StateA_AnotherRegion_StateB",
+						"third_region_StateA_AnotherRegion_StateA", "third_region_StateA_AnotherRegion_StateB"));
+
 		ExecutionFlow flow = optimizer.transform(sequencer.transform(toTest));
-		
+
 		executionflowNamingService.setMaxLength(0);
 		executionflowNamingService.setSeparator('_');
 		executionflowNamingService.initializeNamingService(flow);
@@ -233,72 +202,59 @@ public class TreeNamingServiceTest extends ModelSequencerTest {
 		statechartNamingService.setMaxLength(0);
 		statechartNamingService.setSeparator('_');
 		statechartNamingService.initializeNamingService(toTest);
-		
-		for(ExecutionState state : flow.getStates())
-		{
+
+		for (ExecutionState state : flow.getStates()) {
 			String name = executionflowNamingService.getShortName(state);
 			assertEquals(names.contains(name), false);
 			assertEquals(name, statechartNamingService.getShortName(state));
 			names.add(name);
 		}
-		
+
 		stringListsEqual(expectedNames, names);
 	}
-	
+
 	@Test
-	public void statechartTest2()
-	{
+	public void statechartTest2() {
 		Statechart toTest = getNamingServiceStatechart();
-		
+
 		List<String> names = new ArrayList<String>();
-		
-		// these names are shorter than 15 characters because there are more elements containing these names, e.g. state actions
-		List<String> expectedNames = new ArrayList<String>(Arrays.asList(
-					"mgn_SA",
-					"mgn_StteB",
-					"s_S",
-					"t_S",
-					"t_S_AR_SA", 
-					"t_S_AR_StB",
-					"s_S_AR_SA", 
-					"s_S_AR_StB"
-						));
-		
+
+		// these names are shorter than 15 characters because there are more
+		// elements containing these names, e.g. state actions
+		List<String> expectedNames = new ArrayList<String>(Arrays.asList("mgn_SA", "mgn_StteB", "s_S", "t_S",
+				"t_S_AR_SA", "t_S_AR_StB", "s_S_AR_SA", "s_S_AR_StB"));
+
 		ExecutionFlow flow = optimizer.transform(sequencer.transform(toTest));
-		
+
 		executionflowNamingService.setMaxLength(15);
 		executionflowNamingService.setSeparator('_');
-		
+
 		executionflowNamingService.initializeNamingService(flow);
-		
-		for(ExecutionState state : flow.getStates())
-		{
+
+		for (ExecutionState state : flow.getStates()) {
 			String name = executionflowNamingService.getShortName(state);
 			assertEquals(names.contains(name), false);
 			names.add(name);
 		}
-		
+
 		stringListsEqual(expectedNames, names);
 	}
-	
-	private Statechart getNamingServiceStatechart()
-	{
+
+	private Statechart getNamingServiceStatechart() {
 		Statechart toTest = null;
-		
-		for(Statechart statechart : statecharts)
-		{
-			if(statechart.getName().equals("namingTest")) {
+
+		for (Statechart statechart : statecharts) {
+			if (statechart.getName().equals("namingTest")) {
 				toTest = statechart;
 			}
 		}
-		
+
 		assertEquals(true, toTest != null);
-		
+
 		return toTest;
 	}
-	
-	private void nameLengthTest(int maxLength)
-	{
+
+	private void nameLengthTest(int maxLength) {
 		int num_statecharts = statecharts.size();
 		long cumulated_time = 0L;
 		for (Statechart statechart : statecharts) {
@@ -306,30 +262,28 @@ public class TreeNamingServiceTest extends ModelSequencerTest {
 			// Transform statechart
 			ExecutionFlow flow = sequencer.transform(statechart);
 			flow = optimizer.transform(flow);
-			
+
 			List<String> names = new ArrayList<String>();
 
 			executionflowNamingService.setMaxLength(maxLength);
 			executionflowNamingService.setSeparator('_');
-			
+
 			long t0 = System.currentTimeMillis();
 			executionflowNamingService.initializeNamingService(flow);
 			cumulated_time += System.currentTimeMillis() - t0;
-			for(ExecutionState state : flow.getStates())
-			{
+			for (ExecutionState state : flow.getStates()) {
 				String name = executionflowNamingService.getShortName(state);
 				assertEquals(names.contains(name), false);
 				assertEquals(true, name.length() <= maxLength);
 				names.add(name);
 			}
 		}
-		
+
 		System.out.print("Average time for initialization [ms]: ");
-		System.out.println((float)cumulated_time / (float)num_statecharts);
+		System.out.println((float) cumulated_time / (float) num_statecharts);
 	}
 
-	private void stringListsEqual(List<String> onelist, List<String> otherlist)
-	{
+	private void stringListsEqual(List<String> onelist, List<String> otherlist) {
 		java.util.Collections.sort(onelist, Collator.getInstance());
 		java.util.Collections.sort(otherlist, Collator.getInstance());
 		assertEquals(onelist, otherlist);

+ 9 - 9
test-plugins/org.yakindu.sct.test.models/src/org/yakindu/sct/test/models/SCTUnitTestModels.java

@@ -28,7 +28,7 @@ public class SCTUnitTestModels extends AbstractTestModelsUtil {
 
 	private static final String TESTMODEL_DIR = "org.yakindu.sct.test.models/testmodels/SCTUnit/";
 	public static final String ALWAYS_ONCYCLE = "AlwaysOncycle.sct";
-	public static final String ASSIGNMENT_AS_EXPRESSION ="AssignmentAsExpression.sct";
+	public static final String ASSIGNMENT_AS_EXPRESSION = "AssignmentAsExpression.sct";
 	public static final String BIT_EXPRESSIONS = "BitExpressions.sct";
 	public static final String BOOLEAN_EXPRESSIONS = "BooleanExpressions.sct";
 	public static final String CAST_EXPRESSIONS = "CastExpressions.sct";
@@ -72,7 +72,7 @@ public class SCTUnitTestModels extends AbstractTestModelsUtil {
 	public static final String SHALLOW_HISTORY = "ShallowHistory.sct";
 	public static final String SIMPLE_EVENT = "SimpleEvent.sct";
 	public static final String SIMPLE_HIERACHY = "SimpleHierachy.sct";
-	public static final String STATECHART_LOCAL_REACTIONS = "StatechartLocalReactions.sct";	
+	public static final String STATECHART_LOCAL_REACTIONS = "StatechartLocalReactions.sct";
 	public static final String STATE_ACTIVE = "StateIsActive.sct";
 	public static final String STATIC_CHOICE = "StaticChoice.sct";
 	public static final String STEXT_KEYWORDS_IN_STATES_AND_REGIONS = "STextKeywordsInStatesAndRegions.sct";
@@ -84,7 +84,7 @@ public class SCTUnitTestModels extends AbstractTestModelsUtil {
 	public static final String TRIFFER_GUARD_EXPRESSIONS = "TriggerGuardExpressions.sct";
 	public static final String TYPE_ALIAS = "TypeAlias.sct";
 	public static final String VALUED_EVENTS = "ValuedEvents.sct";
-	
+
 	@Override
 	public String getModelDirectory() {
 		return TESTMODEL_DIR;
@@ -106,20 +106,20 @@ public class SCTUnitTestModels extends AbstractTestModelsUtil {
 		List<Statechart> all = models.loadAllStatecharts();
 		return Iterables.transform(all, new Function<Statechart, Object[]>() {
 			public Object[] apply(Statechart input) {
-				return new Object[] { input };
+				return new Object[]{input};
 			}
 		});
 	}
-	
+
 	public Statechart loadStatechartByFilename(String requestedStatechart) throws Exception {
-		Statechart result = null;		
+		Statechart result = null;
 		Field[] fields = getClass().getFields();
-		for (Field field : fields) {			
+		for (Field field : fields) {
 			String value = (String) field.get(this);
 			if (value.endsWith(requestedStatechart)) {
-				result  = (loadStatechartFromResource(value));
+				result = (loadStatechartFromResource(value));
 				break;
-			}			
+			}
 		}
 		return result;
 	}