Search in sources :

Example 16 with Type

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

the class StextTestFactory method _createRealType.

public static Type _createRealType(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)

Example 17 with Type

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

the class StextTestFactory method _createIntegerType.

public static Type _createIntegerType(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)

Example 18 with Type

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

the class AbstractTypeSystem method isSuperType.

/**
 * @returns <code>true</code> if superType is a direct or indirect super type of
 *          subType.
 */
@Override
public boolean isSuperType(Type subtype, Type supertype) {
    Set<Type> typehierachy = new LinkedHashSet<Type>();
    typehierachy.add(subtype);
    collectSupertypes(subtype, typehierachy);
    for (Type eObject : typehierachy) {
        if (isSame(eObject, supertype))
            return true;
    }
    return false;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) PrimitiveType(org.yakindu.base.types.PrimitiveType) Type(org.yakindu.base.types.Type)

Example 19 with Type

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

the class AbstractTypeSystem method getDirectSuperTypes.

/**
 * Returns the list of direct super types for given type. Also reflects
 * primitive type's base types, type parameter bounds and complex type's super
 * types.
 */
protected List<Type> getDirectSuperTypes(Type type) {
    List<Type> superTypes = new ArrayList<Type>();
    for (Entry<Type, Type> entry : extendsRegistry.entries()) {
        if (isSame(type, entry.getKey())) {
            superTypes.add(entry.getValue());
        }
    }
    superTypes.addAll(type.getSuperTypes());
    if (type instanceof TypeParameter) {
        TypeParameter typeParameter = (TypeParameter) type;
        Type bound = typeParameter.getBound();
        if (bound != null) {
            superTypes.add(bound);
        }
    }
    return superTypes;
}
Also used : PrimitiveType(org.yakindu.base.types.PrimitiveType) Type(org.yakindu.base.types.Type) TypeParameter(org.yakindu.base.types.TypeParameter) ArrayList(java.util.ArrayList)

Example 20 with Type

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

the class AbstractTypeSystem method getCommonTypeWithConversion.

@Override
public Type getCommonTypeWithConversion(Type type1, Type type2) {
    Type result = getCommonType(type1, type2);
    if (result != null)
        return result;
    Type conversionType1 = getConversionType(type1);
    if (conversionType1 != null) {
        result = getCommonTypeInternal(conversionType1, type2);
        if (result != null)
            return result;
    }
    Type conversionType2 = getConversionType(type2);
    if (conversionType2 != null)
        return getCommonTypeInternal(type1, conversionType2);
    return null;
}
Also used : PrimitiveType(org.yakindu.base.types.PrimitiveType) 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