Explorar o código

Refactoring of ISTextTypeSystem and ISTextTypeInferrer

Andreas Mülder %!s(int64=11) %!d(string=hai) anos
pai
achega
f18a689c4f
Modificáronse 23 ficheiros con 224 adicións e 1014 borrados
  1. BIN=BIN
      plugins/org.yakindu.sct.model.stext.edit/icons/full/ctool16/CreateImportScope_imports_Import.gif
  2. BIN=BIN
      plugins/org.yakindu.sct.model.stext.edit/icons/full/ctool16/CreateStateSpecification_scope_ImportScope.gif
  3. BIN=BIN
      plugins/org.yakindu.sct.model.stext.edit/icons/full/ctool16/CreateStatechartSpecification_imports_Import.gif
  4. BIN=BIN
      plugins/org.yakindu.sct.model.stext.edit/icons/full/obj16/Import.gif
  5. BIN=BIN
      plugins/org.yakindu.sct.model.stext.edit/icons/full/obj16/ImportScope.gif
  6. 5 0
      plugins/org.yakindu.sct.model.stext.edit/plugin.properties
  7. 24 0
      plugins/org.yakindu.sct.model.stext.edit/src/org/yakindu/sct/model/stext/stext/provider/EventDefinitionItemProvider.java
  8. 24 0
      plugins/org.yakindu.sct.model.stext.edit/src/org/yakindu/sct/model/stext/stext/provider/OperationDefinitionItemProvider.java
  9. 50 0
      plugins/org.yakindu.sct.model.stext.edit/src/org/yakindu/sct/model/stext/stext/provider/StatechartSpecificationItemProvider.java
  10. 24 0
      plugins/org.yakindu.sct.model.stext.edit/src/org/yakindu/sct/model/stext/stext/provider/VariableDefinitionItemProvider.java
  11. 2 1
      plugins/org.yakindu.sct.model.stext/META-INF/MANIFEST.MF
  12. 5 1
      plugins/org.yakindu.sct.model.stext/model/SText.ecore
  13. 3 1
      plugins/org.yakindu.sct.model.stext/model/SText.genmodel
  14. 0 0
      plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/GenerateSText.mwe2
  15. 18 3
      plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/SText.xtext
  16. 2 2
      plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/STextRuntimeModule.java
  17. 1 1
      plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/scoping/STextGlobalScopeProvider.java
  18. 31 34
      plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/scoping/STextScopeProvider.java
  19. 3 9
      plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/types/ISTextTypeInferrer.java
  20. 0 136
      plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/types/ISTextTypeSystem.java
  21. 28 274
      plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/types/STextDefaultTypeInferrer.xtend
  22. 0 546
      plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/types/STextDefaultTypeSystem.java
  23. 4 6
      plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/validation/STextJavaValidator.java

BIN=BIN
plugins/org.yakindu.sct.model.stext.edit/icons/full/ctool16/CreateImportScope_imports_Import.gif


BIN=BIN
plugins/org.yakindu.sct.model.stext.edit/icons/full/ctool16/CreateStateSpecification_scope_ImportScope.gif


BIN=BIN
plugins/org.yakindu.sct.model.stext.edit/icons/full/ctool16/CreateStatechartSpecification_imports_Import.gif


BIN=BIN
plugins/org.yakindu.sct.model.stext.edit/icons/full/obj16/Import.gif


BIN=BIN
plugins/org.yakindu.sct.model.stext.edit/icons/full/obj16/ImportScope.gif


+ 5 - 0
plugins/org.yakindu.sct.model.stext.edit/plugin.properties

@@ -234,3 +234,8 @@ _UI_GuardExpression_type = Guard Expression
 _UI_Guard_type = Guard
 _UI_Guard_expression_feature = Expression
 _UI_ReactionTrigger_guard_feature = Guard
+_UI_Import_type = Import
+_UI_StatechartSpecification_imports_feature = Imports
+_UI_Import_importedNamespace_feature = Imported Namespace
+_UI_ImportScope_type = Import Scope
+_UI_ImportScope_imports_feature = Imports

+ 24 - 0
plugins/org.yakindu.sct.model.stext.edit/src/org/yakindu/sct/model/stext/stext/provider/EventDefinitionItemProvider.java

@@ -68,6 +68,7 @@ public class EventDefinitionItemProvider
       super.getPropertyDescriptors(object);
 
       addTypePropertyDescriptor(object);
+      addTypeArgumentsPropertyDescriptor(object);
       addDirectionPropertyDescriptor(object);
     }
     return itemPropertyDescriptors;
@@ -96,6 +97,29 @@ public class EventDefinitionItemProvider
          null));
   }
 
