Search in sources :

Example 6 with Type

use of org.yakindu.base.types.Type in project statecharts by Yakindu.

the class AbstractTypeSystemTest method testMultipleInheritance.

@Test
public void testMultipleInheritance() {
    // SubType extends SuperType
    Type int16 = createPrimitive("int16");
    declareType(int16, "int16");
    Type uint16 = createPrimitive("uint16");
    declareType(uint16, "uint16");
    Type int8 = createPrimitive("int8");
    declareType(int8, "int8");
    Type uint8 = createPrimitive("uint8");
    declareType(uint8, "uint8");
    declareSuperType(int8, int16);
    declareSuperType(uint8, int16);
    assertTrue(isSame(getType("int16"), getCommonType(int8, uint8)));
}
Also used : ComplexType(org.yakindu.base.types.ComplexType) PrimitiveType(org.yakindu.base.types.PrimitiveType) Type(org.yakindu.base.types.Type) Test(org.junit.Test)

Example 7 with Type

use of org.yakindu.base.types.Type in project statecharts by Yakindu.

the class STextScopeProvider method scope_FeatureCall_feature.

public IScope scope_FeatureCall_feature(final FeatureCall context, EReference reference) {
    Predicate<IEObjectDescription> predicate = calculateFilterPredicate(context, reference);
    Expression owner = context.getOwner();
    EObject element = null;
    if (owner instanceof ElementReferenceExpression) {
        element = ((ElementReferenceExpression) owner).getReference();
    } else if (owner instanceof FeatureCall) {
        element = ((FeatureCall) owner).getFeature();
    } else {
        return getDelegate().getScope(context, reference);
    }
    IScope scope = IScope.NULLSCOPE;
    InferenceResult result = typeInferrer.infer(owner);
    Type ownerType = result != null ? result.getType() : null;
    if (element instanceof Scope) {
        scope = Scopes.scopeFor(((Scope) element).getDeclarations());
        return new FilteringScope(scope, predicate);
    } else if (ownerType != null) {
        scope = Scopes.scopeFor(typeSystem.getPropertyExtensions(ownerType));
        scope = Scopes.scopeFor(typeSystem.getOperationExtensions(ownerType), scope);
    }
    if (ownerType instanceof ComplexType) {
        return addScopeForComplexType((ComplexType) ownerType, scope, predicate);
    }
    if (ownerType instanceof EnumerationType) {
        return addScopeForEnumType((EnumerationType) ownerType, scope, predicate);
    }
    return scope;
}
Also used : InferenceResult(org.yakindu.base.types.inferrer.ITypeSystemInferrer.InferenceResult) EnumerationType(org.yakindu.base.types.EnumerationType) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription) ComplexType(org.yakindu.base.types.ComplexType) EnumerationType(org.yakindu.base.types.EnumerationType) Type(org.yakindu.base.types.Type) FilteringScope(org.eclipse.xtext.scoping.impl.FilteringScope) InterfaceScope(org.yakindu.sct.model.stext.stext.InterfaceScope) Scope(org.yakindu.sct.model.sgraph.Scope) IScope(org.eclipse.xtext.scoping.IScope) SimpleScope(org.eclipse.xtext.scoping.impl.SimpleScope) InternalScope(org.yakindu.sct.model.stext.stext.InternalScope) ImportScope(org.eclipse.xtext.scoping.impl.ImportScope) Expression(org.yakindu.base.expressions.expressions.Expression) ElementReferenceExpression(org.yakindu.base.expressions.expressions.ElementReferenceExpression) EObject(org.eclipse.emf.ecore.EObject) IScope(org.eclipse.xtext.scoping.IScope) ElementReferenceExpression(org.yakindu.base.expressions.expressions.ElementReferenceExpression) FeatureCall(org.yakindu.base.expressions.expressions.FeatureCall) ComplexType(org.yakindu.base.types.ComplexType) FilteringScope(org.eclipse.xtext.scoping.impl.FilteringScope)

Example 8 with Type

use of org.yakindu.base.types.Type in project statecharts by Yakindu.

the class ExecutionContextImpl method setType.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void setType(Type newType) {
    Type oldType = type;
    type = newType;
    if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, SRuntimePackage.EXECUTION_CONTEXT__TYPE, oldType, type));
}
Also used : Type(org.yakindu.base.types.Type) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 9 with Type

use of org.yakindu.base.types.Type in project statecharts by Yakindu.

the class ExecutionSlotImpl method setType.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void setType(Type newType) {
    Type oldType = type;
    type = newType;
    if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, SRuntimePackage.EXECUTION_SLOT__TYPE, oldType, type));
}
Also used : Type(org.yakindu.base.types.Type) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 10 with Type

use of org.yakindu.base.types.Type in project statecharts by Yakindu.

the class StextTestFactory method _createBooleanType.

public static Type _createBooleanType(String name) {
    Type t = TypesFactory.eINSTANCE.createPrimitiveType();
    t.setName(name);
    return t;
}
Also used : TimeEventType(org.yakindu.sct.model.stext.stext.TimeEventType) Type(org.yakindu.base.types.Type)

Aggregations

Type (org.yakindu.base.types.Type)24 PrimitiveType (org.yakindu.base.types.PrimitiveType)8 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)5 TimeEventType (org.yakindu.sct.model.stext.stext.TimeEventType)5 ArrayList (java.util.ArrayList)4 ComplexType (org.yakindu.base.types.ComplexType)4 GenericElement (org.yakindu.base.types.GenericElement)3 TypeParameter (org.yakindu.base.types.TypeParameter)3 LinkedHashSet (java.util.LinkedHashSet)2 IEObjectDescription (org.eclipse.xtext.resource.IEObjectDescription)2 Check (org.eclipse.xtext.validation.Check)2 CheckType (org.eclipse.xtext.validation.CheckType)2 Expression (org.yakindu.base.expressions.expressions.Expression)2 EnumerationType (org.yakindu.base.types.EnumerationType)2 Operation (org.yakindu.base.types.Operation)2 Inject (com.google.inject.Inject)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 List (java.util.List)1 Optional (java.util.Optional)1