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