use of org.yakindu.base.types.GenericElement in project statecharts by Yakindu.
the class ExpressionsTypeInferrer method doInfer.
public InferenceResult doInfer(TypeSpecifier specifier) {
if (specifier.getType() instanceof GenericElement && ((GenericElement) specifier.getType()).getTypeParameters().size() > 0) {
List<InferenceResult> bindings = new ArrayList<>();
EList<TypeSpecifier> arguments = specifier.getTypeArguments();
for (TypeSpecifier typeSpecifier : arguments) {
InferenceResult binding = inferTypeDispatch(typeSpecifier);
if (binding != null) {
bindings.add(binding);
}
}
Type type = inferTypeDispatch(specifier.getType()).getType();
return InferenceResult.from(type, bindings);
}
return inferTypeDispatch(specifier.getType());
}
use of org.yakindu.base.types.GenericElement in project statecharts by Yakindu.
the class ExpressionsJavaValidator method checkIsRaw.
@Check
public void checkIsRaw(TypeSpecifier typedElement) {
Type type = typedElement.getType();
if (!(type instanceof GenericElement))
return;
EList<TypeParameter> typeParameter = ((GenericElement) type).getTypeParameters();
if (typedElement.getTypeArguments().size() == 0 && typeParameter.size() > 0) {
String s1 = typedElement.getType().getName();
String s2 = s1 + printer.concatTypeParameter(typeParameter);
warning(String.format(WARNING_IS_RAW_MSG, s1, s2), typedElement, TypesPackage.Literals.TYPE_SPECIFIER__TYPE, WARNING_IS_RAW_CODE);
}
}
use of org.yakindu.base.types.GenericElement in project statecharts by Yakindu.
the class ExpressionsJavaValidator method checkNofArguments.
@Check
public void checkNofArguments(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()) && typeParameter.size() > 0) {
String s1 = type.getName() + printer.concatTypeParameter(typeParameter);
String s2 = printer.concatTypeArguments(typedElement.getTypeArguments());
error(String.format(ERROR_ARGUMENTED_SPECIFIER_INCORRECT_ARGUMENT_NR_MSG, s1, s2), typedElement, TypesPackage.Literals.TYPE_SPECIFIER__TYPE, ERROR_ARGUMENTED_SPECIFIER_INCORRECT_ARGUMENT_NR_CODE);
}
}
use of org.yakindu.base.types.GenericElement 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