Search in sources :

Example 6 with ArrayType

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

the class SubTypesSet method enumerate.

/* (non-Javadoc)
	 * @see org.eclipse.jdt.internal.corext.refactoring.typeconstraints.typesets.TypeSet#enumerate()
	 */
@Override
public EnumeratedTypeSet enumerate() {
    if (fEnumCache == null) {
        fEnumCache = new EnumeratedTypeSet(getTypeSetEnvironment());
        for (Iterator<TType> iter = fUpperBounds.iterator(); iter.hasNext(); ) {
            TType ub = iter.next();
            if (ub instanceof ArrayType) {
                ArrayType at = (ArrayType) ub;
                int numDims = at.getDimensions();
                for (Iterator<TType> elemSubIter = TTypes.getAllSubTypesIterator(at.getElementType()); elemSubIter.hasNext(); ) fEnumCache.add(TTypes.createArrayType(elemSubIter.next(), numDims));
            } else {
                for (Iterator<TType> iterator = TTypes.getAllSubTypesIterator(ub); iterator.hasNext(); ) {
                    fEnumCache.fMembers.add(iterator.next());
                }
            }
            fEnumCache.add(ub);
        }
    //			fEnumCache.initComplete();
    }
    return fEnumCache;
}
Also used : ArrayType(org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.ArrayType) TType(org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.TType)

Example 7 with ArrayType

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

the class SuperTypesSet method enumerate.

/* (non-Javadoc)
	 * @see org.eclipse.jdt.internal.corext.refactoring.typeconstraints.typesets.TypeSet#enumerate()
	 */
@Override
public EnumeratedTypeSet enumerate() {
    if (fEnumCache == null) {
        fEnumCache = new EnumeratedTypeSet(getTypeSetEnvironment());
        boolean anyLBIsIntfOrArray = false;
        for (Iterator<TType> iter = fLowerBounds.iterator(); iter.hasNext(); ) {
            TType lb = iter.next();
            if (lb instanceof ArrayType) {
                ArrayType at = (ArrayType) lb;
                int numDims = at.getDimensions();
                for (Iterator<TType> elemSuperIter = TTypes.getAllSuperTypesIterator(at.getElementType()); elemSuperIter.hasNext(); ) fEnumCache.add(TTypes.createArrayType(elemSuperIter.next(), numDims));
                anyLBIsIntfOrArray = true;
            } else {
                for (Iterator<TType> iterator = TTypes.getAllSuperTypesIterator(lb); iterator.hasNext(); ) fEnumCache.fMembers.add(iterator.next());
            }
            fEnumCache.add(lb);
        }
        if (anyLBIsIntfOrArray)
            fEnumCache.add(getJavaLangObject());
    //fEnumCache.initComplete();
    }
    return fEnumCache;
}
Also used : ArrayType(org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.ArrayType) TType(org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.TType)

Example 8 with ArrayType

use of org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.ArrayType 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

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