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;
}
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();
}
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;
}
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;
}
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;
}
Aggregations