Search in sources :

Example 21 with Type

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

the class AbstractTypeSystem method getPropertyExtensions.

@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;
}
Also used : PrimitiveType(org.yakindu.base.types.PrimitiveType) Type(org.yakindu.base.types.Type) ArrayList(java.util.ArrayList) Property(org.yakindu.base.types.Property)

Example 22 with Type

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

the class AbstractTypeSystem method getCommonTypeInternal.

protected Type getCommonTypeInternal(Type type1, Type type2) {
    if (isSame(type1, type2))
        return type1;
    if (isSuperType(type1, type2)) {
        return type2;
    }
    if (isSuperType(type2, type1))
        return type1;
    Set<Type> typehierachy1 = new LinkedHashSet<Type>();
    collectSupertypes(type1, typehierachy1);
    Set<Type> typehierachy2 = new LinkedHashSet<Type>();
    collectSupertypes(type2, typehierachy2);
    for (Type type : typehierachy1) {
        if (typehierachy2.contains(type)) {
            return type;
        }
    }
    for (Type type : typehierachy2) {
        if (typehierachy1.contains(type)) {
            return type;
        }
    }
    return null;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) PrimitiveType(org.yakindu.base.types.PrimitiveType) Type(org.yakindu.base.types.Type)

Example 23 with Type

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

the class AbstractTypeSystem method removeType.

protected void removeType(String name) {
    Type type = typeRegistry.get(name);
    if (type != null) {
        extendsRegistry.removeAll(type);
        resource.getContents().remove(type);
        typeRegistry.remove(name);
    }
}
Also used : PrimitiveType(org.yakindu.base.types.PrimitiveType) Type(org.yakindu.base.types.Type)

Example 24 with Type

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

the class ExpressionsJavaValidator method checkTypeParameterBounds.

@Check
public void checkTypeParameterBounds(TypeSpecifier typedElement) {
    if (!(typedElement.getType() instanceof GenericElement)) {
        return;
    }
    GenericElement type = (GenericElement) typedElement.getType();
    EList<TypeParameter> typeParameter = type.getTypeParameters();
    if (typedElement.getTypeArguments().size() == 0 || (typedElement.getTypeArguments().size() != typeParameter.size()))
        return;
    for (int i = 0; i < typeParameter.size(); i++) {
        TypeParameter parameter = typeParameter.get(i);
        if (parameter.getBound() != null) {
            Type argument = typedElement.getTypeArguments().get(i).getType();
            if (!typeSystem.isSuperType(argument, parameter.getBound())) {
                error(String.format(ERROR_BOUND_MISSMATCH_MSG, argument.getName(), (parameter.getBound()).getName(), type.getName()), typedElement, TypesPackage.Literals.TYPE_SPECIFIER__TYPE_ARGUMENTS, i, ERROR_BOUND_MISSMATCH_CODE);
            }
        }
    }
}
Also used : TypeParameter(org.yakindu.base.types.TypeParameter) ComplexType(org.yakindu.base.types.ComplexType) CheckType(org.eclipse.xtext.validation.CheckType) Type(org.yakindu.base.types.Type) GenericElement(org.yakindu.base.types.GenericElement) Check(org.eclipse.xtext.validation.Check)

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