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

Merge pull request #967 from Yakindu/issue_965

Issue 965
Andreas Mülder 9 лет назад
Родитель
Сommit
030e58919d
38 измененных файлов с 478 добавлено и 247 удалено
  1. 131 113
      plugins/org.yakindu.base.expressions/src/org/yakindu/base/expressions/inferrer/ExpressionsTypeInferrer.java
  2. 1 1
      plugins/org.yakindu.base.expressions/src/org/yakindu/base/expressions/validation/ExpressionsJavaValidator.java
  3. 1 1
      plugins/org.yakindu.base.types.test/src/org/yakindu/base/types/test/AbstractTypeSystemTest.java
  4. 3 1
      plugins/org.yakindu.base.types/src-gen/org/yakindu/base/types/impl/ArrayTypeSpecifierImpl.java
  5. 62 43
      plugins/org.yakindu.base.types/src/org/yakindu/base/types/inferrer/AbstractTypeSystemInferrer.java
  6. 49 8
      plugins/org.yakindu.base.types/src/org/yakindu/base/types/inferrer/ITypeSystemInferrer.java
  7. 34 7
      plugins/org.yakindu.base.types/src/org/yakindu/base/types/typesystem/AbstractTypeSystem.java
  8. 1 1
      plugins/org.yakindu.base.types/src/org/yakindu/base/types/typesystem/GenericTypeSystem.java
  9. 11 5
      plugins/org.yakindu.base.types/src/org/yakindu/base/types/typesystem/ITypeSystem.java
  10. 6 0
      plugins/org.yakindu.sct.domain.generic.generator/src/org/yakindu/sct/domain/generic/generator/GenericGeneratorModule.java
  11. 7 0
      plugins/org.yakindu.sct.domain.generic.resource/.classpath
  12. 1 0
      plugins/org.yakindu.sct.domain.generic.resource/.gitignore
  13. 28 0
      plugins/org.yakindu.sct.domain.generic.resource/.project
  14. 7 0
      plugins/org.yakindu.sct.domain.generic.resource/.settings/org.eclipse.jdt.core.prefs
  15. 14 0
      plugins/org.yakindu.sct.domain.generic.resource/META-INF/MANIFEST.MF
  16. 5 0
      plugins/org.yakindu.sct.domain.generic.resource/build.properties
  17. 12 0
      plugins/org.yakindu.sct.domain.generic.resource/plugin.xml
  18. 15 0
      plugins/org.yakindu.sct.domain.generic.resource/pom.xml
  19. 10 2
      plugins/org.yakindu.sct.domain.generic/src/org/yakindu/sct/domain/generic/modules/ResourceModuleProvider.java
  20. 1 2
      plugins/org.yakindu.sct.domain.generic/META-INF/MANIFEST.MF
  21. 0 8
      plugins/org.yakindu.sct.domain.generic/plugin.xml
  22. 1 1
      plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/ExpressionCode.xtend
  23. 1 1
      plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/ExpressionCode.xtend
  24. 1 1
      plugins/org.yakindu.sct.generator.csharp/src/org/yakindu/sct/generator/csharp/ExpressionCode.xtend
  25. 1 1
      plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/ExpressionCode.xtend
  26. 32 31
      plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/inferrer/STextTypeInferrer.java
  27. 8 2
      plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/scoping/STextScopeProvider.java
  28. 3 3
      plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/validation/STextJavaValidator.java
  29. 1 1
      plugins/org.yakindu.sct.simulation.core.sexec/src/org/yakindu/sct/simulation/core/sexec/container/DefaultExecutionContextInitializer.xtend
  30. 1 0
      releng/org.yakindu.sct.releng/pom.xml
  31. 2 1
      test-plugins/org.yakindu.sct.generator.c.test/META-INF/MANIFEST.MF
  32. 2 1
      test-plugins/org.yakindu.sct.generator.cpp.test/META-INF/MANIFEST.MF
  33. 2 1
      test-plugins/org.yakindu.sct.generator.java.test/META-INF/MANIFEST.MF
  34. 2 1
      test-plugins/org.yakindu.sct.model.sgraph.test/META-INF/MANIFEST.MF
  35. 3 4
      test-plugins/org.yakindu.sct.model.sgraph.test/src/org/yakindu/sct/model/sgraph/test/SGraphTestModule.java
  36. 2 1
      test-plugins/org.yakindu.sct.model.stext.resource.test/META-INF/MANIFEST.MF
  37. 15 4
      test-plugins/org.yakindu.sct.model.stext.test/src/org/yakindu/sct/model/stext/test/util/AbstractTypeInferrerTest.java
  38. 2 1
      test-plugins/org.yakindu.sct.refactoring.tests/META-INF/MANIFEST.MF

+ 131 - 113
plugins/org.yakindu.base.expressions/src/org/yakindu/base/expressions/inferrer/ExpressionsTypeInferrer.java

@@ -17,6 +17,9 @@ import static org.yakindu.base.types.typesystem.ITypeSystem.REAL;
 import static org.yakindu.base.types.typesystem.ITypeSystem.STRING;
 import static org.yakindu.base.types.typesystem.ITypeSystem.VOID;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import org.eclipse.emf.common.util.EList;
 import org.eclipse.xtext.EcoreUtil2;
 import org.yakindu.base.expressions.expressions.AssignmentExpression;
@@ -53,6 +56,7 @@ import org.yakindu.base.types.Parameter;
 import org.yakindu.base.types.Property;
 import org.yakindu.base.types.Type;
 import org.yakindu.base.types.TypeAlias;
