Search in sources :

Example 1 with ArrayType

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

the class ArraySuperTypeSet method contains.

/* (non-Javadoc)
	 * @see org.eclipse.jdt.internal.corext.refactoring.typeconstraints.typesets.ArrayTypeSet#contains(TType)
	 */
@Override
public boolean contains(TType t) {
    if (t.equals(getJavaLangObject()))
        return true;
    if (!(t instanceof ArrayType))
        return false;
    ArrayType at = (ArrayType) t;
    TType atElemType = at.getComponentType();
    if (// try to avoid enumeration
    fElemTypeSet.contains(atElemType))
        return true;
    for (Iterator<TType> iter = fElemTypeSet.iterator(); iter.hasNext(); ) {
        TType elemType = iter.next();
        if (TTypes.canAssignTo(elemType, atElemType))
            return true;
    }
    return false;
}
Also used : ArrayType(org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.ArrayType) TType(org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.TType)

Example 2 with ArrayType

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

the class EnumeratedTypeSet method lowerBound.

/* (non-Javadoc)
	 * @see org.eclipse.jdt.internal.corext.refactoring.typeconstraints.typesets.TypeSet#lowerBound()
	 */
@Override
public TypeSet lowerBound() {
    if (fMembers.size() == 1)
        return new SingletonTypeSet(fMembers.iterator().next(), getTypeSetEnvironment());
    EnumeratedTypeSet result = new EnumeratedTypeSet(getTypeSetEnvironment());
    // Add to result each element of fMembers that has no proper subtype in fMembers
    result.fMembers.addAll(fMembers);
    for (Iterator<TType> iter = fMembers.iterator(); iter.hasNext(); ) {
        TType t = iter.next();
        // of only java.lang.Object, but that case is handled above.
        if (t.equals(getJavaLangObject())) {
            result.fMembers.remove(t);
            continue;
        }
        if (t instanceof ArrayType) {
            ArrayType at = (ArrayType) t;
            int numDims = at.getDimensions();
            for (Iterator<TType> superIter = TTypes.getAllSuperTypesIterator(at.getElementType()); superIter.hasNext(); ) {
                result.fMembers.remove(TTypes.createArrayType(superIter.next(), numDims));
            }
        } else {
            for (Iterator<TType> iterator = TTypes.getAllSuperTypesIterator(t); iterator.hasNext(); ) {
                result.fMembers.remove(iterator.next());
            }
        }
    }
    if (result.size() > 0)
        return result;
    else
        return getTypeSetEnvironment().getEmptyTypeSet();
}
Also used : ArrayType(org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.ArrayType) TType(org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.TType)

Example 3 with ArrayType

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

the class SubTypesOfSingleton method enumerate.

/* (non-Javadoc)
	 * @see org.eclipse.jdt.internal.corext.refactoring.typeconstraints.typesets.TypeSet#enumerate()
	 */
@Override
public EnumeratedTypeSet enumerate() {
    if (fEnumCache == null) {
        if (fUpperBound instanceof ArrayType) {
            ArrayType at = (ArrayType) fUpperBound;
            fEnumCache = EnumeratedTypeSet.makeArrayTypesForElements(TTypes.getAllSubTypesIterator(at.getComponentType()), getTypeSetEnvironment());
        } else
            fEnumCache = new EnumeratedTypeSet(TTypes.getAllSubTypesIterator(fUpperBound), getTypeSetEnvironment());
        fEnumCache.add(fUpperBound);
        fEnumCache.initComplete();
    }
    return fEnumCache;
}
Also used : ArrayType(org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.ArrayType)

Example 4 with ArrayType

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

the class SuperTypesOfSingleton method enumerate.

/* (non-Javadoc)
	 * @see org.eclipse.jdt.internal.corext.refactoring.typeconstraints.typesets.TypeSet#enumerate()
	 */
@Override
public EnumeratedTypeSet enumerate() {
    if (fEnumCache == null) {
        if (fLowerBound instanceof ArrayType) {
            ArrayType at = (ArrayType) fLowerBound;
            fEnumCache = EnumeratedTypeSet.makeArrayTypesForElements(TTypes.getAllSuperTypesIterator(at.getComponentType()), getTypeSetEnvironment());
            fEnumCache.add(getJavaLangObject());
        } else
            fEnumCache = new EnumeratedTypeSet(TTypes.getAllSuperTypesIterator(fLowerBound), getTypeSetEnvironment());
        fEnumCache.add(fLowerBound);
        fEnumCache.initComplete();
    }
    return fEnumCache;
}
Also used : ArrayType(org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.ArrayType)

Example 5 with ArrayType

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

the class EnumeratedTypeSet method upperBound.

/* (non-Javadoc)
	 * @see org.eclipse.jdt.internal.corext.refactoring.typeconstraints.typesets.TypeSet#upperBound()
	 */
@Override
public TypeSet upperBound() {
    if (fMembers.size() == 1)
        return new SingletonTypeSet(fMembers.iterator().next(), getTypeSetEnvironment());
    if (fMembers.contains(getJavaLangObject()))
        return new SingletonTypeSet(getJavaLangObject(), getTypeSetEnvironment());
    EnumeratedTypeSet result = new EnumeratedTypeSet(getTypeSetEnvironment());
    // Add to result each element of fMembers that has no proper supertype in fMembers
    result.fMembers.addAll(fMembers);
    for (Iterator<TType> iter = fMembers.iterator(); iter.hasNext(); ) {
        TType t = iter.next();
        if (t.isArrayType()) {
            ArrayType at = (ArrayType) t;
            int numDims = at.getDimensions();
            for (Iterator<TType> subIter = TTypes.getAllSubTypesIterator(at.getElementType()); subIter.hasNext(); ) {
                result.fMembers.remove(TTypes.createArrayType(subIter.next(), numDims));
            }
        } else {
            for (Iterator<TType> iterator = TTypes.getAllSubTypesIterator(t); iterator.hasNext(); ) {
                result.fMembers.remove(iterator.next());
            }
        }
    }
    result.initComplete();
    return result;
}
Also used : ArrayType(org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.ArrayType) TType(org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.TType)

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