1 11 package org.eclipse.jdt.internal.corext.refactoring.structure; 12 13 import org.eclipse.core.runtime.Assert; 14 15 import org.eclipse.jdt.internal.corext.refactoring.structure.constraints.SuperTypeConstraintsModel; 16 import org.eclipse.jdt.internal.corext.refactoring.structure.constraints.SuperTypeConstraintsSolver; 17 import org.eclipse.jdt.internal.corext.refactoring.structure.constraints.SuperTypeSet; 18 import org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.TType; 19 import org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ConstraintVariable2; 20 import org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ITypeSet; 21 import org.eclipse.jdt.internal.corext.refactoring.typeconstraints2.ImmutableTypeVariable2; 22 23 26 public final class ExtractInterfaceConstraintsSolver extends SuperTypeConstraintsSolver { 27 28 29 private final String fName; 30 31 37 public ExtractInterfaceConstraintsSolver(final SuperTypeConstraintsModel model, final String name) { 38 super(model); 39 Assert.isNotNull(name); 40 fName= name; 41 } 42 43 46 protected final ITypeSet computeTypeEstimate(final ConstraintVariable2 variable) { 47 final TType type= variable.getType(); 48 if (variable instanceof ImmutableTypeVariable2 || !type.getErasure().equals(fModel.getSubType().getErasure())) 49 return SuperTypeSet.createTypeSet(type); 50 final TType[] types= type.getInterfaces(); 51 for (int index= 0; index < types.length; index++) { 52 if (types[index].getName().startsWith(fName) && types[index].getErasure().equals(fModel.getSuperType().getErasure())) 53 return SuperTypeSet.createTypeSet(type, types[index]); 54 } 55 return SuperTypeSet.createTypeSet(type); 56 } 57 } 58 | Popular Tags |