+import org.yakindu.base.types.TypeSpecifier;
 import org.yakindu.base.types.inferrer.AbstractTypeSystemInferrer;
 
 /**
@@ -61,137 +65,141 @@ import org.yakindu.base.types.inferrer.AbstractTypeSystemInferrer;
  */
 public class ExpressionsTypeInferrer extends AbstractTypeSystemInferrer implements ExpressionsTypeInferrerMessages {
 
-	public Type infer(AssignmentExpression e) {
-		Type type1 = inferTypeDispatch(e.getVarRef());
-		Type type2 = inferTypeDispatch(e.getExpression());
-		assertAssignable(type1, type2, String.format(ASSIGNMENT_OPERATOR, e.getOperator(), type1, type2));
+	public InferenceResult infer(AssignmentExpression e) {
+		InferenceResult result1 = inferTypeDispatch(e.getVarRef());
+		InferenceResult result2 = inferTypeDispatch(e.getExpression());
+		assertAssignable(result1, result2, String.format(ASSIGNMENT_OPERATOR, e.getOperator(), result1, result2));
 		return inferTypeDispatch(e.getVarRef());
 	}
 
-	public Type infer(ConditionalExpression e) {
-		Type type1 = inferTypeDispatch(e.getTrueCase());
-		Type type2 = inferTypeDispatch(e.getFalseCase());
-		assertCompatible(type1, type2, String.format(COMMON_TYPE, type1, type2));
-		assertIsSubType(inferTypeDispatch(e.getCondition()), getType(BOOLEAN), CONDITIONAL_BOOLEAN);
-		return getCommonType(type1, type2);
+	public InferenceResult infer(ConditionalExpression e) {
+		InferenceResult result1 = inferTypeDispatch(e.getTrueCase());
+		InferenceResult result2 = inferTypeDispatch(e.getFalseCase());
+		assertCompatible(result1, result2, String.format(COMMON_TYPE, result1, result2));
+		assertIsSubType(inferTypeDispatch(e.getCondition()), getResultFor(BOOLEAN), CONDITIONAL_BOOLEAN);
+		return getCommonType(result1, result2);
 	}
 
-	public Type infer(LogicalOrExpression e) {
-		Type type1 = inferTypeDispatch(e.getLeftOperand());
-		Type type2 = inferTypeDispatch(e.getRightOperand());
-		assertIsSubType(type1, getType(BOOLEAN), String.format(LOGICAL_OPERATORS, "||", type1, type2));
-		assertIsSubType(type2, getType(BOOLEAN), String.format(LOGICAL_OPERATORS, "||", type1, type2));
-		return getType(BOOLEAN);
+	public InferenceResult infer(LogicalOrExpression e) {
+		InferenceResult result1 = inferTypeDispatch(e.getLeftOperand());
+		InferenceResult result2 = inferTypeDispatch(e.getRightOperand());
+		assertIsSubType(result1, getResultFor(BOOLEAN), String.format(LOGICAL_OPERATORS, "||", result1, result2));
+		assertIsSubType(result2, getResultFor(BOOLEAN), String.format(LOGICAL_OPERATORS, "||", result1, result2));
+		return getResultFor(BOOLEAN);
 	}
 
-	public Type infer(LogicalAndExpression e) {
-		Type type1 = inferTypeDispatch(e.getLeftOperand());
-		Type type2 = inferTypeDispatch(e.getRightOperand());
-		assertIsSubType(type1, getType(BOOLEAN), String.format(LOGICAL_OPERATORS, "&&", type1, type2));
-		assertIsSubType(type2, getType(BOOLEAN), String.format(LOGICAL_OPERATORS, "&&", type1, type2));
-		return getType(BOOLEAN);
+	public InferenceResult infer(LogicalAndExpression e) {
+		InferenceResult result1 = inferTypeDispatch(e.getLeftOperand());
+		InferenceResult result2 = inferTypeDispatch(e.getRightOperand());
+		assertIsSubType(result1, getResultFor(BOOLEAN), String.format(LOGICAL_OPERATORS, "&&", result1, result2));
+		assertIsSubType(result2, getResultFor(BOOLEAN), String.format(LOGICAL_OPERATORS, "&&", result1, result2));
+		return getResultFor(BOOLEAN);
 	}
 
-	public Type infer(LogicalNotExpression e) {
-		Type type = inferTypeDispatch(e.getOperand());
-		assertIsSubType(type, getType(BOOLEAN), String.format(LOGICAL_OPERATOR, "!", type));
-		return getType(BOOLEAN);
+	public InferenceResult infer(LogicalNotExpression e) {
+		InferenceResult type = inferTypeDispatch(e.getOperand());
+		assertIsSubType(type, getResultFor(BOOLEAN), String.format(LOGICAL_OPERATOR, "!", type));
+		return getResultFor(BOOLEAN);
 	}
 
-	public Type infer(BitwiseXorExpression e) {
-		Type type1 = inferTypeDispatch(e.getLeftOperand());
-		Type type2 = inferTypeDispatch(e.getRightOperand());
-		assertIsSubType(type1, getType(INTEGER), String.format(BITWISE_OPERATORS, "^", type1, type2));
-		assertIsSubType(type2, getType(INTEGER), String.format(BITWISE_OPERATORS, "^", type1, type2));
-		return getType(INTEGER);
+	public InferenceResult infer(BitwiseXorExpression e) {
+		InferenceResult result1 = inferTypeDispatch(e.getLeftOperand());
+		InferenceResult result2 = inferTypeDispatch(e.getRightOperand());
+		assertIsSubType(result1, getResultFor(INTEGER), String.format(BITWISE_OPERATORS, "^", result1, result2));
+		assertIsSubType(result2, getResultFor(INTEGER), String.format(BITWISE_OPERATORS, "^", result1, result2));
+		return getResultFor(INTEGER);
 	}
 
-	public Type infer(BitwiseOrExpression e) {
-		Type type1 = inferTypeDispatch(e.getLeftOperand());
-		Type type2 = inferTypeDispatch(e.getRightOperand());
-		assertIsSubType(type1, getType(INTEGER), String.format(BITWISE_OPERATORS, "|", type1, type2));
-		assertIsSubType(type2, getType(INTEGER), String.format(BITWISE_OPERATORS, "|", type1, type2));
-		return getType(INTEGER);
+	public InferenceResult infer(BitwiseOrExpression e) {
+		InferenceResult result1 = inferTypeDispatch(e.getLeftOperand());
+		InferenceResult result2 = inferTypeDispatch(e.getRightOperand());
+		assertIsSubType(result1, getResultFor(INTEGER), String.format(BITWISE_OPERATORS, "|", result1, result2));
+		assertIsSubType(result2, getResultFor(INTEGER), String.format(BITWISE_OPERATORS, "|", result1, result2));
+		return getResultFor(INTEGER);
 	}
 
-	public Type infer(BitwiseAndExpression e) {
-		Type type1 = inferTypeDispatch(e.getLeftOperand());
-		Type type2 = inferTypeDispatch(e.getRightOperand());
-		assertIsSubType(type1, getType(INTEGER), String.format(BITWISE_OPERATORS, "&", type1, type2));
-		assertIsSubType(type2, getType(INTEGER), String.format(BITWISE_OPERATORS, "&", type1, type2));
-		return getType(INTEGER);
+	public InferenceResult infer(BitwiseAndExpression e) {
+		InferenceResult result1 = inferTypeDispatch(e.getLeftOperand());
+		InferenceResult result2 = inferTypeDispatch(e.getRightOperand());
+		assertIsSubType(result1, getResultFor(INTEGER), String.format(BITWISE_OPERATORS, "&", result1, result2));
+		assertIsSubType(result2, getResultFor(INTEGER), String.format(BITWISE_OPERATORS, "&", result1, result2));
+		return getResultFor(INTEGER);
 	}
 
-	public Type infer(ShiftExpression e) {
-		Type type1 = inferTypeDispatch(e.getLeftOperand());
-		Type type2 = inferTypeDispatch(e.getRightOperand());
-		assertIsSubType(type1, getType(INTEGER), String.format(BITWISE_OPERATORS, e.getOperator(), type1, type2));
-		assertIsSubType(type2, getType(INTEGER), String.format(BITWISE_OPERATORS, e.getOperator(), type1, type2));
-		return getType(INTEGER);
+	public InferenceResult infer(ShiftExpression e) {
+		InferenceResult result1 = inferTypeDispatch(e.getLeftOperand());
+		InferenceResult result2 = inferTypeDispatch(e.getRightOperand());
+		assertIsSubType(result1, getResultFor(INTEGER),
+				String.format(BITWISE_OPERATORS, e.getOperator(), result1, result2));
+		assertIsSubType(result2, getResultFor(INTEGER),
+				String.format(BITWISE_OPERATORS, e.getOperator(), result1, result2));
+		return getResultFor(INTEGER);
 	}
 
-	public Type infer(LogicalRelationExpression e) {
-		Type type1 = inferTypeDispatch(e.getLeftOperand());
-		Type type2 = inferTypeDispatch(e.getRightOperand());
-		assertCompatible(type1, type2, String.format(COMPARSION_OPERATOR, e.getOperator(), type1, type2));
-		Type result = getType(BOOLEAN);
+	public InferenceResult infer(LogicalRelationExpression e) {
+		InferenceResult result1 = inferTypeDispatch(e.getLeftOperand());
+		InferenceResult result2 = inferTypeDispatch(e.getRightOperand());
+		assertCompatible(result1, result2, String.format(COMPARSION_OPERATOR, e.getOperator(), result1, result2));
+		InferenceResult result = getResultFor(BOOLEAN);
 		return result;
 	}
 
-	public Type infer(NumericalAddSubtractExpression e) {
-		Type type1 = inferTypeDispatch(e.getLeftOperand());
-		Type type2 = inferTypeDispatch(e.getRightOperand());
-		assertCompatible(type1, type2, String.format(ARITHMETIC_OPERATORS, e.getOperator(), type1, type2));
-		assertIsSubType(type1, getType(REAL), String.format(ARITHMETIC_OPERATORS, e.getOperator(), type1, type2));
-		return getCommonType(e.getLeftOperand(), e.getRightOperand());
+	public InferenceResult infer(NumericalAddSubtractExpression e) {
+		InferenceResult result1 = inferTypeDispatch(e.getLeftOperand());
+		InferenceResult result2 = inferTypeDispatch(e.getRightOperand());
+		assertCompatible(result1, result2, String.format(ARITHMETIC_OPERATORS, e.getOperator(), result1, result2));
+		assertIsSubType(result1, getResultFor(REAL),
+				String.format(ARITHMETIC_OPERATORS, e.getOperator(), result1, result2));
+		return getCommonType(inferTypeDispatch(e.getLeftOperand()), inferTypeDispatch(e.getRightOperand()));
 	}
 
-	public Type infer(NumericalMultiplyDivideExpression e) {
-		Type type1 = inferTypeDispatch(e.getLeftOperand());
-		Type type2 = inferTypeDispatch(e.getRightOperand());
-		assertCompatible(type1, type2, String.format(ARITHMETIC_OPERATORS, e.getOperator(), type1, type2));
-		assertIsSubType(type1, getType(REAL), String.format(ARITHMETIC_OPERATORS, e.getOperator(), type1, type2));
-		return getCommonType(type1, type2);
+	public InferenceResult infer(NumericalMultiplyDivideExpression e) {
+		InferenceResult result1 = inferTypeDispatch(e.getLeftOperand());
+		InferenceResult result2 = inferTypeDispatch(e.getRightOperand());
+		assertCompatible(result1, result2, String.format(ARITHMETIC_OPERATORS, e.getOperator(), result1, result2));
+		assertIsSubType(result1, getResultFor(REAL),
+				String.format(ARITHMETIC_OPERATORS, e.getOperator(), result1, result2));
+		return getCommonType(result1, result2);
 	}
 
-	public Type infer(NumericalUnaryExpression e) {
-		Type type1 = inferTypeDispatch(e.getOperand());
+	public InferenceResult infer(NumericalUnaryExpression e) {
+		InferenceResult result1 = inferTypeDispatch(e.getOperand());
 		if (e.getOperator() == UnaryOperator.COMPLEMENT)
-			assertIsSubType(type1, getType(INTEGER), String.format(BITWISE_OPERATOR, '~', type1));
+			assertIsSubType(result1, getResultFor(INTEGER), String.format(BITWISE_OPERATOR, '~', result1));
 		else {
-			assertIsSubType(type1, getType(REAL), String.format(ARITHMETIC_OPERATOR, e.getOperator(), type1));
+			assertIsSubType(result1, getResultFor(REAL), String.format(ARITHMETIC_OPERATOR, e.getOperator(), result1));
 		}
-		return type1;
+		return result1;
 	}
 
-	public Type infer(TypeCastExpression e) {
-		Type type1 = inferTypeDispatch(e.getOperand());
-		Type type2 = inferTypeDispatch(e.getType());
-		assertCompatible(type1, type2, String.format(CAST_OPERATORS, type1, type2));
+	public InferenceResult infer(TypeCastExpression e) {
+		InferenceResult result1 = inferTypeDispatch(e.getOperand());
+		InferenceResult result2 = inferTypeDispatch(e.getType());
+		assertCompatible(result1, result2, String.format(CAST_OPERATORS, result1, result2));
 		return inferTypeDispatch(e.getType());
 	}
 
-	public Type infer(EnumerationType enumType) {
-		return enumType;
+	public InferenceResult infer(EnumerationType enumType) {
+		return InferenceResult.from(enumType);
 	}
 
-	public Type infer(Enumerator enumerator) {
-		return EcoreUtil2.getContainerOfType(enumerator, Type.class);
+	public InferenceResult infer(Enumerator enumerator) {
+		return InferenceResult.from(EcoreUtil2.getContainerOfType(enumerator, Type.class));
 	}
 
-	public Type infer(Type type) {
-		return type.getOriginType();
+	public InferenceResult infer(Type type) {
+		return InferenceResult.from(type.getOriginType());
 	}
 
 	/**
 	 * The type of a type alias is its (recursively inferred) base type, i.e.
 	 * type aliases are assignable if their inferred base types are assignable.
 	 */
-	public Object infer(TypeAlias typeAlias) {
-		return inferTypeDispatch(typeAlias.getType());
+	public InferenceResult infer(TypeAlias typeAlias) {
+		return inferTypeDispatch(typeAlias.getTypeSpecifier());
 	}
 
-	public Type infer(FeatureCall e) {
+	public InferenceResult infer(FeatureCall e) {
 		if (e.isOperationCall()) {
 			Operation operation = (Operation) e.getFeature();
 			EList<Parameter> parameters = operation.getParameters();
@@ -201,7 +209,7 @@ public class ExpressionsTypeInferrer extends AbstractTypeSystemInferrer implemen
 		return inferTypeDispatch(e.getFeature());
 	}
 
-	public Type infer(ElementReferenceExpression e) {
+	public InferenceResult infer(ElementReferenceExpression e) {
 		if (e.isOperationCall()) {
 			Operation operation = (Operation) e.getReference();
 			EList<Parameter> parameters = operation.getParameters();
@@ -214,60 +222,70 @@ public class ExpressionsTypeInferrer extends AbstractTypeSystemInferrer implemen
 	protected void inferParameter(EList<Parameter> parameters, EList<Expression> args) {
 		if (parameters.size() == args.size()) {
 			for (int i = 0; i < parameters.size(); i++) {
-				Type type1 = inferTypeDispatch(parameters.get(i));
-				Type type2 = inferTypeDispatch(args.get(i));
-				assertCompatible(type2, type1, String.format(INCOMPATIBLE_TYPES, type2, type1));
+				InferenceResult result1 = inferTypeDispatch(parameters.get(i));
+				InferenceResult result2 = inferTypeDispatch(args.get(i));
+				assertCompatible(result2, result1, String.format(INCOMPATIBLE_TYPES, result2, result1));
 			}
 		}
 	}
 
-	public Type infer(ParenthesizedExpression e) {
+	public InferenceResult infer(ParenthesizedExpression e) {
 		return inferTypeDispatch(e.getExpression());
 	}
 
-	public Type infer(PrimitiveValueExpression e) {
+	public InferenceResult infer(PrimitiveValueExpression e) {
 		return inferTypeDispatch(e.getValue());
 	}
 
-	public Type infer(BoolLiteral literal) {
-		return getType(BOOLEAN);
+	public InferenceResult infer(BoolLiteral literal) {
+		return getResultFor(BOOLEAN);
 	}
 
-	public Type infer(IntLiteral literal) {
-		return getType(INTEGER);
+	public InferenceResult infer(IntLiteral literal) {
+		return getResultFor(INTEGER);
 	}
 
-	public Type infer(HexLiteral literal) {
-		return getType(INTEGER);
+	public InferenceResult infer(HexLiteral literal) {
+		return getResultFor(INTEGER);
 	}
 
-	public Type infer(DoubleLiteral literal) {
-		return getType(REAL);
+	public InferenceResult infer(DoubleLiteral literal) {
+		return getResultFor(REAL);
 	}
 
-	public Type infer(FloatLiteral literal) {
-		return getType(REAL);
+	public InferenceResult infer(FloatLiteral literal) {
+		return getResultFor(REAL);
 	}
 
-	public Type infer(StringLiteral literal) {
-		return getType(STRING);
+	public InferenceResult infer(StringLiteral literal) {
+		return getResultFor(STRING);
 	}
 
-	public Type infer(NullLiteral literal) {
-		return getType(NULL);
+	public InferenceResult infer(NullLiteral literal) {
+		return getResultFor(NULL);
 	}
 
-	public Object infer(Property p) {
-		Type type = inferTypeDispatch(p.getType());
-		assertNotType(type, VARIABLE_VOID_TYPE, getType(VOID));
-		return inferTypeDispatch(type);
+	public InferenceResult infer(Property p) {
+		InferenceResult type = inferTypeDispatch(p.getTypeSpecifier());
+		assertNotType(type, VARIABLE_VOID_TYPE, getResultFor(VOID));
+		return type;
 	}
 
-	public Object infer(Operation e) {
-		return inferTypeDispatch(e.getType() != null ? e.getType() : getType(VOID));
+	public InferenceResult infer(Operation e) {
+		return e.getTypeSpecifier() == null ? getResultFor(VOID) : inferTypeDispatch(e.getTypeSpecifier());
 	}
 
-	public Object infer(Parameter e) {
-		return inferTypeDispatch(e.getType());
+	public InferenceResult infer(Parameter e) {
+		return inferTypeDispatch(e.getTypeSpecifier());
+	}
+
+	public InferenceResult infer(TypeSpecifier specifier) {
+		List<InferenceResult> bindings = new ArrayList<>();
+		EList<TypeSpecifier> arguments = specifier.getTypeArguments();
+		for (TypeSpecifier typeSpecifier : arguments) {
+			bindings.add(inferTypeDispatch(typeSpecifier));
+		}
+		return InferenceResult.from(inferTypeDispatch(specifier.getType()).getType(), bindings);
+
 	}
 }

+ 1 - 1
plugins/org.yakindu.base.expressions/src/org/yakindu/base/expressions/validation/ExpressionsJavaValidator.java

@@ -66,7 +66,7 @@ public class ExpressionsJavaValidator extends org.yakindu.base.expressions.valid
 	public void checkExpression(Expression expression) {
 		//Only infer root expressions since inferType infers the expression containment hierarchy
 		if(!(expression.eContainer() instanceof Expression))
-			typeInferrer.inferType(expression, this);
+			typeInferrer.infer(expression, this);
 	}
 
 	public void accept(ValidationIssue issue) {

+ 1 - 1
plugins/org.yakindu.base.types.test/src/org/yakindu/base/types/test/AbstractTypeSystemTest.java

@@ -41,7 +41,7 @@ public class AbstractTypeSystemTest extends AbstractTypeSystem {
 	private Type conversionSubType;
 
 	@Override
-	protected void initBuiltInTypes() {
+	protected void initRegistries() {
 		// SubType extends SuperType
 		superType = createPrimitive(SUPER_TYPE);
 		declareType(superType, SUPER_TYPE);

+ 3 - 1
plugins/org.yakindu.base.types/src-gen/org/yakindu/base/types/impl/ArrayTypeSpecifierImpl.java

@@ -92,7 +92,9 @@ public class ArrayTypeSpecifierImpl extends TypeSpecifierImpl implements ArrayTy
 	 * @generated NOT
 	 */
 	public Type getElementType() {
-		return getTypeArguments().get(0).getType();
+		if (getTypeArguments().size() > 0)
+			return getTypeArguments().get(0).getType();
+		return null;
 	}
 
 	/**

+ 62 - 43
plugins/org.yakindu.base.types/src/org/yakindu/base/types/inferrer/AbstractTypeSystemInferrer.java

@@ -13,6 +13,7 @@ package org.yakindu.base.types.inferrer;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.List;
 
 import org.eclipse.emf.ecore.EObject;
 import org.eclipse.xtext.util.PolymorphicDispatcher;
@@ -40,7 +41,7 @@ public abstract class AbstractTypeSystemInferrer implements ITypeSystemInferrer
 	protected static final String ASSERT_NOT_TYPE = "Expected type is not %s.";
 	protected static final String ASSERT_SAME = "Expected types %s and %s are same.";
 	protected static final String ASSERT_COMPATIBLE = "Incompatible types %s and %s.";
-	
+
 	private static final String METHOD_NAME = "infer";
 
 	@Inject
@@ -50,30 +51,35 @@ public abstract class AbstractTypeSystemInferrer implements ITypeSystemInferrer
 
 	private PolymorphicDispatcher<Object> dispatcher;
 
-	private LoadingCache<EObject, Type> typeCache;
+	private LoadingCache<EObject, InferenceResult> typeCache;
 
 	public AbstractTypeSystemInferrer() {
 		initDispatcher();
 	}
 
-	protected Type getType(String name) {
-		return registry.getType(name);
+	protected InferenceResult getResultFor(String name) {
+		return InferenceResult.from(registry.getType(name));
+	}
+
+	protected InferenceResult getCommonType(InferenceResult result1, InferenceResult result2) {
+		return InferenceResult.from(registry.getCommonType(result1.getType(), result2.getType()));
 	}
 
-	protected Type getCommonType(EObject object1, EObject object2) {
-		return registry.getCommonType(inferTypeDispatch(object1), inferTypeDispatch(object2));
+	@Override
+	public final InferenceResult infer(EObject object) {
+		return infer(object, null);
 	}
 
 	@Override
-	public final Type inferType(EObject object, IValidationIssueAcceptor acceptor) {
+	public final InferenceResult infer(EObject object, IValidationIssueAcceptor acceptor) {
 		initTypeCache();
 		this.acceptor = (acceptor != null ? acceptor : new ListBasedValidationIssueAcceptor());
-		Type result = inferTypeDispatch(object);
+		InferenceResult result = inferTypeDispatch(object);
 		typeCache.invalidateAll();
 		return result;
 	}
 
-	protected Type inferTypeDispatch(EObject object) {
+	protected InferenceResult inferTypeDispatch(EObject object) {
 		if (object == null || object.eIsProxy())
 			return null;
 		try {
@@ -85,22 +91,23 @@ public abstract class AbstractTypeSystemInferrer implements ITypeSystemInferrer
 	}
 
 	private void initTypeCache() {
-		typeCache = CacheBuilder.newBuilder().maximumSize(100).build(new CacheLoader<EObject, Type>() {
-			
-			public Type load(EObject key) {
-				// TODO: this is not relevant anymore as we do not declare type aliases in type system
+		typeCache = CacheBuilder.newBuilder().maximumSize(100).build(new CacheLoader<EObject, InferenceResult>() {
+
+			public InferenceResult load(EObject key) {
+				// TODO: this is not relevant anymore as we do not declare type
+				// aliases in type system
 				if (key instanceof TypeAlias) {
 					// for type aliases we want to infer their base types
-					return (Type) (EObject) dispatcher.invoke(key);
+					return (InferenceResult) dispatcher.invoke(key);
 				}
 				if (key instanceof Type) {
 					Collection<Type> types = registry.getTypes();
 					for (Type type : types) {
 						if (registry.isSame((Type) key, type))
-							return type;
+							return InferenceResult.from(type);
 					}
 				}
-				return (Type) (EObject) dispatcher.invoke(key);
+				return (InferenceResult) dispatcher.invoke(key);
 			}
 		});
 	}
@@ -120,52 +127,64 @@ public abstract class AbstractTypeSystemInferrer implements ITypeSystemInferrer
 				});
 	}
 
-	protected void assertNotType(Type currentType, String msg, Type... candidates) {
-		if (currentType == null)
+	protected void assertNotType(InferenceResult currentResult, String msg, InferenceResult... candidates) {
+		if (currentResult == null)
 			return;
-		for (Type type : candidates) {
-			if (registry.isSame(currentType, type)) {
-				error(msg != null ? msg : String.format(ASSERT_NOT_TYPE, currentType), NOT_TYPE_CODE);
+		for (InferenceResult type : candidates) {
+			if (registry.isSame(currentResult.getType(), type.getType())) {
+				error(msg != null ? msg : String.format(ASSERT_NOT_TYPE, currentResult), NOT_TYPE_CODE);
 			}
 		}
 	}
 
-	protected void assertSame(Type type1, Type type2, String msg) {
-		if (type1 == null || type2 == null)
+	protected void assertSame(InferenceResult result1, InferenceResult result2, String msg) {
+		if (result1 == null || result2 == null)
 			return;
-		if (!registry.isSame(type1, type2)) {
-			error(msg != null ? msg : String.format(ASSERT_SAME, type1, type2), NOT_SAME_CODE);
+		if (!registry.isSame(result1.getType(), result2.getType())) {
+			error(msg != null ? msg : String.format(ASSERT_SAME, result1, result2), NOT_SAME_CODE);
 		}
+
+		assertTypeBindingsSame(result1, result2, msg);
 	}
 
-	protected void assertCompatible(Type type1, Type type2, String msg) {
-		if (type1 == null || type2 == null)
+	protected void assertCompatible(InferenceResult result1, InferenceResult result2, String msg) {
+		if (result1 == null || result2 == null)
+			return;
+		if (!registry.haveCommonType(result1.getType(), result2.getType())) {
+			error(msg != null ? msg : String.format(ASSERT_COMPATIBLE, result1, result2), NOT_COMPATIBLE_CODE);
 			return;
-		if (!registry.haveCommonType(type1, type2)) {
-			error(msg != null ? msg : String.format(ASSERT_COMPATIBLE, type1, type2), NOT_COMPATIBLE_CODE);
 		}
+		assertTypeBindingsSame(result1, result2, msg);
+
 	}
-	protected void assertCompatibleWithConversion(Type type1, Type type2, String msg) {
-		if (type1 == null || type2 == null)
+
+	protected void assertAssignable(InferenceResult varResult, InferenceResult valueResult, String msg) {
+		if (varResult == null || valueResult == null)
+			return;
+		if (!registry.isSuperType(valueResult.getType(), varResult.getType())) {
+			error(msg != null ? msg : String.format(ASSERT_COMPATIBLE, varResult, valueResult), NOT_COMPATIBLE_CODE);
 			return;
-		if (!registry.haveCommonTypeWithConversion(type1, type2)) {
-			error(msg != null ? msg : String.format(ASSERT_COMPATIBLE, type1, type2), NOT_COMPATIBLE_CODE);
 		}
+		assertTypeBindingsSame(varResult, valueResult, msg);
 	}
-	
-	protected void assertAssignable(Type varType, Type valueType, String msg) {
-		if (varType == null || valueType == null)
+
+	protected void assertTypeBindingsSame(InferenceResult result1, InferenceResult result2, String msg) {
+		List<InferenceResult> bindings1 = result1.getBindings();
+		List<InferenceResult> bindings2 = result2.getBindings();
+		if (bindings1.size() != bindings2.size()) {
+			error(msg != null ? msg : String.format(ASSERT_COMPATIBLE, result1, result2), NOT_COMPATIBLE_CODE);
 			return;
-		if (!registry.isSuperType(valueType, varType)) {
-			error(msg != null ? msg : String.format(ASSERT_COMPATIBLE, varType, valueType), NOT_COMPATIBLE_CODE);
+		}
+		for (int i = 0; i < bindings1.size(); i++) {
+			assertSame(bindings1.get(i), bindings2.get(i), msg);
 		}
 	}
-	
-	protected void assertIsSubType(Type subtype, Type supertype, String msg) {
-		if (subtype == null || supertype == null)
+
+	protected void assertIsSubType(InferenceResult subResult, InferenceResult superResult, String msg) {
+		if (subResult == null || superResult == null)
 			return;
-		if (!registry.isSuperType(subtype, supertype)) {
-			error(msg != null ? msg : String.format(ASSERT_COMPATIBLE, subtype, supertype), NOT_COMPATIBLE_CODE);
+		if (!registry.isSuperType(subResult.getType(), superResult.getType())) {
+			error(msg != null ? msg : String.format(ASSERT_COMPATIBLE, subResult, superResult), NOT_COMPATIBLE_CODE);
 		}
 	}
 

+ 49 - 8
plugins/org.yakindu.base.types/src/org/yakindu/base/types/inferrer/ITypeSystemInferrer.java

@@ -10,17 +10,17 @@
  */
 package org.yakindu.base.types.inferrer;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import org.eclipse.emf.ecore.EObject;
 import org.yakindu.base.types.Type;
 import org.yakindu.base.types.validation.IValidationIssueAcceptor;
 
-import com.google.inject.ImplementedBy;
-
 /**
  * @author andreas muelder - Initial contribution and API
  * 
  */
-@ImplementedBy(ITypeSystemInferrer.NullTypeInferrer.class)
 public interface ITypeSystemInferrer {
 
 	public static final String EXCEPTION_CODE = "RuntimeExcpetion";
@@ -30,15 +30,56 @@ public interface ITypeSystemInferrer {
 	public static final String NOT_SAME_CODE = "NotSame";
 	public static final String NOT_COMPATIBLE_CODE = "IncompatibleTypes";
 
-	public Type inferType(EObject object, IValidationIssueAcceptor acceptor);
+	public static class InferenceResult {
 
-	public static class NullTypeInferrer implements ITypeSystemInferrer {
+		private Type type;
+		private List<InferenceResult> bindings = new ArrayList<>();
 
-		@Override
-		public Type inferType(EObject object, IValidationIssueAcceptor acceptor) {
-			return null;
+		protected InferenceResult(Type type) {
+			this.type = type;
+		}
+
+		protected InferenceResult(Type type, List<InferenceResult> bindings) {
+			this.type = type;
+			this.bindings.addAll(bindings);
+		}
+
+		public static InferenceResult from(Type type) {
+			return new InferenceResult(type);
+		}
+
+		public static InferenceResult from(Type type, List<InferenceResult> bindings) {
+			return new InferenceResult(type, bindings);
 		}
 
+		public Type getType() {
+			return type;
+		}
+
+		public List<InferenceResult> getBindings() {
+			return bindings;
+		}
+
+		@Override
+		public String toString() {
+			StringBuilder builder = new StringBuilder();
+			builder.append(type.toString());
+			if (bindings.size() > 0) {
+				builder.append("<");
+				String sep = "";
+				for (InferenceResult type : bindings) {
+					builder.append(sep);
+					builder.append(type.toString());
+					sep = ",";
+				}
+				builder.append(">");
+			}
+			return builder.toString();
+		}
 	}
 
+	public InferenceResult infer(EObject object, IValidationIssueAcceptor acceptor);
+
+	public InferenceResult infer(EObject object);
+
 }

+ 34 - 7
plugins/org.yakindu.base.types/src/org/yakindu/base/types/typesystem/AbstractTypeSystem.java

@@ -23,7 +23,9 @@ 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.ComplexType;
+import org.yakindu.base.types.Operation;
 import org.yakindu.base.types.PrimitiveType;
+import org.yakindu.base.types.Property;
 import org.yakindu.base.types.Type;
 import org.yakindu.base.types.TypesFactory;
 import org.yakindu.base.types.annotations.TypeAnnotations;
@@ -42,18 +44,21 @@ public abstract class AbstractTypeSystem implements ITypeSystem {
 
 	protected Map<String, Type> typeRegistry = new HashMap<String, Type>();
 	protected ListMultimap<Type, Type> extendsRegistry = ArrayListMultimap.create();
+	protected ListMultimap<Type, Operation> extensionOperationRegistry = ArrayListMultimap.create();
+	protected ListMultimap<Type, Property> extensionPropertyRegistry = ArrayListMultimap.create();
+
 	protected Map<Type, Type> conversionRegistry = new HashMap<Type, Type>();
 
-	protected abstract void initBuiltInTypes();
+	protected abstract void initRegistries();
 
 	protected Resource resource;
-	
+
 	protected TypeAnnotations typeAnnotations;
 
 	public AbstractTypeSystem() {
 		resource = new ResourceImpl(URI.createURI("types"));
 		typeAnnotations = new TypeAnnotations();
-		initBuiltInTypes();
+		initRegistries();
 	}
 
 	protected void reset() {
@@ -81,7 +86,7 @@ public abstract class AbstractTypeSystem implements ITypeSystem {
 			ComplexType complexType = (ComplexType) type;
 			superTypes.addAll(complexType.getSuperTypes());
 		}
-		
+
 		return superTypes;
 	}
 
@@ -99,7 +104,7 @@ public abstract class AbstractTypeSystem implements ITypeSystem {
 	private void collectSupertypes(Type subtypeClass, List<Type> typeHierachy) {
 		if (subtypeClass == null)
 			return;
-		
+
 		List<Type> superTypes = getSuperTypes(subtypeClass);
 		for (Type superType : superTypes) {
 			typeHierachy.add(superType);
@@ -217,13 +222,35 @@ public abstract class AbstractTypeSystem implements ITypeSystem {
 	protected Type getConversionType(Type sourceType) {
 		return conversionRegistry.get(sourceType);
 	}
-	
+
 	public Resource getResource() {
 		return resource;
 	}
-	
+
 	@Override
 	public boolean isBuiltInType(Type type) {
 		return typeAnnotations.hasBuiltInTypeAnnotation(type);
 	}
+
+	@Override
+	public List<Operation> getOperationExtensions(Type type) {
+		List<Operation> result = new ArrayList<>();
+		result.addAll(extensionOperationRegistry.get(type));
+		List<Type> superTypes = getSuperTypes(type);
+		for (Type superType : superTypes) {
+			result.addAll(extensionOperationRegistry.get(superType));
+		}
+		return result;
+	}
+
+	@Override
+	public List<Property> getPropertyExtensions(Type type) {
+		List<Property> result = new ArrayList<>();
+		result.addAll(extensionPropertyRegistry.get(type));
+		List<Type> superTypes = getSuperTypes(type);
+		for (Type superType : superTypes) {
+			result.addAll(extensionPropertyRegistry.get(superType));
+		}
+		return result;
+	}
 }

+ 1 - 1
plugins/org.yakindu.base.types/src/org/yakindu/base/types/typesystem/GenericTypeSystem.java

@@ -30,7 +30,7 @@ public class GenericTypeSystem extends AbstractTypeSystem {
 	}
 
 	@Override
-	protected void initBuiltInTypes() {
+	protected void initRegistries() {
 		declarePrimitive(STRING);
 		declarePrimitive(REAL);
 		declarePrimitive(INTEGER);

+ 11 - 5
plugins/org.yakindu.base.types/src/org/yakindu/base/types/typesystem/ITypeSystem.java

@@ -13,6 +13,8 @@ package org.yakindu.base.types.typesystem;
 import java.util.Collection;
 import java.util.List;
 
+import org.yakindu.base.types.Operation;
+import org.yakindu.base.types.Property;
 import org.yakindu.base.types.Type;
 
 /**
@@ -23,7 +25,7 @@ import org.yakindu.base.types.Type;
  * 
  */
 public interface ITypeSystem {
-	
+
 	public static final String STRING = "string";
 	public static final String REAL = "real";
 	public static final String INTEGER = "integer";
@@ -32,11 +34,11 @@ public interface ITypeSystem {
 	public static final String NULL = "null";
 
 	public Collection<Type> getTypes();
-	
+
 	public Collection<Type> getConcreteTypes();
 
 	public Type getType(String name);
-	
+
 	public boolean isSame(Type type1, Type type2);
 
 	public boolean haveCommonType(Type type1, Type type2);
@@ -46,11 +48,15 @@ public interface ITypeSystem {
 	public boolean haveCommonTypeWithConversion(Type type1, Type type2);
 
 	public Type getCommonTypeWithConversion(Type type1, Type type2);
-	
+
 	public List<Type> getSuperTypes(Type type);
 
 	public boolean isSuperType(Type subtype, Type supertype);
-	
+
 	public boolean isBuiltInType(Type type);
 
+	public List<Operation> getOperationExtensions(Type type);
+
+	public List<Property> getPropertyExtensions(Type type);
+
 }

+ 6 - 0
plugins/org.yakindu.sct.domain.generic.generator/src/org/yakindu/sct/domain/generic/generator/GenericGeneratorModule.java

@@ -14,8 +14,10 @@ package org.yakindu.sct.domain.generic.generator;
 import org.eclipse.xtext.naming.IQualifiedNameProvider;
 import org.eclipse.xtext.service.AbstractGenericModule;
 import org.eclipse.xtext.validation.IResourceValidator;
+import org.yakindu.base.types.inferrer.ITypeSystemInferrer;
 import org.yakindu.base.types.typesystem.GenericTypeSystem;
 import org.yakindu.base.types.typesystem.ITypeSystem;
+import org.yakindu.sct.model.stext.inferrer.STextTypeInferrer;
 import org.yakindu.sct.model.stext.naming.StextNameProvider;
 import org.yakindu.sct.model.stext.resource.SCTResourceValidatorImpl;
 
@@ -44,4 +46,8 @@ public class GenericGeneratorModule extends AbstractGenericModule {
 		return SCTResourceValidatorImpl.class;
 	}
 
+	public Class<? extends ITypeSystemInferrer> bindITypeSystemInferrer() {
+		return STextTypeInferrer.class;
+	}
+
 }

+ 7 - 0
plugins/org.yakindu.sct.domain.generic.resource/.classpath

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>

+ 1 - 0
plugins/org.yakindu.sct.domain.generic.resource/.gitignore

@@ -0,0 +1 @@
+/bin/

+ 28 - 0
plugins/org.yakindu.sct.domain.generic.resource/.project

@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.yakindu.sct.domain.generic.resource</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.ManifestBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.SchemaBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.pde.PluginNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

+ 7 - 0
plugins/org.yakindu.sct.domain.generic.resource/.settings/org.eclipse.jdt.core.prefs

@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.7

+ 14 - 0
plugins/org.yakindu.sct.domain.generic.resource/META-INF/MANIFEST.MF

@@ -0,0 +1,14 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Resource
+Bundle-SymbolicName: org.yakindu.sct.domain.generic.resource;singleton:=true
+Bundle-Version: 2.7.1.qualifier
+Bundle-Vendor: statecharts.org
+Bundle-RequiredExecutionEnvironment: JavaSE-1.7
+Require-Bundle: org.yakindu.sct.domain,
+ com.google.inject,
+ org.yakindu.sct.model.stext,
+ org.yakindu.sct.model.stext.ui,
+ org.eclipse.xtext.ui
+Export-Package: org.yakindu.sct.domain.generic.resource
+Import-Package: org.eclipse.xtext.ui.shared

+ 5 - 0
plugins/org.yakindu.sct.domain.generic.resource/build.properties

@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .,\
+               plugin.xml

+ 12 - 0
plugins/org.yakindu.sct.domain.generic.resource/plugin.xml

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+<extension
+      point="org.yakindu.sct.domain.modules">
+   <Module
+         domainID="org.yakindu.domain.default"
+         feature="org.yakindu.sct.resource"
+         moduleProvider="org.yakindu.sct.domain.generic.resource.ResourceModuleProvider">
+   </Module>
+</extension>
+</plugin>

+ 15 - 0
plugins/org.yakindu.sct.domain.generic.resource/pom.xml

@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+	xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+	<modelVersion>4.0.0</modelVersion>
+	<parent>
+		<groupId>org.yakindu.sct</groupId>
+		<artifactId>org.yakindu.sct.releng</artifactId>
+		<version>2.7.1-SNAPSHOT</version>
+		<relativePath>../../releng/org.yakindu.sct.releng/pom.xml</relativePath>
+	</parent>
+	<artifactId>org.yakindu.sct.domain.generic.resource</artifactId>
+	<groupId>org.yakindu.sct.plugins</groupId>
+	<packaging>eclipse-plugin</packaging>
+</project>

+ 10 - 2
plugins/org.yakindu.sct.domain.generic/src/org/yakindu/sct/domain/generic/modules/ResourceModuleProvider.java

@@ -8,12 +8,15 @@
  * committers of YAKINDU - initial API and implementation
  *
 */
-package org.yakindu.sct.domain.generic.modules;
+package org.yakindu.sct.domain.generic.resource;
 
 import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.xtext.ui.shared.SharedStateModule;
 import org.yakindu.sct.domain.extension.IModuleProvider;
 import org.yakindu.sct.model.stext.STextRuntimeModule;
 import org.yakindu.sct.model.stext.resource.StextResource;
+import org.yakindu.sct.model.stext.ui.STextUiModule;
+import org.yakindu.sct.model.stext.ui.internal.STextActivator;
 
 import com.google.inject.Binder;
 import com.google.inject.Module;
@@ -28,12 +31,17 @@ public class ResourceModuleProvider implements IModuleProvider {
 
 	@Override
 	public Module getModule(String... options) {
-		return Modules.combine(getLanguageRuntimeModule(), new Module() {
+
+		Module module = Modules.override(getLanguageRuntimeModule())
+				.with(new STextUiModule(STextActivator.getInstance()));
+		module = Modules.override(module).with(new Module() {
 			@Override
 			public void configure(Binder binder) {
 				binder.bind(Resource.class).to(StextResource.class);
 			}
 		});
+
+		return Modules.override(module).with(new SharedStateModule());
 	}
 
 	protected Module getLanguageRuntimeModule() {

+ 1 - 2
plugins/org.yakindu.sct.domain.generic/META-INF/MANIFEST.MF

@@ -12,5 +12,4 @@ Require-Bundle: org.eclipse.core.runtime,
  org.yakindu.sct.model.stext
 Bundle-RequiredExecutionEnvironment: JavaSE-1.7
 Bundle-ActivationPolicy: lazy
-Export-Package: org.yakindu.sct.domain.generic,
- org.yakindu.sct.domain.generic.modules
+Export-Package: org.yakindu.sct.domain.generic

+ 0 - 8
plugins/org.yakindu.sct.domain.generic/plugin.xml

@@ -10,12 +10,4 @@
             name="Default">
       </Domain>
    </extension>
-<extension
-      point="org.yakindu.sct.domain.modules">
-   <Module
-         domainID="org.yakindu.domain.default"
-         feature="org.yakindu.sct.resource"
-         moduleProvider="org.yakindu.sct.domain.generic.modules.ResourceModuleProvider">
-   </Module>
-</extension>
 </plugin>

+ 1 - 1
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/ExpressionCode.xtend

@@ -138,7 +138,7 @@ class ExpressionCode {
 	def dispatch CharSequence code(LogicalNotExpression it) '''! «operand.code»'''
 
 	def dispatch CharSequence code(LogicalRelationExpression it) '''
-	«IF isSame(leftOperand.inferType(null), getType(GenericTypeSystem.STRING))»
+	«IF isSame(leftOperand.infer.type, getType(GenericTypeSystem.STRING))»
 		(strcmp(«leftOperand.code», «rightOperand.code») «operator.literal» 0)
 	«ELSE»«leftOperand.code» «operator.literal» «rightOperand.code»«ENDIF»'''
 

+ 1 - 1
plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/ExpressionCode.xtend

@@ -122,7 +122,7 @@ class ExpressionCode {
 	def dispatch CharSequence code(LogicalNotExpression it) '''! «operand.code»'''
 
 	def dispatch CharSequence code(LogicalRelationExpression it) '''
-	«IF isSame(leftOperand.inferType(null), getType(GenericTypeSystem.STRING))»
+	«IF isSame(leftOperand.infer.type, getType(GenericTypeSystem.STRING))»
 		(strcmp(«leftOperand.code», «rightOperand.code») «operator.literal» 0)
 	«ELSE»«leftOperand.code» «operator.literal» «rightOperand.code»«ENDIF»'''
 

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

@@ -138,7 +138,7 @@ class ExpressionCode {
 	}
 
 	def dispatch String code(LogicalRelationExpression expression) {
-		if (isSame(expression.leftOperand.inferType(null), getType(GenericTypeSystem.STRING))) {
+		if (isSame(expression.leftOperand.infer.type, getType(GenericTypeSystem.STRING))) {
 			expression.logicalString
 		} else
 			expression.leftOperand.code + expression.operator.code + expression.rightOperand.code;

+ 1 - 1
plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/ExpressionCode.xtend

@@ -175,7 +175,7 @@ class ExpressionCode {
 	}
 
 	def dispatch String code(LogicalRelationExpression expression) {
-		if (isSame(expression.leftOperand.inferType(null), getType(GenericTypeSystem.STRING))) {
+		if (isSame(expression.leftOperand.infer.type, getType(GenericTypeSystem.STRING))) {
 			expression.logicalString
 		} else
 			expression.leftOperand.code + expression.operator.code + expression.rightOperand.code;

+ 32 - 31
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/inferrer/STextTypeInferrer.java

@@ -20,7 +20,6 @@ import org.yakindu.base.expressions.expressions.Expression;
 import org.yakindu.base.expressions.expressions.FeatureCall;
 import org.yakindu.base.expressions.inferrer.ExpressionsTypeInferrer;
 import org.yakindu.base.types.Event;
-import org.yakindu.base.types.Type;
 import org.yakindu.sct.model.sgraph.Scope;
 import org.yakindu.sct.model.stext.stext.ActiveStateReferenceExpression;
 import org.yakindu.sct.model.stext.stext.EventRaisingExpression;
@@ -41,57 +40,59 @@ public class STextTypeInferrer extends ExpressionsTypeInferrer {
 	public static final String TIME_SPEC = "The evaluation result of a time expression must be of type integer.";
 	public static final String MISSING_VALUE = "Need to assign a value to an event of type %s.";
 
-	public Object infer(VariableDefinition e) {
-		Type type = inferTypeDispatch(e.getType());
-		assertNotType(type, VARIABLE_VOID_TYPE, getType(VOID));
+	public InferenceResult infer(VariableDefinition e) {
+		InferenceResult type = inferTypeDispatch(e.getTypeSpecifier());
+		assertNotType(type, VARIABLE_VOID_TYPE, getResultFor(VOID));
 		if (e.getInitialValue() == null)
-			return inferTypeDispatch(type);
-		Type type2 = inferTypeDispatch(e.getInitialValue());
+			return type;
+		InferenceResult type2 = inferTypeDispatch(e.getInitialValue());
 		assertAssignable(type, type2, String.format(VARIABLE_DEFINITION, type2, type));
-		return inferTypeDispatch(type);
+		return type;
 	}
 
-	public Object infer(Event e) {
+	
+	
+	public InferenceResult infer(Event e) {
 		// if an event is used within an expression, the type is boolean and the
 		// value indicates if the event is raised or not
-		return getType(BOOLEAN);
+		return getResultFor(BOOLEAN);
 	}
 
-	public Object infer(Guard e) {
-		Type type = inferTypeDispatch(e.getExpression());
-		assertIsSubType(type, getType(BOOLEAN), GUARD);
-		return inferTypeDispatch(type);
+	public InferenceResult infer(Guard e) {
+		InferenceResult type = inferTypeDispatch(e.getExpression());
+		assertIsSubType(type, getResultFor(BOOLEAN), GUARD);
+		return inferTypeDispatch(type.getType());
 	}
 
-	public Object infer(TimeEventSpec e) {
-		Type type = inferTypeDispatch(e.getValue());
-		assertIsSubType(type, getType(INTEGER), TIME_SPEC);
-		return inferTypeDispatch(type);
+	public InferenceResult infer(TimeEventSpec e) {
+		InferenceResult type = inferTypeDispatch(e.getValue());
+		assertIsSubType(type, getResultFor(INTEGER), TIME_SPEC);
+		return inferTypeDispatch(type.getType());
 	}
 
-	public Object infer(Scope scope) {
-		return getType(VOID);
+	public InferenceResult infer(Scope scope) {
+		return getResultFor(VOID);
 	}
 
-	public Object infer(EventValueReferenceExpression e) {
+	public InferenceResult infer(EventValueReferenceExpression e) {
 		Event definition = deresolve(e.getValue());
 		if (definition != null)
-			return inferTypeDispatch(definition.getType() != null ? definition.getType() : getType(VOID));
+			return definition.getTypeSpecifier() == null ? getResultFor(VOID) : inferTypeDispatch(definition.getTypeSpecifier());
 		return inferTypeDispatch(e.getValue());
 	}
 
-	public Object infer(EventRaisingExpression e) {
+	public InferenceResult infer(EventRaisingExpression e) {
 		Event event = deresolve(e.getEvent());
-		Type type1 = null;
+		InferenceResult eventType = null;
 		if(event != null)
-			type1 = event.getType();
-		type1 = type1 != null ? type1 : getType(VOID);
+			eventType = inferTypeDispatch(event.getType());
+		eventType = eventType != null ? eventType : getResultFor(VOID);
 		if (e.getValue() == null) {
-			assertSame(type1, getType(VOID), String.format(MISSING_VALUE, type1));
-			return getType(VOID);
+			assertSame(eventType, getResultFor(VOID), String.format(MISSING_VALUE, eventType));
+			return getResultFor(VOID);
 		}
-		Type type2 = inferTypeDispatch(e.getValue());
-		assertAssignable(type1, type2, String.format(EVENT_DEFINITION, type2, type1));
+		InferenceResult valueType = inferTypeDispatch(e.getValue());
+		assertAssignable(eventType, valueType, String.format(EVENT_DEFINITION, valueType, eventType));
 		return inferTypeDispatch(e.getValue());
 
 	}
@@ -114,8 +115,8 @@ public class STextTypeInferrer extends ExpressionsTypeInferrer {
 		return null;
 	}
 
-	public Object infer(ActiveStateReferenceExpression e) {
-		return getType(BOOLEAN);
+	public InferenceResult infer(ActiveStateReferenceExpression e) {
+		return getResultFor(BOOLEAN);
 	}
 
 }

+ 8 - 2
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/scoping/STextScopeProvider.java

@@ -34,6 +34,7 @@ import org.yakindu.base.types.ComplexType;
 import org.yakindu.base.types.EnumerationType;
 import org.yakindu.base.types.Type;
 import org.yakindu.base.types.inferrer.ITypeSystemInferrer;
+import org.yakindu.base.types.typesystem.ITypeSystem;
 import org.yakindu.sct.model.sgraph.SGraphPackage;
 import org.yakindu.sct.model.sgraph.Scope;
 import org.yakindu.sct.model.sgraph.Statechart;
@@ -58,6 +59,8 @@ public class STextScopeProvider extends AbstractDeclarativeScopeProvider {
 
 	@Inject
 	private ITypeSystemInferrer typeInferrer;
+	@Inject 
+	private ITypeSystem typeSystem;
 	
 	private static class ErrorHandlerDelegate<T> implements ErrorHandler<T> {
 
@@ -130,13 +133,16 @@ public class STextScopeProvider extends AbstractDeclarativeScopeProvider {
 		}
 
 		IScope scope = IScope.NULLSCOPE;
+		Type ownerType = typeInferrer.infer(owner).getType();
 
 		if (element instanceof Scope) {
 			scope = Scopes.scopeFor(((Scope) element).getDeclarations());
 			return new FilteringScope(scope, predicate);
+		}else{
+			scope = Scopes.scopeFor(typeSystem.getPropertyExtensions(ownerType));
+			scope = Scopes.scopeFor(typeSystem.getOperationExtensions(ownerType),scope);
 		}
-
-		Type ownerType = typeInferrer.inferType(owner, null);
+		
 		if (ownerType instanceof ComplexType) {
 			return addScopeForComplexType((ComplexType) ownerType, scope, predicate);
 		}

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

@@ -132,17 +132,17 @@ public class STextJavaValidator extends AbstractSTextJavaValidator implements ST
 	public void checkExpression(VariableDefinition expression) {
 		if (expression.getType() == null || expression.getType().eIsProxy())
 			return;
-		typeInferrer.inferType(expression, this);
+		typeInferrer.infer(expression, this);
 	}
 
 	@Check
 	public void checkExpression(TimeEventSpec expression) {
-		typeInferrer.inferType(expression, this);
+		typeInferrer.infer(expression, this);
 	}
 
 	@Check
 	public void checkExpression(Guard expression) {
-		typeInferrer.inferType(expression, this);
+		typeInferrer.infer(expression, this);
 	}
 	
 	@Check

+ 1 - 1
plugins/org.yakindu.sct.simulation.core.sexec/src/org/yakindu/sct/simulation/core/sexec/container/DefaultExecutionContextInitializer.xtend

@@ -113,7 +113,7 @@ class DefaultExecutionContextInitializer implements IExecutionContextInitializer
 	def dispatch ExecutionSlot create new ExecutionVariableImpl() transform(VariableDefinition variable) {
 		it.name = variable.fullyQualifiedName.lastSegment
 		it.fqName = variable.fullyQualifiedName.toString
-		it.type = variable.inferType(null)
+		it.type = variable.infer.type
 		it.value = it.type?.defaultValue
 		it.writable = !variable.const
 	}

+ 1 - 0
releng/org.yakindu.sct.releng/pom.xml

@@ -394,6 +394,7 @@
 		<module>../../plugins/org.yakindu.sct.domain.generic.editor</module>
 		<module>../../plugins/org.yakindu.sct.domain.generic.generator</module>
 		<module>../../plugins/org.yakindu.sct.domain.generic.simulation</module>
+		<module>../../plugins/org.yakindu.sct.domain.generic.resource</module>
 		<module>../../plugins/org.yakindu.sct.doc.user</module>
 		<module>../../plugins/org.yakindu.sct.generator.core</module>
 		<module>../../plugins/org.yakindu.sct.generator.builder</module>

+ 2 - 1
test-plugins/org.yakindu.sct.generator.c.test/META-INF/MANIFEST.MF

@@ -18,6 +18,7 @@ Require-Bundle: org.junit,
  org.yakindu.sct.generator.genmodel.ui,
  org.yakindu.sct.model.resource,
  org.yakindu.sct.generator.builder,
- org.eclipse.xtext.ui.shared
+ org.eclipse.xtext.ui.shared,
+ org.yakindu.sct.domain.generic.resource
 Export-Package: org.yakindu.sct.generator.c.gtest,
  org.yakindu.sct.generator.c.test

+ 2 - 1
test-plugins/org.yakindu.sct.generator.cpp.test/META-INF/MANIFEST.MF

@@ -9,4 +9,5 @@ Require-Bundle: org.yakindu.sct.test.models,
  org.yakindu.sct.generator.c.test,
  org.junit,
  org.yakindu.sct.generator.cpp,
- org.yakindu.sct.model.resource
+ org.yakindu.sct.model.resource,
+ org.yakindu.sct.domain.generic.resource

+ 2 - 1
test-plugins/org.yakindu.sct.generator.java.test/META-INF/MANIFEST.MF

@@ -14,6 +14,7 @@ Require-Bundle: org.yakindu.sct.test.models,
  org.eclipse.ui,
  org.eclipse.core.resources,
  org.eclipse.xtext.ui.shared,
- org.yakindu.sct.generator.builder
+ org.yakindu.sct.generator.builder,
+ org.yakindu.sct.domain.generic.resource
 Bundle-RequiredExecutionEnvironment: JavaSE-1.7
 Bundle-Vendor: statecharts.org

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

@@ -10,7 +10,8 @@ Require-Bundle: org.yakindu.sct.model.sgraph,
  org.eclipse.core.runtime,
  org.yakindu.sct.model.stext,
  org.eclipse.xtext.junit4,
- org.yakindu.sct.test.models
+ org.yakindu.sct.test.models,
+ org.yakindu.sct.domain.generic.resource
 Bundle-ActivationPolicy: lazy
 Bundle-RequiredExecutionEnvironment: JavaSE-1.7
 Bundle-Vendor: statecharts.org

+ 3 - 4
test-plugins/org.yakindu.sct.model.sgraph.test/src/org/yakindu/sct/model/sgraph/test/SGraphTestModule.java

@@ -16,6 +16,7 @@ import org.eclipse.xtext.Constants;
 import com.google.inject.Binder;
 import com.google.inject.Module;
 import com.google.inject.name.Names;
+
 /**
  * 
  * @author andreas muelder - Initial contribution and API
@@ -24,11 +25,9 @@ import com.google.inject.name.Names;
 public class SGraphTestModule implements Module {
 
 	public void configure(Binder binder) {
-		binder.bind(String.class)
-				.annotatedWith(Names.named(Constants.LANGUAGE_NAME))
+		binder.bind(String.class).annotatedWith(Names.named(Constants.LANGUAGE_NAME))
 				.toInstance("org.yakindu.sct.model.sgraph");
-		binder.bind(EValidator.Registry.class).toInstance(
-				EValidator.Registry.INSTANCE);
+		binder.bind(EValidator.Registry.class).toInstance(EValidator.Registry.INSTANCE);
 	}
 
 }

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

@@ -7,5 +7,6 @@ Fragment-Host: org.yakindu.sct.model.resource
 Bundle-RequiredExecutionEnvironment: JavaSE-1.7
 Require-Bundle: org.junit,
  org.yakindu.sct.test.models,
- org.yakindu.sct.model.stext.ui
+ org.yakindu.sct.model.stext.ui,
+ org.yakindu.sct.domain.generic.resource
 Bundle-Vendor: statecharts.org

+ 15 - 4
test-plugins/org.yakindu.sct.model.stext.test/src/org/yakindu/sct/model/stext/test/util/AbstractTypeInferrerTest.java

@@ -12,6 +12,7 @@ import org.junit.rules.ExpectedException;
 import org.yakindu.base.expressions.expressions.Expression;
 import org.yakindu.base.types.Type;
 import org.yakindu.base.types.inferrer.ITypeSystemInferrer;
+import org.yakindu.base.types.inferrer.ITypeSystemInferrer.InferenceResult;
 import org.yakindu.base.types.typesystem.ITypeSystem;
 import org.yakindu.base.types.validation.IValidationIssueAcceptor.ListBasedValidationIssueAcceptor;
 import org.yakindu.base.types.validation.IValidationIssueAcceptor.ValidationIssue;
@@ -46,20 +47,30 @@ public abstract class AbstractTypeInferrerTest extends AbstractSTextTest {
 		return inferType(expression, parserRule, super.internalScope() + "\n" + super.interfaceScope());
 	}
 
+	protected InferenceResult inferTypeResultForExpression(String expression, String scopes) {
+		return inferTypeResult(expression, Expression.class.getSimpleName(), scopes);
+	}
+	
+	@Deprecated
 	protected Type inferTypeForExpression(String expression, String scopes) {
 		return inferType(expression, Expression.class.getSimpleName(), scopes);
 	}
 
+	@Deprecated
 	protected Type inferType(String expression, String parserRule, String scopes) {
+		return inferTypeResult(expression, parserRule, scopes).getType();
+	}
+	
+	protected InferenceResult inferTypeResult(String expression, String parserRule, String scopes) {
 		EObject parseResult = super.parseExpression(expression, parserRule, scopes);
 		assertNotNull(parseResult);
 		acceptor = new ListBasedValidationIssueAcceptor();
 		if (parseResult instanceof Expression) {
-			return typeInferrer.inferType((Expression) parseResult, acceptor);
+			return typeInferrer.infer((Expression) parseResult, acceptor);
 		} else if (parseResult instanceof EventDefinition) {
-			return typeInferrer.inferType((EventDefinition) parseResult, acceptor);
+			return typeInferrer.infer((EventDefinition) parseResult, acceptor);
 		} else if (parseResult instanceof VariableDefinition) {
-			return typeInferrer.inferType((VariableDefinition) parseResult, acceptor);
+			return typeInferrer.infer((VariableDefinition) parseResult, acceptor);
 		} else {
 			throw new IllegalArgumentException("Unsupported parse result.");
 		}
@@ -131,7 +142,7 @@ public abstract class AbstractTypeInferrerTest extends AbstractSTextTest {
 	protected ListBasedValidationIssueAcceptor validate(String expression, String scope) {
 		EObject exp = parseExpression(expression, Expression.class.getSimpleName(), scope);
 		ListBasedValidationIssueAcceptor diagnostics = new ListBasedValidationIssueAcceptor();
-		typeInferrer.inferType(exp, diagnostics);
+		typeInferrer.infer(exp, diagnostics);
 		return diagnostics;
 	}
 }

+ 2 - 1
test-plugins/org.yakindu.sct.refactoring.tests/META-INF/MANIFEST.MF

@@ -9,7 +9,8 @@ Require-Bundle: org.eclipse.core.runtime,
  org.junit,
  org.eclipse.xtext.junit4,
  org.yakindu.sct.model.sexec,
- org.yakindu.sct.test.models
+ org.yakindu.sct.test.models,
+ org.yakindu.sct.domain.generic.resource
 Bundle-RequiredExecutionEnvironment: JavaSE-1.7
 Bundle-ActivationPolicy: lazy