Browse Source

Remove C# Navigation extension in favor of SExecExtensions (#2075)

Rene Beckmann 7 years ago
parent
commit
1857b18a74

+ 6 - 5
plugins/org.yakindu.sct.generator.csharp/src/org/yakindu/sct/generator/csharp/CSharpExpressionsGenerator.xtend

@@ -27,6 +27,7 @@ import org.yakindu.base.types.typesystem.GenericTypeSystem
 import org.yakindu.base.types.typesystem.ITypeSystem
 import org.yakindu.sct.generator.core.templates.ExpressionsGenerator
 import org.yakindu.sct.model.sexec.TimeEvent
+import org.yakindu.sct.model.sexec.extensions.SExecExtensions
 import org.yakindu.sct.model.stext.stext.ActiveStateReferenceExpression
 import org.yakindu.sct.model.stext.stext.EventRaisingExpression
 import org.yakindu.sct.model.stext.stext.EventValueReferenceExpression
@@ -35,7 +36,7 @@ import org.yakindu.sct.model.stext.stext.OperationDefinition
 class CSharpExpressionsGenerator extends ExpressionsGenerator {
 
 	@Inject protected extension Naming
-	@Inject protected extension Navigation
+	@Inject protected extension SExecExtensions
 	@Inject protected extension ITypeSystem
 	@Inject protected extension ITypeSystemInferrer
 
@@ -118,14 +119,14 @@ class CSharpExpressionsGenerator extends ExpressionsGenerator {
 			return getConstContext(it)
 		}
 		if (scope !== null) {
-			return scope.interfaceName.asEscapedIdentifier + "."
+			return interfaceScope.interfaceName.asEscapedIdentifier + "."
 		}
 		return ""
 	}
 
 	def getConstContext(Property it) {
 		if (scope !== null) {
-			return scope.interfaceName + "."
+			return interfaceScope.interfaceName + "."
 		} else {
 			return it.flow.statemachineInterfaceName + "."
 		}
@@ -133,14 +134,14 @@ class CSharpExpressionsGenerator extends ExpressionsGenerator {
 
 	def dispatch CharSequence getContext(Event it) {
 		if (scope !== null) {
-			return scope.interfaceName.asEscapedIdentifier + "."
+			return interfaceScope.interfaceName.asEscapedIdentifier + "."
 		}
 		return ""
 	}
 
 	def dispatch CharSequence getContext(OperationDefinition it) {
 		if (scope !== null) {
-			return scope.interfaceName.asEscapedIdentifier + "."
+			return interfaceScope.interfaceName.asEscapedIdentifier + "."
 		}
 		return ""
 	}

+ 2 - 1
plugins/org.yakindu.sct.generator.csharp/src/org/yakindu/sct/generator/csharp/CSharpGenerator.xtend

@@ -14,6 +14,7 @@ import org.eclipse.xtext.generator.IFileSystemAccess
 import org.yakindu.sct.generator.core.IExecutionFlowGenerator
 import org.yakindu.sct.model.sexec.ExecutionFlow
 import org.yakindu.sct.model.sgen.GeneratorEntry
+import org.yakindu.sct.model.sexec.extensions.SExecExtensions
 
 /**
  * This is the C# code generators main class. 
@@ -26,7 +27,7 @@ class CSharpGenerator implements IExecutionFlowGenerator {
 	@Inject extension GenmodelEntries
 	@Inject extension RunnableFeature
 
-	@Inject extension Navigation
+	@Inject extension SExecExtensions
 	@Inject extension IStatemachine
 	@Inject extension ITimerCallback
 	@Inject extension ITimer

+ 0 - 100
plugins/org.yakindu.sct.generator.csharp/src/org/yakindu/sct/generator/csharp/Navigation.xtend

@@ -1,100 +0,0 @@
-/**
-  Copyright (c) 2012 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:
-  	Commiters of Yakindu - Initial contribution and API
- */
-package org.yakindu.sct.generator.csharp
-
-import java.util.ArrayList
-import java.util.List
-import org.yakindu.base.types.Event
-import org.yakindu.base.types.Property
-import org.yakindu.sct.model.sexec.ExecutionFlow
-import org.yakindu.sct.model.sexec.extensions.SExecExtensions
-import org.yakindu.sct.model.sgraph.Scope
-import org.yakindu.sct.model.stext.stext.EventDefinition
-import org.yakindu.sct.model.stext.stext.InterfaceScope
-import org.yakindu.sct.model.stext.stext.InternalScope
-import org.yakindu.sct.model.stext.stext.OperationDefinition
-import org.yakindu.sct.model.stext.stext.VariableDefinition
-
-class Navigation extends SExecExtensions {
-	
-	
-	def List<EventDefinition> getOutgoingEvents(ExecutionFlow flow) {
-		val events = new ArrayList<EventDefinition>()
-		for (scope: flow.scopes) {
-			events.addAll(scope.outgoingEvents)
-		}
-		return events
-	}
-	
-	def boolean hasOutgoingEvents(ExecutionFlow it) {
-		return !outgoingEvents.empty
-	}
-	
-	def getInternalScopeEvents(ExecutionFlow flow) {
-		val events = new ArrayList<EventDefinition>
-		flow.internalScopes.forEach[events.addAll(eventDefinitions)]
-		return events
-	}
-	
-	def getInternalScopeVariables(ExecutionFlow flow) {
-		val variables = new ArrayList<VariableDefinition>
-		flow.internalScopes.forEach[variables.addAll(variableDefinitions)]
-		return variables
-	}
-	
-	
-	def getDefaultScope(ExecutionFlow it) {
-		interfaceScopes.filter[name === null || name.empty].head
-	}
-	
-	def Iterable<InternalScope> getInternalScopes(ExecutionFlow it) {
-		return scopes.filter(typeof(InternalScope))
-	}
-	
-	def boolean hasEvents(Scope it) {
-		return !eventDefinitions.empty
-	}
-	
-	def getEventDefinitions(Scope scope) {
-		scope.declarations.filter(typeof(EventDefinition))
-	}
-	
-	def getOperations(Scope it) {
-		declarations.filter(typeof(OperationDefinition));
-	}
-	
-	def hasOperations(Scope it) {
-		!operations.isEmpty;
-	}
-	
-	
-	def dispatch scope(Property it) {
-		if (eContainer instanceof InterfaceScope)
-			eContainer as InterfaceScope
-		else
-			null
-	}
-	
-	def dispatch scope(Event it) {
-		if (eContainer instanceof InterfaceScope)
-			eContainer as InterfaceScope
-		else
-			null
-	}
-	
-	def dispatch scope(OperationDefinition it) {
-		if (eContainer instanceof InterfaceScope)
-			eContainer as InterfaceScope
-		else
-			null
-	}
-	
-	
-}

+ 2 - 1
plugins/org.yakindu.sct.generator.csharp/src/org/yakindu/sct/generator/csharp/RunnableWrapper.xtend

@@ -17,6 +17,7 @@ import org.yakindu.base.types.typesystem.GenericTypeSystem
 import org.yakindu.base.types.typesystem.ITypeSystem
 import org.yakindu.sct.generator.core.types.ICodegenTypeSystemAccess
 import org.yakindu.sct.model.sexec.ExecutionFlow
+import org.yakindu.sct.model.sexec.extensions.SExecExtensions
 import org.yakindu.sct.model.sgen.GeneratorEntry
 import org.yakindu.sct.model.stext.stext.InterfaceScope
 
@@ -29,7 +30,7 @@ class RunnableWrapper {
 	@Inject protected extension RunnableFeature
 
 	@Inject protected extension Naming
-	@Inject protected extension Navigation
+	@Inject protected extension SExecExtensions
 	@Inject protected extension ITypeSystem
 	@Inject protected extension ICodegenTypeSystemAccess
 	

+ 2 - 1
plugins/org.yakindu.sct.generator.csharp/src/org/yakindu/sct/generator/csharp/Statemachine.xtend

@@ -20,6 +20,7 @@ import org.yakindu.sct.generator.core.types.ICodegenTypeSystemAccess
 import org.yakindu.sct.model.sexec.Check
 import org.yakindu.sct.model.sexec.ExecutionFlow
 import org.yakindu.sct.model.sexec.Step
+import org.yakindu.sct.model.sexec.extensions.SExecExtensions
 import org.yakindu.sct.model.sexec.extensions.StateVectorExtensions
 import org.yakindu.sct.model.sgen.GeneratorEntry
 import org.yakindu.sct.model.stext.stext.EventDefinition
@@ -32,7 +33,7 @@ class Statemachine {
 	
 	@Inject protected extension Naming
 	@Inject protected extension GenmodelEntries
-	@Inject protected extension Navigation
+	@Inject protected extension SExecExtensions
 	@Inject protected extension ICodegenTypeSystemAccess
 	@Inject protected extension ITypeSystem
 	@Inject protected extension FlowCode

+ 2 - 1
plugins/org.yakindu.sct.generator.csharp/src/org/yakindu/sct/generator/csharp/StatemachineInterface.xtend

@@ -17,6 +17,7 @@ import org.yakindu.base.types.typesystem.GenericTypeSystem
 import org.yakindu.base.types.typesystem.ITypeSystem
 import org.yakindu.sct.generator.core.types.ICodegenTypeSystemAccess
 import org.yakindu.sct.model.sexec.ExecutionFlow
+import org.yakindu.sct.model.sexec.extensions.SExecExtensions
 import org.yakindu.sct.model.sgen.GeneratorEntry
 import org.yakindu.sct.model.sgraph.Scope
 import org.yakindu.sct.model.stext.stext.InterfaceScope
@@ -28,7 +29,7 @@ class StatemachineInterface {
 
 	@Inject extension Naming
 	@Inject extension GenmodelEntries
-	@Inject extension Navigation
+	@Inject extension SExecExtensions
 	@Inject extension ITypeSystem
 	@Inject extension ICodegenTypeSystemAccess
 	@Inject extension CSharpExpressionsGenerator

+ 4 - 4
plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/extensions/SExecExtensions.xtend

@@ -154,7 +154,7 @@ class SExecExtensions {
 	}
 	
 	def getEventDefinitions(Scope scope) {
-		scope.declarations.filter(typeof(EventDefinition))
+		scope.declarations.filter(EventDefinition)
 	}
 	
 	def boolean hasEvents(Scope it) {
@@ -210,11 +210,11 @@ class SExecExtensions {
 	}
 	
 	def getInterfaceScopes(ExecutionFlow it) {
-		scopes.filter(typeof(InterfaceScope))
+		scopes.filter(InterfaceScope)
 	}
 	
 	def Iterable<InternalScope> getInternalScopes(ExecutionFlow it) {
-		return scopes.filter(typeof(InternalScope))
+		return scopes.filter(InternalScope)
 	}
 	
 	def getDefaultScope(ExecutionFlow it) {
@@ -222,7 +222,7 @@ class SExecExtensions {
 	}
 	
 	def getVariableDefinitions(Scope it) {
-		declarations.filter(typeof(VariableDefinition))
+		declarations.filter(VariableDefinition)
 	} 
 	
 	def dispatch definition(ElementReferenceExpression it) {