+  /**
+   * This adds a property descriptor for the Type Arguments feature.
+   * <!-- begin-user-doc -->
+   * <!-- end-user-doc -->
+   * @generated
+   */
+  protected void addTypeArgumentsPropertyDescriptor(Object object)
+  {
+    itemPropertyDescriptors.add
+      (createItemPropertyDescriptor
+        (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
+         getResourceLocator(),
+         getString("_UI_TypedElement_typeArguments_feature"),
+         getString("_UI_PropertyDescriptor_description", "_UI_TypedElement_typeArguments_feature", "_UI_TypedElement_type"),
+         TypesPackage.Literals.TYPED_ELEMENT__TYPE_ARGUMENTS,
+         true,
+         false,
+         true,
+         null,
+         null,
+         null));
+  }
+
   /**
    * This adds a property descriptor for the Direction feature.
    * <!-- begin-user-doc -->

+ 24 - 0
plugins/org.yakindu.sct.model.stext.edit/src/org/yakindu/sct/model/stext/stext/provider/OperationDefinitionItemProvider.java

@@ -70,6 +70,7 @@ public class OperationDefinitionItemProvider
       super.getPropertyDescriptors(object);
 
       addTypePropertyDescriptor(object);
+      addTypeArgumentsPropertyDescriptor(object);
     }
     return itemPropertyDescriptors;
   }
@@ -97,6 +98,29 @@ public class OperationDefinitionItemProvider
          null));
   }
 
+  /**
+   * This adds a property descriptor for the Type Arguments feature.
+   * <!-- begin-user-doc -->
+   * <!-- end-user-doc -->
+   * @generated
+   */
+  protected void addTypeArgumentsPropertyDescriptor(Object object)
+  {
+    itemPropertyDescriptors.add
+      (createItemPropertyDescriptor
+        (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
+         getResourceLocator(),
+         getString("_UI_TypedElement_typeArguments_feature"),
+         getString("_UI_PropertyDescriptor_description", "_UI_TypedElement_typeArguments_feature", "_UI_TypedElement_type"),
+         TypesPackage.Literals.TYPED_ELEMENT__TYPE_ARGUMENTS,
+         true,
+         false,
+         true,
+         null,
+         null,
+         null));
+  }
+
   /**
    * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
    * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or

+ 50 - 0
plugins/org.yakindu.sct.model.stext.edit/src/org/yakindu/sct/model/stext/stext/provider/StatechartSpecificationItemProvider.java

@@ -11,19 +11,24 @@ import org.eclipse.emf.common.notify.Notification;
 
 import org.eclipse.emf.common.util.ResourceLocator;
 
+import org.eclipse.emf.ecore.EStructuralFeature;
+
 import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
 import org.eclipse.emf.edit.provider.IItemLabelProvider;
 import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
 import org.eclipse.emf.edit.provider.IItemPropertySource;
 import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
 import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
+import org.eclipse.emf.edit.provider.ViewerNotification;
 
+import org.yakindu.sct.model.sgraph.SGraphFactory;
 import org.yakindu.sct.model.sgraph.SGraphPackage;
 
 import org.yakindu.sct.model.sgraph.provider.ScopedElementItemProvider;
 
 import org.yakindu.sct.model.stext.stext.StatechartSpecification;
 import org.yakindu.sct.model.stext.stext.StextFactory;
+import org.yakindu.sct.model.stext.stext.StextPackage;
 
 /**
  * This is the item provider adapter for a {@link org.yakindu.sct.model.stext.stext.StatechartSpecification} object.
@@ -68,6 +73,39 @@ public class StatechartSpecificationItemProvider
     return itemPropertyDescriptors;
   }
 
+  /**
+   * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
+   * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
+   * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}.
+   * <!-- begin-user-doc -->
+   * <!-- end-user-doc -->
+   * @generated
+   */
+  @Override
+  public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object)
+  {
+    if (childrenFeatures == null)
+    {
+      super.getChildrenFeatures(object);
+      childrenFeatures.add(StextPackage.Literals.STATECHART_SPECIFICATION__IMPORTS);
+    }
+    return childrenFeatures;
+  }
+
+  /**
+   * <!-- begin-user-doc -->
+   * <!-- end-user-doc -->
+   * @generated
+   */
+  @Override
+  protected EStructuralFeature getChildFeature(Object object, Object child)
+  {
+    // Check the type of the specified child object and return the proper feature to use for
+    // adding (see {@link AddCommand}) it as a child.
+
+    return super.getChildFeature(object, child);
+  }
+
   /**
    * This returns StatechartSpecification.gif.
    * <!-- begin-user-doc -->
@@ -106,6 +144,13 @@ public class StatechartSpecificationItemProvider
   public void notifyChanged(Notification notification)
   {
     updateChildren(notification);
+
+    switch (notification.getFeatureID(StatechartSpecification.class))
+    {
+      case StextPackage.STATECHART_SPECIFICATION__IMPORTS:
+        fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false));
+        return;
+    }
     super.notifyChanged(notification);
   }
 
@@ -140,6 +185,11 @@ public class StatechartSpecificationItemProvider
       (createChildParameter
         (SGraphPackage.Literals.SCOPED_ELEMENT__SCOPES,
          StextFactory.eINSTANCE.createSimpleScope()));
+
+    newChildDescriptors.add
+      (createChildParameter
+        (StextPackage.Literals.STATECHART_SPECIFICATION__IMPORTS,
+         SGraphFactory.eINSTANCE.createImport()));
   }
 
   /**

+ 24 - 0
plugins/org.yakindu.sct.model.stext.edit/src/org/yakindu/sct/model/stext/stext/provider/VariableDefinitionItemProvider.java

@@ -73,6 +73,7 @@ public class VariableDefinitionItemProvider
       super.getPropertyDescriptors(object);
 
       addTypePropertyDescriptor(object);
+      addTypeArgumentsPropertyDescriptor(object);
       addReadonlyPropertyDescriptor(object);
       addExternalPropertyDescriptor(object);
     }
@@ -102,6 +103,29 @@ public class VariableDefinitionItemProvider
          null));
   }
 
+  /**
+   * This adds a property descriptor for the Type Arguments feature.
+   * <!-- begin-user-doc -->
+   * <!-- end-user-doc -->
+   * @generated
+   */
+  protected void addTypeArgumentsPropertyDescriptor(Object object)
+  {
+    itemPropertyDescriptors.add
+      (createItemPropertyDescriptor
+        (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
+         getResourceLocator(),
+         getString("_UI_TypedElement_typeArguments_feature"),
+         getString("_UI_PropertyDescriptor_description", "_UI_TypedElement_typeArguments_feature", "_UI_TypedElement_type"),
+         TypesPackage.Literals.TYPED_ELEMENT__TYPE_ARGUMENTS,
+         true,
+         false,
+         true,
+         null,
+         null,
+         null));
+  }
+
   /**
    * This adds a property descriptor for the Readonly feature.
    * <!-- begin-user-doc -->

+ 2 - 1
plugins/org.yakindu.sct.model.stext/META-INF/MANIFEST.MF

@@ -22,7 +22,8 @@ Require-Bundle: org.eclipse.xtext;visibility:=reexport,
  org.yakindu.base.types;bundle-version="1.0.0",
  org.yakindu.base.types.scope;bundle-version="1.0.0",
  de.itemis.xtext.utils.jface;bundle-version="1.0.0",
- org.yakindu.base.expressions;bundle-version="1.0.0";visibility:=reexport
+ org.yakindu.base.expressions;bundle-version="1.0.0";visibility:=reexport,
+ org.yakindu.sct.commons;bundle-version="2.1.2"
 Import-Package: org.apache.commons.logging,
  org.apache.log4j,
  org.eclipse.xtext.builder.builderState,

+ 5 - 1
plugins/org.yakindu.sct.model.stext/model/SText.ecore

@@ -18,7 +18,11 @@
     <eStructuralFeatures xsi:type="ecore:EReference" name="def" eType="#//TransitionSpecification"
         containment="true"/>
   </eClassifiers>
-  <eClassifiers xsi:type="ecore:EClass" name="StatechartSpecification" eSuperTypes="../../org.yakindu.sct.model.sgraph/model/emf/sgraph.ecore#//ScopedElement"/>
+  <eClassifiers xsi:type="ecore:EClass" name="StatechartSpecification" eSuperTypes="../../org.yakindu.sct.model.sgraph/model/emf/sgraph.ecore#//ScopedElement">
+    <eStructuralFeatures xsi:type="ecore:EReference" name="imports" upperBound="-1"
+        eType="ecore:EClass ../../org.yakindu.sct.model.sgraph/model/emf/sgraph.ecore#//Import"
+        containment="true"/>
+  </eClassifiers>
   <eClassifiers xsi:type="ecore:EClass" name="StateSpecification">
     <eStructuralFeatures xsi:type="ecore:EReference" name="scope" eType="ecore:EClass ../../org.yakindu.sct.model.sgraph/model/emf/sgraph.ecore#//Scope"
         containment="true"/>

+ 3 - 1
plugins/org.yakindu.sct.model.stext/model/SText.genmodel

@@ -35,7 +35,9 @@
     <genClasses ecoreClass="platform:/resource/org.yakindu.sct.model.stext/model/SText.ecore#//TransitionRoot">
       <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference platform:/resource/org.yakindu.sct.model.stext/model/SText.ecore#//TransitionRoot/def"/>
     </genClasses>
-    <genClasses ecoreClass="platform:/resource/org.yakindu.sct.model.stext/model/SText.ecore#//StatechartSpecification"/>
+    <genClasses ecoreClass="platform:/resource/org.yakindu.sct.model.stext/model/SText.ecore#//StatechartSpecification">
+      <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference platform:/resource/org.yakindu.sct.model.stext/model/SText.ecore#//StatechartSpecification/imports"/>
+    </genClasses>
     <genClasses ecoreClass="platform:/resource/org.yakindu.sct.model.stext/model/SText.ecore#//StateSpecification">
       <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference platform:/resource/org.yakindu.sct.model.stext/model/SText.ecore#//StateSpecification/scope"/>
     </genClasses>

plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/GenerateExpressions.mwe2 → plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/GenerateSText.mwe2


+ 18 - 3
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/SText.xtext

@@ -30,7 +30,9 @@ ScopedElement returns sgraph::ScopedElement:
 	StatechartSpecification;
 
 StatechartSpecification:
-	{StatechartSpecification} ('namespace' namespace=FQN)? (scopes+=StatechartScope)*;
+	{StatechartSpecification} ('namespace' namespace=FQN)? 
+	(imports+=Import)*
+	(scopes+=StatechartScope)*;
 
 StateSpecification:
 	scope=StateScope;
@@ -60,11 +62,24 @@ InterfaceScope:
 InternalScope:
 	{InternalScope} 'internal' ':' (declarations+=(EventDeclarartion | VariableDeclaration | OperationDeclaration |
 	LocalReaction))*; /* ---- declarations ----
-a definition is a top level element of a definition scope. */ Declaration
-returns sgraph::Declaration:
+a definition is a top level element of a definition scope. */ 
+
+Import returns sgraph::Import:
+	'import' importedNamespace=QIDWithWildcards';'
+;
+
+QIDWithWildcards:
+	QID ('.*')?;
+	
+QID:
+	ID ('.' ID)*;
+
+
+Declaration returns sgraph::Declaration:
 	EventDeclarartion | VariableDeclaration | OperationDeclaration | LocalReaction //		| Entrypoint 
  //		| Exitpoint
 ;
+
 /* ---- event definition ---- */ EventDeclarartion returns sgraph::Event:
 	EventDefinition;
 

+ 2 - 2
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/STextRuntimeModule.java

@@ -14,13 +14,13 @@ import org.eclipse.xtext.Constants;
 import org.eclipse.xtext.linking.ILinker;
 import org.eclipse.xtext.naming.IQualifiedNameProvider;
 import org.eclipse.xtext.resource.IDefaultResourceDescriptionStrategy;
+import org.yakindu.base.types.DefaultTypeSystem;
 import org.yakindu.base.types.ITypeSystem;
 import org.yakindu.sct.model.sgraph.resource.SCTLinker;
 import org.yakindu.sct.model.sgraph.resource.provider.SCTResourceDescriptionStrategy;
 import org.yakindu.sct.model.stext.conversion.StextValueConverterService;
 import org.yakindu.sct.model.stext.naming.StextNameProvider;
 import org.yakindu.sct.model.stext.scoping.STextGlobalScopeProvider;
-import org.yakindu.sct.model.stext.types.STextDefaultTypeSystem;
 
 import com.google.inject.Binder;
 import com.google.inject.name.Names;
