Browse Source

Replace private with protected, == with === where needed

René Beckmann 7 years ago
parent
commit
4ccec00721

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

@@ -17,10 +17,10 @@ class ShortString {
 	/*
 	 * Class that manages a string and shortened versions of it.
 	 */
-	private String originalString;
+	protected String originalString;
 
-	private int[] cutArray; // holds information if char is cut or not
-	private int[] previous_cutArray; // holds previous state for rollback / undo possibility
+	protected int[] cutArray; // holds information if char is cut or not
+	protected 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;
@@ -30,7 +30,7 @@ class ShortString {
 	final static public int COST_FIRSTLETTER = 10;
 
 	new(String s) {
-		if (s == null) {
+		if (s === null) {
 			originalString = "";
 		} else {
 			originalString = s;
@@ -45,7 +45,7 @@ class ShortString {
 		originalString
 	}
 
-	def private int size() {
+	def protected int size() {
 		// instead of saving originalString.length as an own member
 		originalString.length
 	}
@@ -58,7 +58,7 @@ class ShortString {
 		}
 	}
 
-	def private saveCurrentToPrevious() {
+	def protected saveCurrentToPrevious() {
 		// save current cut-state to previous_cutArray.
 		for (var i = 0; i < size; i++) {
 			previous_cutArray.set(i, cutArray.get(i));
@@ -171,12 +171,12 @@ class ShortString {
 		}
 	}
 
-	def private boolean isLowercaseVocal(int i) {
+	def protected boolean isLowercaseVocal(int i) {
 		var c = originalString.charAt(i);
 		return isLowercaseVocal(c);
 	}
 
-	def private boolean isLowercaseVocal(char c) {
+	def protected boolean isLowercaseVocal(char c) {
 		val s = c.toString();
 		return (s == "a" || s == "e" || s == "i" || s == "o" || s == "u");
 	}

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

@@ -149,7 +149,7 @@ class StringTreeNode {
 
 	def public int getDepth() {
 		// Upwards recursion to get distance from root
-		if (parent == null) {
+		if (parent === null) {
 			return 0;
 		} else {
 			return parent.getDepth() + 1;
@@ -275,7 +275,7 @@ class StringTreeNode {
 			}
 		}
 
-		if (maxEqualNode == null) {
+		if (maxEqualNode === null) {
 			return null;
 		}
 
@@ -285,7 +285,7 @@ class StringTreeNode {
 
 		val childrenNodeChain = maxEqualNode.getNodeChain(rest);
 
-		if (childrenNodeChain == null) {
+		if (childrenNodeChain === null) {
 			return null;
 		}
 
@@ -443,7 +443,7 @@ class StringTreeNode {
 	}
 
 	def public boolean isRoot() {
-		return this.parent == null;
+		return this.parent === null;
 	}
 
 	def public boolean isEnd() {

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

@@ -44,10 +44,10 @@ class TreeNamingService implements INamingService {
 
 	@Inject extension ElementNameProvider
 
-	@Inject private StringTreeNodeDepthComparator stringTreeNodeDepthComparator
+	@Inject protected 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]*";
+	protected static final String VALID_IDENTIFIER_REGEX = "[_a-zA-Z][_a-zA-Z0-9]*";
 
 	var protected int maxLength = 0;
 
@@ -91,7 +91,7 @@ class TreeNamingService implements INamingService {
 	}
 
 	override initializeNamingService(Statechart statechart) {
-		if (tree == null || activeStatechart != statechart) {
+		if (tree === null || activeStatechart != statechart) {
 			map = Maps.newHashMap
 			treeMap = Maps.newHashMap
 			shortNamesValid = false;
@@ -107,7 +107,7 @@ class TreeNamingService implements INamingService {
 		}
 	}
 
-	def private void createNameTree(Statechart statechart) {
+	def protected void createNameTree(Statechart statechart) {
 		tree = new StringTreeNode();
 
 		addShortVertexNames(statechart);
@@ -135,7 +135,7 @@ class TreeNamingService implements INamingService {
 	}
 
 	override initializeNamingService(ExecutionFlow flow) {
-		if (tree == null || activeFlow != flow) {
+		if (tree === null || activeFlow != flow) {
 			map = Maps.newHashMap
 			treeMap = Maps.newHashMap
 			shortNamesValid = false;
@@ -151,7 +151,7 @@ class TreeNamingService implements INamingService {
 		}
 	}
 
-	def private void createNameTree(ExecutionFlow flow) {
+	def protected void createNameTree(ExecutionFlow flow) {
 		// Initialize tree
 		tree = new StringTreeNode();
 
@@ -197,13 +197,13 @@ class TreeNamingService implements INamingService {
 		for (tes : timeEventSpecs) {
 			val timeEvent = executionFlowElement.flow.getTimeEvent(sgraphElement.fullyQualifiedName + "_time_event_" +
 				timeEventSpecs.indexOf(tes))
-			if (timeEvent != null) {
+			if (timeEvent !== null) {
 				addElement(executionFlowElement, prefix(tes, sgraphElement), suffix(tes, sgraphElement));
 			}
 		}
 	}
 
-	def private void addElement(NamedElement elem, List<String> prefix, List<String> suffix) {
+	def protected 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);
@@ -275,7 +275,7 @@ class TreeNamingService implements INamingService {
 		return name;
 	}
 
-	def private Map<StringTreeNode, ArrayList<StringTreeNode>> constructIndividualNames() {
+	def protected Map<StringTreeNode, ArrayList<StringTreeNode>> constructIndividualNames() {
 		/*
 		 * 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.
@@ -378,8 +378,8 @@ class TreeNamingService implements INamingService {
 		return mapping;
 	}
 
-	def private shortenNames() {
-		if (individualMap == null || individualMap.isEmpty()) {
+	def protected shortenNames() {
+		if (individualMap === null || individualMap.isEmpty()) {
 			constructIndividualNames();
 		}
 		if (this.maxLength == 0) {
@@ -394,7 +394,7 @@ class TreeNamingService implements INamingService {
 		shortNamesValid = true;
 	}
 
-	def private boolean shortenOneCharacter(ArrayList<StringTreeNode> endnodes, int max_weight) {
+	def protected 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.
@@ -458,14 +458,14 @@ class TreeNamingService implements INamingService {
 			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 protected Map<StringTreeNode, ShortString> createShortStringMapping() {
 		val HashMap<StringTreeNode, ShortString> mapping = newHashMap;
 		for (node : tree.getNodes()) {
 			mapping.put(
@@ -477,29 +477,29 @@ class TreeNamingService implements INamingService {
 		return mapping;
 	}
 
-	def private StringTreeNode getNodeForElement(NamedElement elem) {
+	def protected StringTreeNode getNodeForElement(NamedElement elem) {
 		return treeMap.get(elem);
 	}
 
-	def private ShortString getShortStringForNode(StringTreeNode node) {
-		if (node_shortString_map == null || node_shortString_map.isEmpty()) {
+	def protected 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) {
+	def protected ArrayList<StringTreeNode> getIndividualName(StringTreeNode node) {
 		if (individualMap.isEmpty()) {
 			constructIndividualNames();
 		}
 		return individualMap.get(node);
 	}
 
-	def private getShortenedName(StringTreeNode node) {
+	def protected getShortenedName(StringTreeNode node) {
 		return joinShortStrings(getIndividualName(node));
 	}
 
-	def private getShortenedName(NamedElement elem) {
+	def protected getShortenedName(NamedElement elem) {
 		return getShortenedName(getNodeForElement(elem));
 	}
 
@@ -527,7 +527,7 @@ class TreeNamingService implements INamingService {
 		return tree.getContents();
 	}
 
-	def private List<NamedElement> getNodeElements(StringTreeNode node) {
+	def protected List<NamedElement> getNodeElements(StringTreeNode node) {
 		val ArrayList<NamedElement> list = new ArrayList<NamedElement>();
 
 		for (elem : treeMap.keySet()) {
@@ -539,7 +539,7 @@ class TreeNamingService implements INamingService {
 		return list;
 	}
 
-	def private String joinShortStrings(ArrayList list) {
+	def protected String joinShortStrings(ArrayList<?> list) {
 		val sb = new StringBuilder();
 		var first = true;