Search in sources :

Example 1 with ArrayTypeVariable2

use of org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ArrayTypeVariable2 in project che by eclipse.

the class InferTypeArgumentsTCModel method makeArrayTypeVariable.

private ArrayTypeVariable2 makeArrayTypeVariable(ArrayType type) {
    ArrayTypeVariable2 cv = new ArrayTypeVariable2(type);
    ArrayTypeVariable2 storedCv = (ArrayTypeVariable2) storedCv(cv);
    if (cv == storedCv) {
        fCuScopedConstraintVariables.add(storedCv);
        makeArrayElementVariable(storedCv);
        if (fStoreToString)
            //$NON-NLS-1$ //$NON-NLS-2$
            storedCv.setData(ConstraintVariable2.TO_STRING, "ArrayType(" + type.getPrettySignature() + ")");
    }
    return storedCv;
}
Also used : ArrayTypeVariable2(org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ArrayTypeVariable2)

Example 2 with ArrayTypeVariable2

use of org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ArrayTypeVariable2 in project che by eclipse.

the class InferTypeArgumentsConstraintsSolver method findCastsToRemove.

private void findCastsToRemove(CastVariable2[] castVariables) {
    for (int i = 0; i < castVariables.length; i++) {
        CastVariable2 castCv = castVariables[i];
        ConstraintVariable2 expressionVariable = castCv.getExpressionVariable();
        TType chosenType = InferTypeArgumentsConstraintsSolver.getChosenType(expressionVariable);
        TType castType = castCv.getType();
        TType expressionType = expressionVariable.getType();
        if (chosenType != null && TTypes.canAssignTo(chosenType, castType)) {
            if (chosenType.equals(expressionType))
                // The type has not changed. Don't remove the cast, since it could be
                continue;
            // there to get access to default-visible members or to
            // unify types of conditional expressions.
            fUpdate.addCastToRemove(castCv);
        } else if (expressionVariable instanceof ArrayTypeVariable2 && castType.isArrayType()) {
            // bug 97258
            ArrayElementVariable2 arrayElementCv = fTCModel.getArrayElementVariable(expressionVariable);
            if (arrayElementCv == null)
                continue;
            TType chosenArrayElementType = InferTypeArgumentsConstraintsSolver.getChosenType(arrayElementCv);
            if (chosenArrayElementType != null && TTypes.canAssignTo(chosenArrayElementType, ((ArrayType) castType).getComponentType())) {
                if (expressionType instanceof ArrayType && chosenArrayElementType.equals(((ArrayType) expressionType).getComponentType()))
                    // The type has not changed. Don't remove the cast, since it could be
                    continue;
                // there to unify types of conditional expressions.
                fUpdate.addCastToRemove(castCv);
            }
        }
    }
}
Also used : ArrayType(org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.ArrayType) CastVariable2(org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.CastVariable2) ArrayTypeVariable2(org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ArrayTypeVariable2) TType(org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.TType) ConstraintVariable2(org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ConstraintVariable2) ArrayElementVariable2(org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ArrayElementVariable2)

Aggregations

ArrayTypeVariable2 (org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ArrayTypeVariable2)2 ArrayType (org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.ArrayType)1 TType (org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.TType)1 ArrayElementVariable2 (org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ArrayElementVariable2)1 CastVariable2 (org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.CastVariable2)1 ConstraintVariable2 (org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ConstraintVariable2)1