@@ -55,7 +55,7 @@ public class STextRuntimeModule extends
 	}
 
 	public Class<? extends ITypeSystem> bindITypeSystem() {
-		return STextDefaultTypeSystem.class;
+		return DefaultTypeSystem.class;
 	}
 
 	public Class<? extends IDefaultResourceDescriptionStrategy> bindIDefaultResourceDescriptionStrategy() {

+ 1 - 1
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/scoping/STextGlobalScopeProvider.java

@@ -45,7 +45,7 @@ public class STextGlobalScopeProvider extends DefaultGlobalScopeProvider {
 	public IScope getScope(Resource context, EReference reference,
 			Predicate<IEObjectDescription> filter) {
 		IScope parentScope = super.getScope(context, reference, filter);
-		parentScope = filterExternalDeclarations(context, parentScope);
+//		parentScope = filterExternalDeclarations(context, parentScope);
 
 		parentScope = new TypeSystemAwareScope(parentScope, typeSystem,
 				qualifiedNameProvider, reference.getEReferenceType());

+ 31 - 34
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/scoping/STextScopeProvider.java

@@ -64,16 +64,15 @@ public class STextScopeProvider extends AbstractDeclarativeScopeProvider {
 
 	@Inject
 	ITypeSystem typeSystem;
-	
+
 	@Inject
 	TypeSystemUtils typeSystemUtils;
-	
+
 	private static class ErrorHandlerDelegate<T> implements ErrorHandler<T> {
 
 		private ErrorHandler<T> delegate;
 
-		public static final Log LOG = LogFactory
-				.getLog(STextScopeProvider.class);
+		public static final Log LOG = LogFactory.getLog(STextScopeProvider.class);
 
 		public ErrorHandlerDelegate(ErrorHandler<T> delegate) {
 			this.delegate = delegate;
@@ -93,6 +92,8 @@ public class STextScopeProvider extends AbstractDeclarativeScopeProvider {
 
 	@Override
 	public IScope getScope(EObject context, EReference reference) {
+		String methodName = "scope_" + reference.getEContainingClass().getName() + "_" + reference.getName();
+		System.out.println(methodName);
 		try {
 			ErrorHandler<IScope> originalHandler = getErrorHandler();
 			setErrorHandler(new ErrorHandlerDelegate<IScope>(originalHandler));
@@ -108,24 +109,19 @@ public class STextScopeProvider extends AbstractDeclarativeScopeProvider {
 	@Inject
 	private ContextPredicateProvider predicateProvider;
 
-	public IScope scope_ElementReferenceExpression_reference(
-			final EObject context, EReference reference) {
+	public IScope scope_ElementReferenceExpression_reference(final EObject context, EReference reference) {
 		IScope namdScope = getNamedTopLevelScope(context, reference);
 		IScope unnamedScope = getUnnamedTopLevelScope(context, reference);
-		Predicate<IEObjectDescription> predicate = calculateFilterPredicate(
-				context, reference);
-		unnamedScope = new FilteringScope(unnamedScope, predicate);
+//		Predicate<IEObjectDescription> predicate = calculateFilterPredicate(context, reference);
+//		unnamedScope = new FilteringScope(unnamedScope, predicate);
 		// add enum types
-		return new SimpleScope(Iterables.concat(namdScope.getAllElements(),
-				unnamedScope.getAllElements(),
-				Scopes.scopeFor(typeSystemUtils.getEnumerationTypes(typeSystem)).getAllElements()));
+		return new SimpleScope(Iterables.concat(namdScope.getAllElements(), unnamedScope.getAllElements(), Scopes
+				.scopeFor(typeSystemUtils.getEnumerationTypes(typeSystem)).getAllElements()));
 	}
 
-	public IScope scope_FeatureCall_feature(final FeatureCall context,
-			EReference reference) {
+	public IScope scope_FeatureCall_feature(final FeatureCall context, EReference reference) {
 
-		Predicate<IEObjectDescription> predicate = calculateFilterPredicate(
-				context, reference);
+		Predicate<IEObjectDescription> predicate = calculateFilterPredicate(context, reference);
 
 		Expression owner = context.getOwner();
 		EObject element = null;
@@ -148,23 +144,21 @@ public class STextScopeProvider extends AbstractDeclarativeScopeProvider {
 			scope = Scopes.scopeFor(allFeatures((Type) element), scope);
 			scope = new FilteringScope(scope, predicate);
 		}
-		
-		if( element instanceof EnumerationType){
+
+		if (element instanceof EnumerationType) {
 			scope = Scopes.scopeFor(((EnumerationType) element).getEnumerator(), scope);
 			scope = new FilteringScope(scope, predicate);
 		}
 
 		if (element instanceof Feature) {
-			scope = Scopes.scopeFor(allFeatures(((Feature) element).getType()),
-					scope);
+			scope = Scopes.scopeFor(allFeatures(((Feature) element).getType()), scope);
 			scope = new FilteringScope(scope, predicate);
 		}
 
 		return scope;
 	}
 
-	private Predicate<IEObjectDescription> calculateFilterPredicate(
-			final EObject context, final EReference reference) {
+	private Predicate<IEObjectDescription> calculateFilterPredicate(final EObject context, final EReference reference) {
 		Predicate<IEObjectDescription> predicate = null;
 		EObject container = context;
 		EReference ref = reference;
@@ -182,8 +176,7 @@ public class STextScopeProvider extends AbstractDeclarativeScopeProvider {
 	/**
 	 * Returns the toplevel scope
 	 */
-	protected IScope getNamedTopLevelScope(final EObject context,
-			EReference reference) {
+	protected IScope getNamedTopLevelScope(final EObject context, EReference reference) {
 		List<EObject> scopeCandidates = Lists.newArrayList();
 		Statechart statechart = getStatechart(context);
 		if (statechart == null)
@@ -203,8 +196,7 @@ public class STextScopeProvider extends AbstractDeclarativeScopeProvider {
 	/**
 	 * Returns a scope with all toplevel declarations of unnamed scope
 	 */
-	protected IScope getUnnamedTopLevelScope(final EObject context,
-			EReference reference) {
+	protected IScope getUnnamedTopLevelScope(final EObject context, EReference reference) {
 		List<EObject> scopeCandidates = Lists.newArrayList();
 		Statechart statechart = getStatechart(context);
 		if (statechart == null)
@@ -222,25 +214,23 @@ public class STextScopeProvider extends AbstractDeclarativeScopeProvider {
 		}
 		return Scopes.scopeFor(scopeCandidates);
 	}
-	
 
 	/**
 	 * Returns the {@link Statechart} for a context element
 	 */
 
 	protected Statechart getStatechart(EObject context) {
-		final ContextElementAdapter provider = (ContextElementAdapter) EcoreUtil
-				.getExistingAdapter(context.eResource(),
-						ContextElementAdapter.class);
+		final ContextElementAdapter provider = (ContextElementAdapter) EcoreUtil.getExistingAdapter(
+				context.eResource(), ContextElementAdapter.class);
 
 		if (provider == null) {
 			return EcoreUtil2.getContainerOfType(context, Statechart.class);
 		} else {
-			return (Statechart) EcoreUtil.getObjectByType(provider.getElement()
-					.eResource().getContents(),
+			return (Statechart) EcoreUtil.getObjectByType(provider.getElement().eResource().getContents(),
 					SGraphPackage.Literals.STATECHART);
 		}
 	}
+	
 
 	/**
 	 * Returns all features including super features for the given type
@@ -256,8 +246,7 @@ public class STextScopeProvider extends AbstractDeclarativeScopeProvider {
 	 * super types.
 	 * 
 	 */
-	protected void collectFeatures(Type type, List<Feature> features,
-			Set<Type> visited) {
+	protected void collectFeatures(Type type, List<Feature> features, Set<Type> visited) {
 		if (type == null || visited.contains(type))
 			return;
 		if (type instanceof ComplexType) {
@@ -269,4 +258,12 @@ public class STextScopeProvider extends AbstractDeclarativeScopeProvider {
 		visited.add(type);
 	}
 
+	// TODO
+	protected IScope scope_TypedElement_type(EObject context, EReference ref) {
+		IScope scope = getDelegate().getScope(context, ref);
+		
+		return scope;
+	}
+	//
+
 }

+ 3 - 9
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/types/ISTextTypeInferrer.java

@@ -11,8 +11,8 @@
  */
 package org.yakindu.sct.model.stext.types;
 
-import org.yakindu.base.expressions.expressions.Expression;
-import org.yakindu.base.types.ITypeSystem.InferenceResult;
+import org.yakindu.base.expressions.inferrer.IExpressionsTypeInferrer;
+import org.yakindu.base.types.InferenceResult;
 import org.yakindu.sct.model.stext.stext.EventDefinition;
 import org.yakindu.sct.model.stext.stext.VariableDefinition;
 
@@ -25,13 +25,7 @@ import com.google.inject.ImplementedBy;
  * 
  */
 @ImplementedBy(STextDefaultTypeInferrer.class)
-public interface ISTextTypeInferrer {
-	
-	/**
-	 * Infers the type for a given {@link Expression}
-	 * 
-	 */
-	InferenceResult inferType(Expression e);
+public interface ISTextTypeInferrer extends IExpressionsTypeInferrer {
 	
 	InferenceResult inferType(VariableDefinition d);
 	

+ 0 - 136
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/types/ISTextTypeSystem.java

@@ -1,136 +0,0 @@
-/**
- * Copyright (c) 2014 itemis AG 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:
- * 	itemis AG - initial API and implementation
- * 
- */
-package org.yakindu.sct.model.stext.types;
-
-import org.yakindu.base.expressions.expressions.AdditiveOperator;
-import org.yakindu.base.expressions.expressions.AssignmentOperator;
-import org.yakindu.base.expressions.expressions.MultiplicativeOperator;
-import org.yakindu.base.expressions.expressions.RelationalOperator;
-import org.yakindu.base.expressions.expressions.ShiftOperator;
-import org.yakindu.base.types.ITypeSystem;
-import org.yakindu.base.types.Type;
-
-import com.google.inject.ImplementedBy;
-
-/**
- * Extension of {@link ITypeSystem}, which defines the operators that have to be
- * supported by an {@link ITypeSystem} to be used in combination with SText. The
- * extension also offers means to infer types for SText literals.
- * 
- * @author Alexander Nyßen (alexander.nyssen@itemis.de) - Inital contribution
- *         and API
- * 
- */
-@ImplementedBy(STextDefaultTypeSystem.class)
-public interface ISTextTypeSystem extends ITypeSystem {
-
-	public enum UnaryOperators implements ITypeSystemOperator {
-		LOGICAL_NOT("!"), POSITIVE("+"), NEGATIVE("-"), COMPLEMENT("~");
-
-		private String symbol;
-
-		UnaryOperators(String symbol) {
-			this.symbol = symbol;
-		}
-
-		public String getSymbol() {
-			return symbol;
-		}
-	};
-
-	public enum BinaryOperators implements ITypeSystemOperator {
-		LOGICAL_OR("||"), LOGICAL_AND("&&"), BITWISE_OR("|"), BITWISE_AND("&"), BITWISE_XOR(
-				"^"), SMALLER(RelationalOperator.SMALLER.getLiteral()), SMALLER_EQUAL(
-				RelationalOperator.SMALLER_EQUAL.getLiteral()), GREATER(
-				RelationalOperator.GREATER.getLiteral()), GREATER_EQUAL(
-				RelationalOperator.GREATER_EQUAL.getLiteral()), EQUAL(
-				RelationalOperator.EQUALS.getLiteral()), NOT_EQUAL(
-				RelationalOperator.NOT_EQUALS.getLiteral()), MULTIPLY(
-				MultiplicativeOperator.MUL.getLiteral()), DIV(
-				MultiplicativeOperator.DIV.getLiteral()), MOD(
-				MultiplicativeOperator.MOD.getLiteral()), ADD(
-				AdditiveOperator.PLUS.getLiteral()), SUBTRACT(
-				AdditiveOperator.MINUS.getLiteral()), LEFT_SHIFT(
-				ShiftOperator.LEFT.getLiteral()), RIGHT_SHIFT(
-				ShiftOperator.RIGHT.getLiteral()), ASSIGN(
-				AssignmentOperator.ASSIGN.getLiteral()), ASSIGN_MULTIPLY(
-				AssignmentOperator.MULT_ASSIGN.getLiteral()), ASSIGN_DIV(
-				AssignmentOperator.DIV_ASSIGN.getLiteral()), ASSIGN_MOD(
-				AssignmentOperator.MOD_ASSIGN.getLiteral()), ASSIGN_ADD(
-				AssignmentOperator.ADD_ASSIGN.getLiteral()), ASSIGN_SUBTRACT(
-				AssignmentOperator.SUB_ASSIGN.getLiteral()), ASSIGN_LEFT_SHIFT(
-				AssignmentOperator.LEFT_SHIFT_ASSIGN.getLiteral()), ASSIGN_RIGHT_SHIFT(
-				AssignmentOperator.RIGHT_SHIFT_ASSIGN.getLiteral()), ASSIGN_BITWISE_AND(
-				AssignmentOperator.AND_ASSIGN.getLiteral()), ASSIGN_BITWISE_XOR(
-				AssignmentOperator.XOR_ASSIGN.getLiteral()), ASSIGN_BITWISE_OR(
-				AssignmentOperator.OR_ASSIGN.getLiteral());
-
-		private String symbol;
-
-		BinaryOperators(String symbol) {
-			this.symbol = symbol;
-		}
-
-		public String getSymbol() {
-			return symbol;
-		}
-	};
-
-	public enum TernaryOperators implements ITypeSystemOperator {
-		CONDITIONAL("?");
-
-		private String symbol;
-
-		TernaryOperators(String symbol) {
-			this.symbol = symbol;
-		}
-
-		public String getSymbol() {
-			return symbol;
-		}
-	};
-
-	public Type getVoidType();
-
-	public Type getBooleanType();
-
-	public Type getIntegerType();
-
-	public Type getRealType();
-
-	public Type getStringType();
-
-	public boolean isVoidType(InferredType inferredType);
-
-	public boolean isBooleanType(InferredType inferredType);
-
-	public boolean isIntegerType(InferredType inferredType);
-
-	public boolean isRealType(InferredType inferredType);
-
-	public boolean isStringType(InferredType inferredType);
-
-	public boolean isVoidType(Type type);
-
-	public boolean isBooleanType(Type type);
-
-	public boolean isIntegerType(Type type);
-
-	public boolean isRealType(Type type);
-
-	public boolean isStringType(Type type);
-	
-	public Object defaultValue(InferredType type);
-	
-	public Object defaultValue(Type type);
-
-}

+ 28 - 274
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/types/STextDefaultTypeInferrer.xtend

@@ -11,50 +11,21 @@
  */
 package org.yakindu.sct.model.stext.types
 
-import com.google.common.collect.Iterables
 import com.google.inject.Inject
 import com.google.inject.Singleton
 import org.eclipse.core.runtime.IStatus
-import org.eclipse.emf.ecore.EObject
-import org.eclipse.internal.xtend.expression.ast.Literal
-import org.yakindu.base.expressions.expressions.AdditiveOperator
 import org.yakindu.base.expressions.expressions.AssignmentExpression
-import org.yakindu.base.expressions.expressions.AssignmentOperator
-import org.yakindu.base.expressions.expressions.BitwiseAndExpression
-import org.yakindu.base.expressions.expressions.BitwiseOrExpression
-import org.yakindu.base.expressions.expressions.BitwiseXorExpression
-import org.yakindu.base.expressions.expressions.BoolLiteral
-import org.yakindu.base.expressions.expressions.ConditionalExpression
 import org.yakindu.base.expressions.expressions.ElementReferenceExpression
 import org.yakindu.base.expressions.expressions.Expression
 import org.yakindu.base.expressions.expressions.FeatureCall
-import org.yakindu.base.expressions.expressions.HexLiteral
-import org.yakindu.base.expressions.expressions.IntLiteral
-import org.yakindu.base.expressions.expressions.LogicalAndExpression
-import org.yakindu.base.expressions.expressions.LogicalNotExpression
-import org.yakindu.base.expressions.expressions.LogicalOrExpression
-import org.yakindu.base.expressions.expressions.LogicalRelationExpression
-import org.yakindu.base.expressions.expressions.MultiplicativeOperator
-import org.yakindu.base.expressions.expressions.NumericalAddSubtractExpression
-import org.yakindu.base.expressions.expressions.NumericalMultiplyDivideExpression
-import org.yakindu.base.expressions.expressions.NumericalUnaryExpression
-import org.yakindu.base.expressions.expressions.ParenthesizedExpression
-import org.yakindu.base.expressions.expressions.PrimitiveValueExpression
-import org.yakindu.base.expressions.expressions.RealLiteral
-import org.yakindu.base.expressions.expressions.RelationalOperator
-import org.yakindu.base.expressions.expressions.ShiftExpression
-import org.yakindu.base.expressions.expressions.ShiftOperator
-import org.yakindu.base.expressions.expressions.StringLiteral
-import org.yakindu.base.expressions.expressions.UnaryOperator
-import org.yakindu.base.types.Enumerator
+import org.yakindu.base.expressions.inferrer.DefaultExpressionsTypeInferrer
 import org.yakindu.base.types.Event
 import org.yakindu.base.types.Feature
-import org.yakindu.base.types.ITypeSystem.ITypeSystemOperator
-import org.yakindu.base.types.ITypeSystem.InferenceIssue
-import org.yakindu.base.types.ITypeSystem.InferenceResult
-import org.yakindu.base.types.ITypeSystem.InferredType
+import org.yakindu.base.types.ITypeSystem
+import org.yakindu.base.types.InferenceIssue
+import org.yakindu.base.types.InferenceResult
+import org.yakindu.base.types.InferredType
 import org.yakindu.base.types.Type
-import org.yakindu.base.types.TypedElement
 import org.yakindu.sct.model.stext.stext.ActiveStateReferenceExpression
 import org.yakindu.sct.model.stext.stext.EventDefinition
 import org.yakindu.sct.model.stext.stext.EventRaisingExpression
@@ -63,6 +34,7 @@ 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
+import org.yakindu.base.types.ITypeSystem.BinaryOperators
 
 /**
  * 
@@ -73,19 +45,12 @@ import org.yakindu.sct.model.stext.stext.VariableDefinition
  *  
  */
  @Singleton
-class STextDefaultTypeInferrer implements ISTextTypeInferrer {
+class STextDefaultTypeInferrer extends DefaultExpressionsTypeInferrer implements ISTextTypeInferrer {
 	
 	@Inject protected extension
-	ISTextTypeSystem ts
+	ITypeSystem ts
+	
 	
-	override inferType(Expression e) {
-		if(e == null){
-			throw new IllegalArgumentException("Expression may not be null")
-		}
-		else{
-			return doInferType(e)
-		}
-	}
 	
 	override inferType(VariableDefinition definition) {
 		if(definition == null){
@@ -118,7 +83,7 @@ class STextDefaultTypeInferrer implements ISTextTypeInferrer {
  				}
  			
  				// reuse the assignment logic of the type system
- 				val result = inferResult(varType, valueType, ISTextTypeSystem.BinaryOperators::ASSIGN)
+ 				val result = inferResult(varType, valueType, BinaryOperators.ASSIGN)
  				if(result.type == null){
  					return new InferenceResult(null, new InferenceIssue("Cannot assign a value of type " + valueType.type.type.name + " to a variable of type " + varType.type.type.name + ".", IStatus::ERROR))
  				}	
@@ -151,16 +116,7 @@ class STextDefaultTypeInferrer implements ISTextTypeInferrer {
 		return new InferenceResult(new InferredType(type))
 	}
 	
-	def dispatch InferenceResult doInferType(TypedElement typedElement) {
-		if(typedElement.type == null)
-			return new InferenceResult(null,new InferenceIssue("Could not infer type of typedelement: " + typedElement, IStatus::ERROR))
-		else
-			return new InferenceResult(new InferredType(typedElement.type))
-	}
 	
-	def dispatch InferenceResult doInferType(Enumerator enumerator) {
-		return new InferenceResult(new InferredType(enumerator.owningEnumeration));
-	}
 	
 	def dispatch InferenceResult doInferType(InterfaceScope s){
 		// TODO: this could be handled via the type system
@@ -176,88 +132,12 @@ class STextDefaultTypeInferrer implements ISTextTypeInferrer {
 		throw new UnsupportedOperationException("Unsupported expression type " + e)
 	}
 	
-	def InferenceResult inferResult(InferenceResult operand, ITypeSystemOperator unaryOperator){
-		if(operand.getType() != null){
-			return ts.inferType(operand.type, unaryOperator);
-//			result.issues.addAll(operand.issues);
-		}
-		return new InferenceResult(null, operand.issues)
-	}
-	
-	def InferenceResult inferResult(InferenceResult firstOperand, InferenceResult secondOperand, ITypeSystemOperator binaryOperator){
-		if(firstOperand.getType() != null && secondOperand.getType() != null){
-			val result = ts.inferType(firstOperand.type, secondOperand.type, binaryOperator);
-			result.issues.addAll(firstOperand.issues);
-			result.issues.addAll(secondOperand.issues);
-			return result;
-		}
-		return new InferenceResult(null, Iterables::concat(firstOperand.issues, secondOperand.issues).toList);
-	}
 	
-	def InferenceResult inferResult(InferenceResult firstOperand, InferenceResult secondOperand, InferenceResult thirdOperand, ITypeSystemOperator ternaryOperator){
-		if(firstOperand.getType() != null && secondOperand.getType() != null && thirdOperand.getType() != null){
-			val result = ts.inferType(firstOperand.type, secondOperand.type, thirdOperand.type, ternaryOperator);
-			result.issues.addAll(firstOperand.issues);
-			result.issues.addAll(secondOperand.issues);
-			result.issues.addAll(thirdOperand.issues);
-			return result;
-		}
-		return new InferenceResult(null, Iterables::concat(firstOperand.issues, secondOperand.issues).toList);
-	}
 	
 	def dispatch InferenceResult doInferType(AssignmentExpression expression){
 		return inferResult(expression.varRef.doInferType, expression.expression.doInferType, getTypeSystemOperator(expression.operator))
 	}
 	
-	def dispatch InferenceResult doInferType(LogicalAndExpression expression){
-		return inferResult(expression.leftOperand.doInferType, expression.rightOperand.doInferType, ISTextTypeSystem.BinaryOperators::LOGICAL_AND)
-	}
-	def dispatch InferenceResult doInferType(LogicalOrExpression expression){
-		return inferResult(expression.leftOperand.doInferType, expression.rightOperand.doInferType, ISTextTypeSystem.BinaryOperators::LOGICAL_OR)
-	}
-	
-	def dispatch InferenceResult doInferType(LogicalNotExpression expression){
-		return inferResult(expression.operand.doInferType, ISTextTypeSystem.UnaryOperators::LOGICAL_NOT)
-	}
-	
-	def dispatch InferenceResult doInferType(BitwiseAndExpression expression){
-		return inferResult(expression.leftOperand.doInferType, expression.rightOperand.doInferType, ISTextTypeSystem.BinaryOperators::BITWISE_AND)
-	}
-	
-	def dispatch InferenceResult doInferType(BitwiseOrExpression expression){
-		return inferResult(expression.leftOperand.doInferType, expression.rightOperand.doInferType, ISTextTypeSystem.BinaryOperators::BITWISE_OR)
-	}
-	
-	def dispatch InferenceResult doInferType(BitwiseXorExpression expression){
-		return inferResult(expression.leftOperand.doInferType, expression.rightOperand.doInferType, ISTextTypeSystem.BinaryOperators::BITWISE_XOR)
-	}
-	
-	def dispatch InferenceResult doInferType(LogicalRelationExpression expression){ 
-		return inferResult(expression.leftOperand.doInferType, expression.rightOperand.doInferType, getTypeSystemOperator(expression.operator))
-	}
-	
-	def dispatch InferenceResult doInferType(NumericalAddSubtractExpression expression){
-		return inferResult(expression.leftOperand.doInferType, expression.rightOperand.doInferType, getTypeSystemOperator(expression.operator))
-	}
-	def dispatch InferenceResult doInferType(NumericalMultiplyDivideExpression expression){
-		return inferResult(expression.leftOperand.doInferType, expression.rightOperand.doInferType, getTypeSystemOperator(expression.operator))
-	}
-	def dispatch InferenceResult doInferType(NumericalUnaryExpression expression){
-		return inferResult(expression.operand.doInferType, getTypeSystemOperator(expression.operator))
-	}	
-	
-	def dispatch InferenceResult doInferType(PrimitiveValueExpression expression){
-		return expression.value.doInferType
-	}
-	
-	def dispatch InferenceResult doInferType(ShiftExpression expression){
-		return inferResult(expression.leftOperand.doInferType, expression.rightOperand.doInferType, getTypeSystemOperator(expression.operator))
-	}
-	
-	def dispatch InferenceResult doInferType(ConditionalExpression expression){
-		return inferResult(expression.condition.doInferType, expression.trueCase.doInferType, expression.falseCase.doInferType, ISTextTypeSystem.TernaryOperators::CONDITIONAL);
-	} 
-	
 	def dispatch InferenceResult doInferType(EventRaisingExpression eventRaising){
  		val eventType = eventRaising.event.doInferType
  		if(eventType.type == null) {
@@ -277,7 +157,7 @@ class STextDefaultTypeInferrer implements ISTextTypeInferrer {
  				}
  			
  				// reuse the assignment logic of the type system
- 				val result = inferResult(eventType, valueType, ISTextTypeSystem.BinaryOperators::ASSIGN)
+ 				val result = inferResult(eventType, valueType, BinaryOperators.ASSIGN)
  				if(result.type == null){
  					return new InferenceResult(null, new InferenceIssue("Cannot assign a value of type " + valueType.type.type.name + " to an event of type " + eventType.type.type.name + ".", IStatus::ERROR))
  				}
@@ -288,23 +168,7 @@ class STextDefaultTypeInferrer implements ISTextTypeInferrer {
  		}
 	}
 	
-	def dispatch InferenceResult doInferType(FeatureCall featureCall){
-		if(featureCall.feature instanceof Event /*Definition*/ 
-			&& !(featureCall.eContainer instanceof EventRaisingExpression) 
-			&& !(featureCall.eContainer instanceof EventValueReferenceExpression)
-		){
-			// e1 is a shortcut for isRaised(e1) and thus we have to return boolean here
-			return new InferenceResult(getBooleanType)
-		}
-		if (featureCall.feature instanceof Feature) {
-			val type = (featureCall.feature as Feature).type
-			if(type != null){
-				return new InferenceResult(new InferredType(type))
-			}
-			return new InferenceResult(getVoidType)
-		}
-		return featureCall.feature.doInferType
-	}
+	
 	 
 	def dispatch InferenceResult doInferType(ActiveStateReferenceExpression expression){
 		return new InferenceResult(getBooleanType)
@@ -322,136 +186,26 @@ class STextDefaultTypeInferrer implements ISTextTypeInferrer {
 		}
 	}
 	
-	def dispatch InferenceResult doInferType(EventValueReferenceExpression expression){
-		return doInferType(expression.value)
-	}
-	
-	def dispatch InferenceResult doInferType(ParenthesizedExpression expression){
-		return doInferType(expression.expression)
-	}
-	
-	def dispatch InferenceResult doInferType(StringLiteral literal){
-		return inferTypeForLiteral(literal.value);
-	}
-	
-	def dispatch InferenceResult doInferType(BoolLiteral literal){
-		return inferTypeForLiteral(literal.value);
-	}
-	
-	def dispatch InferenceResult doInferType(RealLiteral literal){
-		return inferTypeForLiteral(literal.value);
-	}
-	
-	def dispatch InferenceResult doInferType(HexLiteral literal){
-		return inferTypeForLiteral(literal.value);
-	}
-	
-	def dispatch InferenceResult doInferType(IntLiteral literal){
-		return inferTypeForLiteral(literal.value);
-	}
-	
-	def dispatch InferenceResult doInferType(Literal l) {
-		throw new IllegalArgumentException("Unsupported literal kind " + l)
-	}
-	
-	def dispatch InferenceResult doInferType(EObject e) {
-		return inferTypeForLiteral(e);
-	}
-	
-	def protected dispatch ITypeSystemOperator getTypeSystemOperator(UnaryOperator operator){
-		switch(operator){
-			case UnaryOperator::COMPLEMENT:
-				ISTextTypeSystem.UnaryOperators::COMPLEMENT
-			case UnaryOperator::NEGATIVE:
-				ISTextTypeSystem.UnaryOperators::NEGATIVE
-			case UnaryOperator::POSITIVE:
-				ISTextTypeSystem.UnaryOperators::POSITIVE
-			default:
-				throw new IllegalArgumentException("Unsupported operator" + operator)
-		}
-	}
-	
-	def protected dispatch ITypeSystemOperator getTypeSystemOperator(AssignmentOperator operator) {
-		switch(operator){
-			case AssignmentOperator::ADD_ASSIGN:
-				ISTextTypeSystem.BinaryOperators::ASSIGN_ADD
-			case AssignmentOperator::AND_ASSIGN:
-				ISTextTypeSystem.BinaryOperators::ASSIGN_BITWISE_AND
-			case AssignmentOperator::ASSIGN:
-				ISTextTypeSystem.BinaryOperators::ASSIGN
-			case AssignmentOperator::DIV_ASSIGN:
-				ISTextTypeSystem.BinaryOperators::ASSIGN_DIV
-			case AssignmentOperator::LEFT_SHIFT_ASSIGN:
-				ISTextTypeSystem.BinaryOperators::ASSIGN_LEFT_SHIFT
-			case AssignmentOperator::MOD_ASSIGN:
-				ISTextTypeSystem.BinaryOperators::ASSIGN_MOD
-			case AssignmentOperator::MULT_ASSIGN:
-				ISTextTypeSystem.BinaryOperators::ASSIGN_MULTIPLY
-			case AssignmentOperator::OR_ASSIGN:
-				ISTextTypeSystem.BinaryOperators::ASSIGN_BITWISE_OR
-			case AssignmentOperator::RIGHT_SHIFT_ASSIGN:
-				ISTextTypeSystem.BinaryOperators::ASSIGN_RIGHT_SHIFT
-			case AssignmentOperator::SUB_ASSIGN:
-				ISTextTypeSystem.BinaryOperators::ASSIGN_SUBTRACT
-			case AssignmentOperator::XOR_ASSIGN:
-				ISTextTypeSystem.BinaryOperators::ASSIGN_BITWISE_XOR
-			default: 
-				throw new IllegalArgumentException("Unsupported operator" + operator)
-		}
-	}
-	
-	def dispatch ITypeSystemOperator getTypeSystemOperator(ShiftOperator operator) {
-		switch(operator){
-			case ShiftOperator::LEFT:
-				ISTextTypeSystem.BinaryOperators::LEFT_SHIFT
-			case ShiftOperator::RIGHT:
-				ISTextTypeSystem.BinaryOperators::RIGHT_SHIFT
-			default: 
-				throw new IllegalArgumentException("Unsupported operator" + operator)
+	def dispatch InferenceResult doInferType(FeatureCall featureCall){
+		if(featureCall.feature instanceof Event /*Definition*/ 
+			&& !(featureCall.eContainer instanceof EventRaisingExpression) 
+			&& !(featureCall.eContainer instanceof EventValueReferenceExpression)
+		){
+			// e1 is a shortcut for isRaised(e1) and thus we have to return boolean here
+			return new InferenceResult(getBooleanType)
 		}
-	}
-	
-	def protected dispatch ITypeSystemOperator getTypeSystemOperator(AdditiveOperator operator) {
-		switch(operator){
-			case AdditiveOperator::PLUS:
-				ISTextTypeSystem.BinaryOperators::ADD
-			case AdditiveOperator::MINUS:
-				ISTextTypeSystem.BinaryOperators::SUBTRACT
-			default: 
-				throw new IllegalArgumentException("Unsupported operator" + operator)
+		if (featureCall.feature instanceof Feature) {
+			val type = (featureCall.feature as Feature).type
+			if(type != null){
+				return new InferenceResult(new InferredType(type))
+			}
+			return new InferenceResult(getVoidType)
 		}
+		return featureCall.feature.doInferType
 	}
 	
-	def protected dispatch ITypeSystemOperator getTypeSystemOperator(MultiplicativeOperator operator) {
-		switch(operator){
-			case MultiplicativeOperator::DIV:
-				ISTextTypeSystem.BinaryOperators::DIV
-			case MultiplicativeOperator::MOD:
-				ISTextTypeSystem.BinaryOperators::MOD
-			case MultiplicativeOperator::MUL:
-				ISTextTypeSystem.BinaryOperators::MULTIPLY
-			default: 
-				throw new IllegalArgumentException("Unsupported operator" + operator)
-		}
-	}
-
-	def protected dispatch ITypeSystemOperator getTypeSystemOperator(RelationalOperator operator) {
-		switch(operator){
-			case RelationalOperator::EQUALS:
-				ISTextTypeSystem.BinaryOperators::EQUAL
-			case RelationalOperator::NOT_EQUALS:
-				ISTextTypeSystem.BinaryOperators::NOT_EQUAL
-			case RelationalOperator::GREATER:
-				ISTextTypeSystem.BinaryOperators::GREATER
-			case RelationalOperator::GREATER_EQUAL:
-				ISTextTypeSystem.BinaryOperators::GREATER_EQUAL
-			case RelationalOperator::SMALLER:
-				ISTextTypeSystem.BinaryOperators::SMALLER
-			case RelationalOperator::SMALLER_EQUAL:
-				ISTextTypeSystem.BinaryOperators::SMALLER_EQUAL
-			default: 
-				throw new IllegalArgumentException("Unsupported operator" + operator)
-		}
+	def dispatch InferenceResult doInferType(EventValueReferenceExpression expression){
+		return doInferType(expression.value)
 	}
 
 }

+ 0 - 546
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/types/STextDefaultTypeSystem.java

@@ -1,546 +0,0 @@
-/**
- * Copyright (c) 2014 itemis AG 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:
- * 	itemis AG - initial API and implementation
- * 
- */
-package org.yakindu.sct.model.stext.types;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.impl.ResourceImpl;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.yakindu.base.types.AbstractTypeSystem;
-import org.yakindu.base.types.ComplexType;
-import org.yakindu.base.types.EnumerationType;
-import org.yakindu.base.types.ITypeSystem;
-import org.yakindu.base.types.PrimitiveType;
-import org.yakindu.base.types.Type;
-import org.yakindu.base.types.TypesFactory;
-
-import com.google.inject.Singleton;
-
-/**
- * Default implementation of an {@link ISTextTypeSystem} that is provided with
- * SText. The type system offers exactly five types, namely the primitives
- * <code>void</code>, <code>boolean</code>, <code>integer</code>,
- * <code>real</code>, <code>string</code>.
- * 
- * @author Alexander Nyßen (alexander.nyssen@itemis.de) - Initial contributino
- *         and API
- * 
- */
-@Singleton
-public class STextDefaultTypeSystem extends AbstractTypeSystem implements ISTextTypeSystem {
-
-	/**
-	 * Dummy resource. Xtext linker expects types to be contained in a resource.
-	 */
-	private static Resource resource;
-	private static PrimitiveType voidType;
-	private static PrimitiveType stringType;
-	private static PrimitiveType realType;
-	private static PrimitiveType integerType;
-	private static PrimitiveType booleanType;
-
-	protected static synchronized Resource getResource() {
-		if (resource == null) {
-			resource = new ResourceImpl();
-			// use old uri for backwards compatibility
-			resource.setURI(URI.createURI("platform:/plugin/org.yakindu.sct.model.stext/libraries/Primitives.types"));
-		}
-		return resource;
-	}
-
-	public Type getBooleanType() {
-		synchronized (STextDefaultTypeSystem.class) {
-			if (booleanType == null) {
-				booleanType = TypesFactory.eINSTANCE.createPrimitiveType();
-				booleanType.setName("boolean");
-				getResource().getContents().add(booleanType);
-			}
-			return booleanType;
-		}
-	}
-
-	public Type getIntegerType() {
-		synchronized (STextDefaultTypeSystem.class) {
-			if (integerType == null) {
-				integerType = TypesFactory.eINSTANCE.createPrimitiveType();
-				integerType.setName("integer");
-				getResource().getContents().add(integerType);
-			}
-			return integerType;
-		}
-	}
-
-	public Type getRealType() {
-		synchronized (STextDefaultTypeSystem.class) {
-			if (realType == null) {
-				realType = TypesFactory.eINSTANCE.createPrimitiveType();
-				realType.setName("real");
-				getResource().getContents().add(realType);
-			}
-			return realType;
-		}
-	}
-
-	public Type getStringType() {
-		synchronized (STextDefaultTypeSystem.class) {
-			if (stringType == null) {
-				stringType = TypesFactory.eINSTANCE.createPrimitiveType();
-				stringType.setName("string");
-				getResource().getContents().add(stringType);
-			}
-			return stringType;
-		}
-	}
-
-	public Type getVoidType() {
-		synchronized (STextDefaultTypeSystem.class) {
-			if (voidType == null) {
-				voidType = TypesFactory.eINSTANCE.createPrimitiveType();
-				voidType.setName("void");
-				getResource().getContents().add(voidType);
-			}
-			return voidType;
-		}
-	}
-
-	public InferenceResult inferTypeForLiteral(Object literal) {
-		if (literal instanceof String) {
-			return new InferenceResult(getStringType());
-		} else if (literal instanceof Boolean) {
-			return new InferenceResult(getBooleanType());
-		} else if (literal instanceof Integer) {
-			return new InferenceResult(getIntegerType());
-		} else if (literal instanceof Float) {
-			return new InferenceResult(getRealType());
-		}
-		throw new IllegalArgumentException("Literal of unknown kind " + literal);
-	}
-
-	public InferenceResult inferType(InferredType operandType, ITypeSystemOperator unaryOperator) {
-		// some defense programming
-		if (operandType == null) {
-			throw new NullPointerException("operandType may not be null.");
-		}
-
-		// if the operand type could not be inferred, there is not much we can
-		// do here
-		if (operandType.getType() == null) {
-			return new InferenceResult(null, new InferenceIssue("Could not infer a type for the operation "
-					+ unaryOperator.getSymbol() + ", because no type was inferred for its operand.", IStatus.ERROR));
-		}
-
-		// check we have a primitive type
-		if (!(operandType.getType() instanceof PrimitiveType)) {
-			return new InferenceResult(null, new InferenceIssue("Operator " + unaryOperator.getSymbol()
-					+ " may only be applied on a primitive type.", IStatus.ERROR));
-		}
-
-		// infer type based on given operator
-		UnaryOperators o = (UnaryOperators) unaryOperator;
-		switch (o) {
-		case COMPLEMENT:
-			if (!isIntegerType(operandType.getType())) {
-				return new InferenceResult(null, new InferenceIssue("Bitwise operator '" + o.getSymbol()
-						+ "' may only be applied on integer types, not on " + operandType.getType().getName() + ".",
-						IStatus.ERROR));
-
-			}
-			return new InferenceResult(operandType);
-		case NEGATIVE:
-		case POSITIVE:
-			if (!isIntegerType(operandType.getType()) && !isRealType(operandType.getType())) {
-				return new InferenceResult(null, new InferenceIssue("Arithmetic operator '" + o.getSymbol()
-						+ "' may only be applied on numeric types, not on " + operandType.getType().getName() + ".",
-						IStatus.ERROR));
-			}
-			return new InferenceResult(operandType);
-		case LOGICAL_NOT:
-			if (!isBooleanType(operandType.getType())) {
-				return new InferenceResult(null, new InferenceIssue("Logical operator '" + o.getSymbol()
-						+ "' may only be applied on boolean types, not on " + operandType.getType().getName() + ".",
-						IStatus.ERROR));
-
-			}
-			return new InferenceResult(operandType);
-		default:
-			throw new IllegalArgumentException("Unsupported unary operator: " + unaryOperator);
-		}
-	}
-
-	public InferenceResult inferType(InferredType firstOperandType, InferredType secondOperandType,
-			ITypeSystemOperator binaryOperator) {
-		// some defense programming
-		if (firstOperandType == null || secondOperandType == null) {
-			throw new NullPointerException("Operand types may not be null.");
-		}
-
-		// if the operand type could not be inferred, there is not much we can
-		// do here
-		if (firstOperandType.getType() == null || secondOperandType.getType() == null) {
-			return new InferenceResult(null, new InferenceIssue("Could not infer a type for the operation "
-					+ binaryOperator.getSymbol() + ", because types were not inferred for all of its operands.",
-					IStatus.ERROR));
-		}
-
-		// infer type base on operator (fist pass: check types are valid, second
-		// pass: compute result type)
-		BinaryOperators o = (BinaryOperators) binaryOperator;
-		switch (o) {
-		case BITWISE_OR:
-		case BITWISE_XOR:
-		case BITWISE_AND:
-		case RIGHT_SHIFT:
-		case LEFT_SHIFT:
-		case ASSIGN_BITWISE_AND:
-		case ASSIGN_BITWISE_OR:
-		case ASSIGN_BITWISE_XOR:
-		case ASSIGN_LEFT_SHIFT:
-		case ASSIGN_RIGHT_SHIFT:
-			// check only integer types are used
-			if (!isIntegerType(firstOperandType.getType()) || !isIntegerType(secondOperandType.getType())) {
-				return new InferenceResult(null, new InferenceIssue("Bitwise operator '" + o.getSymbol()
-						+ "' may only be applied on integer types, not on " + firstOperandType.getType().getName()
-						+ " and " + secondOperandType.getType().getName() + ".", IStatus.ERROR));
-			}
-			// second pass: compute common type
-			switch (o) {
-			case BITWISE_OR:
-			case BITWISE_XOR:
-			case BITWISE_AND:
-				// compute union type
-				return union(firstOperandType, secondOperandType);
-			case RIGHT_SHIFT:
-			case LEFT_SHIFT:
-			case ASSIGN_LEFT_SHIFT:
-			case ASSIGN_RIGHT_SHIFT:
-			case ASSIGN_BITWISE_AND:
-			case ASSIGN_BITWISE_OR:
-			case ASSIGN_BITWISE_XOR:
-				// return type of assignment target
-				return new InferenceResult(firstOperandType);
-			default:
-				throw new IllegalStateException("Unsupported operator kind.");
-			}
-		case ADD:
-		case SUBTRACT:
-		case MULTIPLY:
-		case DIV:
-		case MOD:
-		case ASSIGN_ADD:
-		case ASSIGN_SUBTRACT:
-		case ASSIGN_MULTIPLY:
-		case ASSIGN_DIV:
-		case ASSIGN_MOD:
-			// only numeric types
-			if (!isNumericType(firstOperandType.getType()) || !isNumericType(secondOperandType.getType())) {
-				return new InferenceResult(null, new InferenceIssue("Arithmetic operator '" + o.getSymbol()
-						+ "' may only be applied on numeric types, not on " + firstOperandType.getType().getName()
-						+ " and " + secondOperandType.getType().getName() + ".", IStatus.ERROR));
-			}
-
-			// second pass: compute type
-			switch (o) {
-			case ADD:
-			case SUBTRACT:
-			case MULTIPLY:
-			case DIV:
-			case MOD:
-				return union(firstOperandType, secondOperandType);
-			case ASSIGN_ADD:
-			case ASSIGN_SUBTRACT:
-			case ASSIGN_MULTIPLY:
-			case ASSIGN_DIV:
-			case ASSIGN_MOD:
-				// return type of assignment target
-				return new InferenceResult(firstOperandType);
-			default:
-				throw new IllegalStateException("Unsupported operator kind.");
-			}
-		case LOGICAL_OR:
-		case LOGICAL_AND:
-			// only boolean types allowed
-			if (!isBooleanType(firstOperandType.getType()) || !isBooleanType(secondOperandType.getType())) {
-				return new InferenceResult(null, new InferenceIssue("Logical operator '" + o.getSymbol()
-						+ "' may only be applied on boolean types, not on " + firstOperandType.getType().getName()
-						+ " and " + secondOperandType.getType().getName() + ".", IStatus.ERROR));
-			}
-
-			// second pass: compute type
-			switch (o) {
-			case LOGICAL_OR:
-			case LOGICAL_AND:
-				return union(firstOperandType, secondOperandType);
-			default:
-				throw new IllegalStateException("Unsupported operator kind.");
-			}
-		case GREATER:
-		case GREATER_EQUAL:
-		case SMALLER:
-		case SMALLER_EQUAL:
-			// check we have primitive types
-			if (!(firstOperandType.getType() instanceof PrimitiveType)
-					|| !(secondOperandType.getType() instanceof PrimitiveType)) {
-				return new InferenceResult(null, new InferenceIssue("Comparison operator '" + o.getSymbol()
-						+ "' may only be applied on primitive types, not on " + firstOperandType.getType().getName()
-						+ " and " + secondOperandType.getType().getName() + ".", IStatus.ERROR));
-			}
-			// check types have the same base type
-			if (!EcoreUtil.equals(getBaseType((PrimitiveType) firstOperandType.getType()),
-					getBaseType((PrimitiveType) secondOperandType.getType()))) {
-				// exclude coercion case (integer -> real)
-				if (!(isNumericType(firstOperandType.getType()) && isNumericType(secondOperandType.getType()))) {
-					return new InferenceResult(null, new InferenceIssue("Comparison operator '" + o.getSymbol()
-							+ "' may only be applied on compatible types, not on "
-							+ firstOperandType.getType().getName() + " and " + secondOperandType.getType().getName()
-							+ ".", IStatus.ERROR));
-				}
-
-			}
-			// expression has boolean type
-			return new InferenceResult(new InferredType(getBooleanType()));
-		case EQUAL:
-		case NOT_EQUAL:
-		case ASSIGN:
-			// complex types are allowed here
-			if (firstOperandType.getType() instanceof PrimitiveType
-					&& secondOperandType.getType() instanceof PrimitiveType) {
-				// check primitive types have the same base type
-				if (!EcoreUtil.equals(getBaseType((PrimitiveType) firstOperandType.getType()),
-						getBaseType((PrimitiveType) secondOperandType.getType()))) {
-					// handle coercion
-					if (!(isNumericType(firstOperandType.getType()) && isNumericType(secondOperandType.getType()))) {
-						return new InferenceResult(null, o.equals(BinaryOperators.ASSIGN) ? new InferenceIssue(
-								"Assignment operator '" + o.getSymbol()
-										+ "' may only be applied on compatible types, not on "
-										+ firstOperandType.getType().getName() + " and "
-										+ secondOperandType.getType().getName() + ".", IStatus.ERROR)
-								: new InferenceIssue("Comparison operator '" + o.getSymbol()
-										+ "' may only be applied on compatible types, not on "
-										+ firstOperandType.getType().getName() + " and "
-										+ secondOperandType.getType().getName() + ".", IStatus.ERROR));
-					} else {
-						if (o.equals(BinaryOperators.ASSIGN) && !isRealType(firstOperandType.getType())
-								&& isRealType(secondOperandType.getType())) {
-							// may only assign integer to real, not vice versa
-							return new InferenceResult(null, new InferenceIssue("Assignment operator '" + o.getSymbol()
-									+ "' may only be applied on compatible types, not on "
-									+ firstOperandType.getType().getName() + " and "
-									+ secondOperandType.getType().getName() + ".", IStatus.ERROR));
-						}
-					}
-				}
-			} else if (firstOperandType instanceof ComplexType && secondOperandType.getType() instanceof ComplexType) {
-				// no further checks for complex types required here
-				// (computation of type in second pass will result in null, if
-				// they are not compatible)
-			} else {
-				return new InferenceResult(null, new InferenceIssue(
-						"Assignment and equality operations may only be applied on types of the same kind, not on "
-								+ firstOperandType.getType().getName() + " and "
-								+ secondOperandType.getType().getName() + ".", IStatus.ERROR));
-			}
-
-			// second pass, compute types
-			switch (o) {
-			case ASSIGN:
-				// type of assignment target
-				return new InferenceResult(firstOperandType);
-			case EQUAL:
-			case NOT_EQUAL:
-				// boolean type
-				return new InferenceResult(new InferredType(getBooleanType()));
-			default:
-				throw new IllegalStateException("Unsupported operator kind.");
-			}
-		default:
-			throw new IllegalArgumentException("Unsupported binary operator: " + binaryOperator);
-		}
-	}
-
-	public InferenceResult inferType(InferredType firstOperandType, InferredType secondOperandType,
-			InferredType thirdOperandType, ITypeSystemOperator ternaryOperator) {
-		// some defense programming
-		if (firstOperandType == null || secondOperandType == null || thirdOperandType == null) {
-			throw new NullPointerException("Operand types may not be null");
-		}
-
-		// if the operand type could not be inferred, there is not much we can
-		// do here
-		if (firstOperandType.getType() == null || secondOperandType.getType() == null
-				|| thirdOperandType.getType() == null) {
-			return new InferenceResult(null, new InferenceIssue("Could not infer a type for the operation "
-					+ ternaryOperator.getSymbol() + ", because types were not inferred for all of its operands.",
-					IStatus.ERROR));
-		}
-
-		// infer type based on operator
-		TernaryOperators o = (TernaryOperators) ternaryOperator;
-		switch (o) {
-		case CONDITIONAL:
-			// first operand has to be boolean, second and third determine the
-			// inferred type of the expression
-			List<InferenceIssue> issues = new ArrayList<ITypeSystem.InferenceIssue>();
-			if (!isBooleanType(firstOperandType.getType())) {
-				issues.add(new InferenceIssue(
-						"No valid type can be inferred for conditional expression, because type of first operand is not boolean.",
-						IStatus.ERROR));
-			}
-			// compute a union of the second and third operand types
-			InferenceResult unionResult = union(secondOperandType, thirdOperandType);
-			unionResult.getIssues().addAll(issues);
-			return unionResult;
-		default:
-			throw new IllegalArgumentException("Unsupported ternary operator: " + ternaryOperator);
-		}
-	}
-
-	public InferenceResult union(InferredType firstType, InferredType secondType) {
-		// defense programming
-		if (firstType == null || secondType == null) {
-			throw new NullPointerException("firstType and secondType may not be null.");
-		}
-
-		// if the operand type could not be inferred, there is not much we can
-		// do here
-		if (firstType.getType() == null || secondType.getType() == null) {
-			return new InferenceResult(null, new InferenceIssue(
-					"Could not infer a type union, because not all given types were properly inferred in advance.",
-					IStatus.ERROR));
-		}
-
-		// infer the union of both given types
-		if (firstType.getType() instanceof PrimitiveType && secondType.getType() instanceof PrimitiveType) {
-			Type commonType = computeCommonType((PrimitiveType) firstType.getType(),
-					(PrimitiveType) secondType.getType());
-			if (commonType != null) {
-				return new InferenceResult(new InferredType(commonType));
-			} else {
-				// handle coercion of types
-				if (isNumericType(firstType) && isNumericType(secondType)) {
-					// integer to real coercion
-					if (isRealType(firstType)) {
-						return new InferenceResult(firstType);
-					} else {
-						return new InferenceResult(secondType);
-					}
-				}
-			}
-		}
-		return new InferenceResult(null, new InferenceIssue("Cannot compute a type union for the given types: "
-				+ firstType + ", " + secondType, IStatus.ERROR));
-	}
-
-	public List<Type> getTypes(InferenceResult inferenceResult) {
-		if (inferenceResult == null) {
-			throw new NullPointerException("InferenceResult result may not be null.");
-		}
-		// we do not evaluate constraints and we only have one type of a kind
-		if (inferenceResult.getType() == null) {
-			return Collections.<Type> emptyList();
-		} else {
-			return Collections.singletonList(inferenceResult.getType().getType());
-		}
-	}
-
-	public List<Type> getTypes() {
-		List<Type> types = new ArrayList<Type>();
-		types.add(getVoidType());
-		types.add(getBooleanType());
-		types.add(getIntegerType());
-		types.add(getRealType());
-		types.add(getStringType());
-		return types;
-	}
-
-	public boolean isVoidType(Type type) {
-		return EcoreUtil.equals(getVoidType(), type);
-	}
-
-	public boolean isVoidType(InferredType type) {
-		return isVoidType(type.getType());
-	}
-
-	public boolean isBooleanType(InferredType type) {
-		return isBooleanType(type.getType());
-	}
-
-	public boolean isBooleanType(Type type) {
-		return EcoreUtil.equals(getBooleanType(), type);
-	}
-
-	public boolean isRealType(Type type) {
-		return EcoreUtil.equals(getRealType(), type);
-	}
-
-	public boolean isRealType(InferredType type) {
-		return isRealType(type.getType());
-	}
-
-	public boolean isIntegerType(Type type) {
-		return EcoreUtil.equals(getIntegerType(), type);
-	}
-
-	public boolean isIntegerType(InferredType type) {
-		return isIntegerType(type.getType());
-	}
-
-	public boolean isStringType(Type type) {
-		return EcoreUtil.equals(getStringType(), type);
-	}
-
-	public boolean isStringType(InferredType type) {
-		return isStringType(type.getType());
-	}
-
-	public boolean isNumericType(Type type) {
-		return EcoreUtil.equals(getIntegerType(), type) || EcoreUtil.equals(getRealType(), type);
-	}
-
-	public boolean isNumericType(InferredType type) {
-		return isNumericType(type.getType());
-	}
-
-	public List<Type> getTypes(InferredType inferredType) {
-		if (inferredType == null) {
-			throw new NullPointerException("inferredType may not be null.");
-		}
-		return Collections.singletonList(inferredType.getType());
-	}
-
-	public Object defaultValue(Type type) {
-		if (isBooleanType(type))
-			return true;
-		if (isIntegerType(type))
-			return 0;
-		if (isRealType(type))
-			return 0.0;
-		if (isVoidType(type))
-			return null;
-		if (isStringType(type))
-			return "";
-		if (type instanceof EnumerationType) {
-			return ((EnumerationType) type).getEnumerator().get(0);
-		}
-		return null;
-		
-	}
-
-	public Object defaultValue(InferredType type) {
-		return defaultValue(type.getType());
-	}
-
-}

+ 4 - 6
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/validation/STextJavaValidator.java

@@ -40,8 +40,9 @@ import org.yakindu.base.expressions.expressions.ExpressionsPackage;
 import org.yakindu.base.expressions.expressions.FeatureCall;
 import org.yakindu.base.types.Event;
 import org.yakindu.base.types.Feature;
-import org.yakindu.base.types.ITypeSystem.InferenceIssue;
-import org.yakindu.base.types.ITypeSystem.InferenceResult;
+import org.yakindu.base.types.ITypeSystem;
+import org.yakindu.base.types.InferenceIssue;
+import org.yakindu.base.types.InferenceResult;
 import org.yakindu.base.types.Operation;
 import org.yakindu.base.types.Parameter;
 import org.yakindu.base.types.Property;
@@ -80,7 +81,6 @@ import org.yakindu.sct.model.stext.stext.StextPackage;
 import org.yakindu.sct.model.stext.stext.TimeEventSpec;
 import org.yakindu.sct.model.stext.stext.VariableDefinition;
 import org.yakindu.sct.model.stext.types.ISTextTypeInferrer;
-import org.yakindu.sct.model.stext.types.ISTextTypeSystem;
 
 import com.google.common.base.Predicate;
 import com.google.common.collect.Iterables;
@@ -126,7 +126,7 @@ public class STextJavaValidator extends AbstractSTextJavaValidator {
 	@Inject
 	private ISTextTypeInferrer typeInferrer;
 	@Inject
-	private ISTextTypeSystem typeSystem;
+	private ITypeSystem typeSystem;
 	@Inject
 	private STextGrammarAccess grammarAccess;
 	@Inject
@@ -627,10 +627,8 @@ public class STextJavaValidator extends AbstractSTextJavaValidator {
 	protected void report(InferenceResult result, EStructuralFeature feature) {
 		if (result.getIssues().isEmpty())
 			return;
-		// TODO: Sort issues by severity and evaluate severity
 		InferenceIssue error = Iterables.getLast(result.getIssues());
 		error(error.getMessage(), feature);
-
 	}
 
 	private INode findNode(EObject source, boolean sourceFound, INode root, Keyword keyword, int[] index) {