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;
}
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;
}
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);
}
}
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);
}
}
}
}
Aggregations