Search in sources :

Example 1 with ParameterizedType

use of org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.ParameterizedType in project che by eclipse.

the class InferTypeArgumentsTCModel method makeFixedElementVariables.

public void makeFixedElementVariables(ConstraintVariable2 expressionCv, TType type) {
    if (isAGenericType(type)) {
        GenericType genericType = (GenericType) type.getTypeDeclaration();
        TType[] typeParameters = genericType.getTypeParameters();
        TType[] typeArguments = null;
        if (type.isParameterizedType())
            typeArguments = ((ParameterizedType) type).getTypeArguments();
        for (int i = 0; i < typeParameters.length; i++) {
            TypeVariable typeVariable = (TypeVariable) typeParameters[i];
            CollectionElementVariable2 elementCv = makeElementVariable(expressionCv, typeVariable, i);
            TType referenceTypeArgument;
            if (typeArguments == null) {
                // do not consider
                continue;
            } else {
                referenceTypeArgument = typeArguments[i];
            }
            createEqualsConstraint(elementCv, makeImmutableTypeVariable(referenceTypeArgument));
        //				if (typeVariable.getBounds().length != 0) {
        //					//TODO: create subtype constraints for bounds
        //				}
        }
    }
    makeFixedElementVariablesFromSupertypes(expressionCv, type.getTypeDeclaration());
}
Also used : ParameterizedType(org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.ParameterizedType) GenericType(org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.GenericType) CollectionElementVariable2(org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.CollectionElementVariable2) TypeVariable(org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.TypeVariable) TType(org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.TType)

Example 2 with ParameterizedType

use of org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.ParameterizedType in project che by eclipse.

the class InferTypeArgumentsTCModel method makeFixedSupertypeElementVariables.

private void makeFixedSupertypeElementVariables(ConstraintVariable2 expressionCv, TType supertype) {
    if (supertype.isParameterizedType() || supertype.isRawType()) {
        TType[] typeArguments = null;
        if (supertype.isParameterizedType())
            typeArguments = ((ParameterizedType) supertype).getTypeArguments();
        TypeVariable[] typeParameters = ((GenericType) supertype.getTypeDeclaration()).getTypeParameters();
        for (int i = 0; i < typeParameters.length; i++) {
            TypeVariable typeParameter = typeParameters[i];
            TType referenceTypeArgument;
            if (typeArguments == null) {
                // do not consider
                continue;
            } else {
                referenceTypeArgument = typeArguments[i];
            }
            if (referenceTypeArgument.isTypeVariable()) {
                CollectionElementVariable2 referenceTypeArgumentCv = getElementVariable(expressionCv, (TypeVariable) referenceTypeArgument);
                setElementVariable(expressionCv, referenceTypeArgumentCv, typeParameter);
            } else {
                CollectionElementVariable2 elementCv = makeElementVariable(expressionCv, typeParameter, CollectionElementVariable2.NOT_DECLARED_TYPE_VARIABLE_INDEX);
                createEqualsConstraint(elementCv, makeImmutableTypeVariable(referenceTypeArgument));
            }
        }
    }
    makeFixedElementVariablesFromSupertypes(expressionCv, supertype);
}
Also used : ParameterizedType(org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.ParameterizedType) GenericType(org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.GenericType) CollectionElementVariable2(org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.CollectionElementVariable2) TypeVariable(org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.TypeVariable) TType(org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.TType)

Aggregations

GenericType (org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.GenericType)2 ParameterizedType (org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.ParameterizedType)2 TType (org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.TType)2 TypeVariable (org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.TypeVariable)2 CollectionElementVariable2 (org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.CollectionElementVariable2)2