Просмотр исходного кода

[YAKHMI-1104 ] changed back Vertex dispatch in Default Naming service. Added Support for IdFeature in SGen, refactor CNaming Service a bit

malknet42 11 лет назад
Родитель
Сommit
b087f4c305

+ 31 - 28
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/CNamingService.xtend

@@ -31,7 +31,7 @@ public class CNamingService extends DefaultNamingService {
 		this.entry = entry
 	}
 	
-	override Map<NamedElement, String> getShortNameMap(ExecutionFlow flow) {
+	override void initializeNamingService(Statechart statechart) {
 		if (entry.identifierLength != null) {
 			maxLength = entry.identifierLength
 		}
@@ -40,41 +40,44 @@ public class CNamingService extends DefaultNamingService {
 			separator = entry.separator.charAt(0)
 		}
 		
-		return super.getShortNameMap(flow)
+		super.initializeNamingService(statechart)
 	}
 	
-	override void initializeNamingService(Statechart statechart) {
-		if (map == null || activeStatechart != statechart) {
-			activeFlow = null
-			activeStatechart = statechart
-			
-			var Integer lengthSGen			
-			if(entry.identifierLength != null){
-				lengthSGen = entry.identifierLength			
-				super.maxLength =lengthSGen
-			}			
-			
-			map = statechart.createShortNameMap(maxLength, separator)
+	override void initializeNamingService(ExecutionFlow flow) {
+		if (entry.identifierLength != null) {
+			maxLength = entry.identifierLength
 		}
+		
+		if (entry.separator != null) {
+			separator = entry.separator.charAt(0)
+		}
+		
+		super.initializeNamingService(flow)
 	}
 	
-	
-	override void initializeNamingService(ExecutionFlow flow) {
-		if (map == null || activeFlow != flow) {
-			activeFlow = flow
-			activeStatechart = null
-			
-			var Integer lengthSGen			
-			if(entry.identifierLength != null){
-				lengthSGen = entry.identifierLength			
-				super.maxLength =lengthSGen
-			}	
-			
-			map = flow.createShortNameMap(maxLength, separator)
+	override Map<NamedElement, String> getShortNameMap(ExecutionFlow flow) {
+		if (entry.identifierLength != null) {
+			maxLength = entry.identifierLength
 		}
+		
+		if (entry.separator != null) {
+			separator = entry.separator.charAt(0)
+		}
+		
+		return super.getShortNameMap(flow)
 	}
 	
-	
+	override Map<NamedElement, String> getShortNameMap(Statechart statechart) {
+		if (entry.identifierLength != null) {
+			maxLength = entry.identifierLength
+		}
+		
+		if (entry.separator != null) {
+			separator = entry.separator.charAt(0)
+		}
+		
+		return super.getShortNameMap(statechart)
+	}
 	
 	override protected prefix(Step it, char separator) {
 		var prefix = flow.name.toFirstLower

+ 14 - 14
plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/naming/DefaultNamingService.xtend

@@ -335,13 +335,13 @@ class DefaultNamingService implements INamingService {
 		}
 	}
 
-//	def protected dispatch String elementName(Vertex it, NameShorteningStrategy nameShorteningType) {
-//		switch nameShorteningType {
-//			case NameShorteningStrategy::STANDARD: return name
-//			case NameShorteningStrategy::REMOVE_VOWELS: return name.removeVowels
-//			case NameShorteningStrategy::INDEX_POSITION: return asSGraphIndexPosition
-//		}
-//	}
+	def protected dispatch String elementName(Vertex it, NameShorteningStrategy nameShorteningType) {
+		switch nameShorteningType {
+			case NameShorteningStrategy::STANDARD: return name
+			case NameShorteningStrategy::REMOVE_VOWELS: return name.removeVowels
+			case NameShorteningStrategy::INDEX_POSITION: return asSGraphIndexPosition
+		}
+	}
 
 	def protected dispatch String elementName(ExecutionNode it, NameShorteningStrategy nameShorteningType) {
 		simpleName
@@ -375,13 +375,13 @@ class DefaultNamingService implements INamingService {
 		superScope.subScopes.indexOf(it).toString;
 	}
 	
-//	def protected dispatch asSGraphIndexPosition(Vertex it) {
-//		parentRegion.vertices.toList.indexOf(it).toString
-//	}
-//	
-//	def protected dispatch asSGraphIndexPosition(State it) {
-//		parentRegion.vertices.filter(typeof(State)).toList.indexOf(it).toString
-//	}
+	def protected dispatch asSGraphIndexPosition(Vertex it) {
+		parentRegion.vertices.toList.indexOf(it).toString
+	}
+	
+	def protected dispatch asSGraphIndexPosition(State it) {
+		parentRegion.vertices.filter(typeof(State)).toList.indexOf(it).toString
+	}
 
 	def protected removeVowels(String it) {
 		replaceAll('[aeiou]', '')

+ 0 - 2
test-plugins/org.yakindu.sct.generator.c.test/gtests/StringExpressions/StringExpressions.sgen

@@ -5,8 +5,6 @@ GeneratorModel for yakindu::c {
 			targetFolder = "StringExpressions"
 		}
 		feature IdentifierSettings {
-			moduleName =  "StringExpressions" 
-			statemachinePrefix =  "stringExpressions" 
 			maxIdentifierLength = 254
 			separator =  "_" 
 		}

+ 0 - 2
test-plugins/org.yakindu.sct.generator.c.test/model/test.sgen

@@ -529,8 +529,6 @@ GeneratorModel for sctunit::c {
 		}
 
 		feature IdentifierSettings {
-			moduleName =  "StringExpressions" 
-			statemachinePrefix =  "stringExpressions" 
 			maxIdentifierLength = 254
 			separator =  "_" 
 		}		

+ 16 - 16
test-plugins/org.yakindu.sct.generator.cpp.test/gtests/STextKeywordsInStatesAndRegionsTest/STextKeywordsInStatesAndRegionsTest.cc

@@ -131,7 +131,7 @@ TEST(StatemachineTest, activeCheckWithSTextNamedStates) {
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::local));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::out));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::readonly));
-	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::operation));
+	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::internal_operation));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::default_ID));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::entry));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::always));
@@ -153,7 +153,7 @@ TEST(StatemachineTest, activeCheckWithSTextNamedStates) {
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::local));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::out));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::readonly));
-	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::operation));
+	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::internal_operation));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::else_ID));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::entry));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::always));
@@ -175,7 +175,7 @@ TEST(StatemachineTest, activeCheckWithSTextNamedStates) {
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::local));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::out));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::readonly));
-	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::operation));
+	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::internal_operation));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::else_ID));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::exit_ID));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::always));
@@ -197,7 +197,7 @@ TEST(StatemachineTest, activeCheckWithSTextNamedStates) {
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::local));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::out));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::readonly));
-	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::operation));
+	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::internal_operation));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::else_ID));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::exit_ID));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::oncycle));
@@ -219,7 +219,7 @@ TEST(StatemachineTest, activeCheckWithSTextNamedStates) {
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::local));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::out));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::readonly));
-	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::operation));
+	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::internal_operation));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::else_ID));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::exit_ID));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::oncycle));
@@ -241,7 +241,7 @@ TEST(StatemachineTest, activeCheckWithSTextNamedStates) {
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::local));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::out));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::readonly));
-	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::operation));
+	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::internal_operation));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::else_ID));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::exit_ID));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::oncycle));
@@ -263,7 +263,7 @@ TEST(StatemachineTest, activeCheckWithSTextNamedStates) {
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::local));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::out));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::readonly));
-	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::operation));
+	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::internal_operation));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::else_ID));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::exit_ID));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::oncycle));
@@ -285,7 +285,7 @@ TEST(StatemachineTest, activeCheckWithSTextNamedStates) {
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::local));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::out));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::readonly));
-	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::operation));
+	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::internal_operation));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::else_ID));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::exit_ID));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::oncycle));
@@ -307,7 +307,7 @@ TEST(StatemachineTest, activeCheckWithSTextNamedStates) {
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::local));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::out));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::readonly));
-	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::operation));
+	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::internal_operation));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::else_ID));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::exit_ID));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::oncycle));
@@ -329,7 +329,7 @@ TEST(StatemachineTest, activeCheckWithSTextNamedStates) {
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::local));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::out));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::readonly));
-	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::operation));
+	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::internal_operation));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::else_ID));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::exit_ID));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::oncycle));
@@ -351,7 +351,7 @@ TEST(StatemachineTest, activeCheckWithSTextNamedStates) {
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::local));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::out));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::readonly));
-	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::operation));
+	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::internal_operation));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::else_ID));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::exit_ID));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::oncycle));
@@ -373,7 +373,7 @@ TEST(StatemachineTest, activeCheckWithSTextNamedStates) {
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::local));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::out));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::readonly));
-	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::operation));
+	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::internal_operation));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::else_ID));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::exit_ID));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::oncycle));
@@ -395,7 +395,7 @@ TEST(StatemachineTest, activeCheckWithSTextNamedStates) {
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::local));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::out));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::readonly));
-	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::operation));
+	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::internal_operation));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::else_ID));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::exit_ID));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::oncycle));
@@ -417,7 +417,7 @@ TEST(StatemachineTest, activeCheckWithSTextNamedStates) {
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::local));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::out));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::readonly));
-	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::operation));
+	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::internal_operation));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::else_ID));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::exit_ID));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::oncycle));
@@ -439,7 +439,7 @@ TEST(StatemachineTest, activeCheckWithSTextNamedStates) {
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::local));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::out));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::readonly));
-	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::operation));
+	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::internal_operation));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::else_ID));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::exit_ID));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::oncycle));
@@ -461,7 +461,7 @@ TEST(StatemachineTest, activeCheckWithSTextNamedStates) {
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::local));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::out));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::readonly));
-	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::operation));
+	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::internal_operation));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::else_ID));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::exit_ID));
 	EXPECT_TRUE(statechart->isActive(STextKeywordsInStatesAndRegions::oncycle));