private CSTypeReferenceExpression mappedWildcardTypeReference(ITypeBinding type) { final ITypeBinding bound = type.getBound(); return bound != null ? mappedTypeReference(bound) : OBJECT_TYPE_REFERENCE; }
private TType createSuperWildCardType(ITypeBinding binding) { TType bound= create(binding.getBound()); SuperWildcardType result= (SuperWildcardType)fSuperWildcardTypes.get(bound); if (result != null) return result; result= new SuperWildcardType(this); fSuperWildcardTypes.put(bound, result); result.initialize(binding); return result; }
private TType createExtendsWildCardType(ITypeBinding binding) { TType bound= create(binding.getBound()); ExtendsWildcardType result= fExtendsWildcardTypes.get(bound); if (result != null) return result; result= new ExtendsWildcardType(this); fExtendsWildcardTypes.put(bound, result); result.initialize(binding); return result; }
private TType createSuperWildCardType(ITypeBinding binding) { TType bound= create(binding.getBound()); SuperWildcardType result= fSuperWildcardTypes.get(bound); if (result != null) return result; result= new SuperWildcardType(this); fSuperWildcardTypes.put(bound, result); result.initialize(binding); return result; }
private TType createExtendsWildCardType(ITypeBinding binding) { TType bound= create(binding.getBound()); ExtendsWildcardType result= fExtendsWildcardTypes.get(bound); if (result != null) return result; result= new ExtendsWildcardType(this); fExtendsWildcardTypes.put(bound, result); result.initialize(binding); return result; }
private TType createExtendsWildCardType(ITypeBinding binding) { TType bound= create(binding.getBound()); ExtendsWildcardType result= (ExtendsWildcardType)fExtendsWildcardTypes.get(bound); if (result != null) return result; result= new ExtendsWildcardType(this); fExtendsWildcardTypes.put(bound, result); result.initialize(binding); return result; }
private TType createSuperWildCardType(ITypeBinding binding) { TType bound= create(binding.getBound()); SuperWildcardType result= fSuperWildcardTypes.get(bound); if (result != null) return result; result= new SuperWildcardType(this); fSuperWildcardTypes.put(bound, result); result.initialize(binding); return result; }
/** * Use this method before creating a type for a wildcard. Either to assign a wildcard to a new type or for a type to be assigned. * * @param wildcardType the wildcard type to normalize * @param isBindingToAssign If true, then a new receiver type is searched (X x= s), else the type of a sender (R r= x) * @param ast th current AST * @return Returns the normalized binding or null when only the 'null' binding */ public static ITypeBinding normalizeWildcardType(ITypeBinding wildcardType, boolean isBindingToAssign, AST ast) { ITypeBinding bound= wildcardType.getBound(); if (isBindingToAssign) { if (bound == null || !wildcardType.isUpperbound()) { return ast.resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$ } } else { if (bound == null || wildcardType.isUpperbound()) { return null; } } return bound; }
protected void initialize(ITypeBinding binding) { Assert.isTrue(binding.isWildcardType()); super.initialize(binding); ITypeBinding bound= binding.getBound(); if (bound != null) { fBound= getEnvironment().create(bound); } }
@Override protected void initialize(ITypeBinding binding) { Assert.isTrue(binding.isWildcardType()); super.initialize(binding); ITypeBinding bound= binding.getBound(); if (bound != null) { fBound= getEnvironment().create(bound); } }
@Override protected void initialize(ITypeBinding binding) { Assert.isTrue(binding.isWildcardType()); super.initialize(binding); ITypeBinding bound= binding.getBound(); if (bound != null) { fBound= getEnvironment().create(bound); } }
private String computeTypeProposal(ITypeBinding binding, ITypeParameter parameter) throws JavaModelException { final String name = TypeProposalUtils.getTypeQualifiedName(binding); if (binding.isWildcardType()) { if (binding.isUpperbound()) { // replace the wildcard ? with the type parameter name to get "E extends Bound" instead of "? extends Bound" // String contextName= name.replaceFirst("\\?", parameter.getElementName()); //$NON-NLS-1$ // upper bound - the upper bound is the bound itself return binding.getBound().getName(); } // no or upper bound - use the type parameter of the inserted type, as it may be more // restrictive (eg. List<?> list= new SerializableList<Serializable>()) return computeTypeProposal(parameter); } // not a wildcard but a type or type variable - this is unambigously the right thing to insert return name; }
public static ITypeBinding replaceWildcardsAndCaptures(ITypeBinding type) { while (type.isWildcardType() || type.isCapture() || (type.isArray() && type.getElementType().isCapture())) { ITypeBinding bound = type.getBound(); type = (bound != null) ? bound : type.getErasure(); } return type; }
public static boolean containsTypeVariables(ITypeBinding type) { if (type.isTypeVariable()) return true; if (type.isArray()) return containsTypeVariables(type.getElementType()); if (type.isCapture()) return containsTypeVariables(type.getWildcard()); if (type.isParameterizedType()) return containsTypeVariables(type.getTypeArguments()); if (type.isWildcardType() && type.getBound() != null) return containsTypeVariables(type.getBound()); return false; }
static boolean containsTypeVariables(ITypeBinding type) { if (type.isTypeVariable()) return true; if (type.isArray()) return containsTypeVariables(type.getElementType()); if (type.isCapture()) return containsTypeVariables(type.getWildcard()); if (type.isParameterizedType()) return containsTypeVariables(type.getTypeArguments()); if (type.isWildcardType() && type.getBound() != null) return containsTypeVariables(type.getBound()); return false; }
private static boolean containsTypeVariables(ITypeBinding type) { if (type.isTypeVariable()) return true; if (type.isArray()) return containsTypeVariables(type.getElementType()); if (type.isCapture()) return containsTypeVariables(type.getWildcard()); if (type.isParameterizedType()) return containsTypeVariables(type.getTypeArguments()); if (type.isTypeVariable()) return containsTypeVariables(type.getTypeBounds()); if (type.isWildcardType() && type.getBound() != null) return containsTypeVariables(type.getBound()); return false; }
/** * Normalizes the binding so that it can be used as a type inside a declaration * (e.g. variable declaration, method return type, parameter type, ...). For * null bindings Object is returned. * @param binding binding to normalize * @param ast current ast * * @return the normalized type to be used in declarations */ public static ITypeBinding normalizeForDeclarationUse(ITypeBinding binding, AST ast) { if (binding.isNullType()) return ast.resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$ if (binding.isPrimitive()) return binding; binding= normalizeTypeBinding(binding); if (binding == null || !binding.isWildcardType()) return binding; if (binding.isUpperbound()) { return binding.getBound(); } else { return ast.resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$ } }
private void collectTypeVariables(ITypeBinding typeBinding, Set<ITypeBinding> typeVariablesCollector) { if (typeBinding.isTypeVariable()) { typeVariablesCollector.add(typeBinding); ITypeBinding[] typeBounds= typeBinding.getTypeBounds(); for (int i= 0; i < typeBounds.length; i++) collectTypeVariables(typeBounds[i], typeVariablesCollector); } else if (typeBinding.isArray()) { collectTypeVariables(typeBinding.getElementType(), typeVariablesCollector); } else if (typeBinding.isParameterizedType()) { ITypeBinding[] typeArguments= typeBinding.getTypeArguments(); for (int i= 0; i < typeArguments.length; i++) collectTypeVariables(typeArguments[i], typeVariablesCollector); } else if (typeBinding.isWildcardType()) { ITypeBinding bound= typeBinding.getBound(); if (bound != null) { collectTypeVariables(bound, typeVariablesCollector); } } }
private void collectTypeVariables(ITypeBinding typeBinding, Set typeVariablesCollector) { if (typeBinding.isTypeVariable()) { typeVariablesCollector.add(typeBinding); ITypeBinding[] typeBounds= typeBinding.getTypeBounds(); for (int i= 0; i < typeBounds.length; i++) collectTypeVariables(typeBounds[i], typeVariablesCollector); } else if (typeBinding.isArray()) { collectTypeVariables(typeBinding.getElementType(), typeVariablesCollector); } else if (typeBinding.isParameterizedType()) { ITypeBinding[] typeArguments= typeBinding.getTypeArguments(); for (int i= 0; i < typeArguments.length; i++) collectTypeVariables(typeArguments[i], typeVariablesCollector); } else if (typeBinding.isWildcardType()) { ITypeBinding bound= typeBinding.getBound(); if (bound != null) { collectTypeVariables(bound, typeVariablesCollector); } } }
private void collectTypeVariables(ITypeBinding typeBinding, Set<ITypeBinding> typeVariablesCollector) { if (typeBinding.isTypeVariable()) { typeVariablesCollector.add(typeBinding); ITypeBinding[] typeBounds= typeBinding.getTypeBounds(); for (int i= 0; i < typeBounds.length; i++) collectTypeVariables(typeBounds[i], typeVariablesCollector); } else if (typeBinding.isArray()) { collectTypeVariables(typeBinding.getElementType(), typeVariablesCollector); } else if (typeBinding.isParameterizedType()) { ITypeBinding[] typeArguments= typeBinding.getTypeArguments(); for (int i= 0; i < typeArguments.length; i++) collectTypeVariables(typeArguments[i], typeVariablesCollector); } else if (typeBinding.isWildcardType()) { ITypeBinding bound= typeBinding.getBound(); if (bound != null) { collectTypeVariables(bound, typeVariablesCollector); } } }