use of org.yakindu.base.types.TypeParameter 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);
}
}
}
}
use of org.yakindu.base.types.TypeParameter in project statecharts by Yakindu.
the class ExpressionsJavaValidator method checkDuplicateTypeParameter.
@Check
public void checkDuplicateTypeParameter(GenericElement type) {
Set<String> names = Sets.newHashSet();
EList<TypeParameter> typeParameter = type.getTypeParameters();
for (TypeParameter param : typeParameter) {
String name = param.getName();
if (names.contains(name)) {
error(String.format(ERROR_DUPLICATE_TYPE_PARAMETER_MSG, name), type, TypesPackage.Literals.GENERIC_ELEMENT__TYPE_PARAMETERS, ERROR_DUPLICATE_TYPE_PARAMETER_CODE);
}
names.add(name);
}
}
Aggregations