private boolean areSameTypeBindingsByAliasingTypeCaptures(final ITypeBinding type1, final ITypeBinding type2) { if (type1.isCapture() ^ type2.isCapture()) { return false; } else if (type1.isCapture()) { return areSameTypeBindings(type1.getWildcard(), type2.getWildcard()); } else { return type1.equals(type2); } }
/** * If a type variable, return the bound (getTypeVariablesBase()). If a parameterized type, return the generic type. */ public static ITypeBinding getErasedType(ITypeBinding returnType, AST ast) { if (returnType.isTypeVariable() || returnType.isCapture()) return getTypesVariablesBase(returnType, ast); return returnType.getTypeDeclaration(); // Things like "Collection<? extends Bla>" are parameterized types... }
public static ITypeBinding getTypesVariablesBase(ITypeBinding returnType, AST ast) { assert returnType.isTypeVariable() || returnType.isCapture(); if (returnType.getTypeBounds().length > 0) return returnType.getTypeBounds()[0]; // TODO: why is there more than one bound? else return ast.resolveWellKnownType("java.lang.Object"); }
protected void initialize(ITypeBinding binding, IJavaProject javaProject) { Assert.isTrue(binding.isCapture()); super.initialize(binding); fWildcard= (WildcardType) getEnvironment().create(binding.getWildcard()); fJavaProject= javaProject; }
protected void initialize(ITypeBinding binding, IJavaProject javaProject) { Assert.isTrue(binding.isCapture()); super.initialize(binding); fWildcard= (WildcardType) getEnvironment().create(binding.getWildcard()); fJavaProject= javaProject; }
protected void initialize(ITypeBinding binding, IJavaProject javaProject) { Assert.isTrue(binding.isCapture()); super.initialize(binding); fWildcard= (WildcardType) getEnvironment().create(binding.getWildcard()); fJavaProject= javaProject; }
private static ITypeBinding normalizeTypeBinding(ITypeBinding binding) { if (binding != null && !binding.isNullType() && !"void".equals(binding.getName())) { //$NON-NLS-1$ if (binding.isAnonymous()) { ITypeBinding[] baseBindings= binding.getInterfaces(); if (baseBindings.length > 0) { return baseBindings[0]; } return binding.getSuperclass(); } if (binding.isCapture()) { return binding.getWildcard(); } return binding; } return null; }
private static ITypeBinding normalizeTypeBinding(ITypeBinding binding) { if (binding != null && !binding.isNullType() && !"void".equals(binding.getName())) { //$NON-NLS-1$ if (binding.isAnonymous()) { ITypeBinding[] baseBindings= binding.getInterfaces(); if (baseBindings.length > 0) { return baseBindings[0]; } return binding.getSuperclass(); } if (binding.isCapture()) { return binding.getWildcard(); } return binding; } return null; }
private static ITypeBinding normalizeTypeBinding(ITypeBinding binding) { if (binding != null && !binding.isNullType() && !"void".equals(binding.getName())) { //$NON-NLS-1$ if (binding.isAnonymous()) { ITypeBinding[] baseBindings= binding.getInterfaces(); if (baseBindings.length > 0) { return baseBindings[0]; } return binding.getSuperclass(); } if (binding.isCapture()) { return binding.getWildcard(); } return binding; } return null; }
private static ITypeBinding normalizeTypeBinding(ITypeBinding binding) { if (binding != null && !binding.isNullType() && !"void".equals(binding.getName())) { //$NON-NLS-1$ if (binding.isAnonymous()) { ITypeBinding[] baseBindings= binding.getInterfaces(); if (baseBindings.length > 0) { return baseBindings[0]; } return binding.getSuperclass(); } if (binding.isCapture()) { return binding.getWildcard(); } return binding; } return null; }
private static ITypeBinding normalizeTypeBinding(ITypeBinding binding) { if (binding != null && !binding.isNullType() && !"void".equals(binding.getName())) { //$NON-NLS-1$ if (binding.isAnonymous()) { ITypeBinding[] baseBindings= binding.getInterfaces(); if (baseBindings.length > 0) { return baseBindings[0]; } return binding.getSuperclass(); } if (binding.isCapture()) { return binding.getWildcard(); } return binding; } return null; }
private static ITypeBinding normalizeTypeBinding(ITypeBinding binding) { if (binding != null && !binding.isNullType() && !"void".equals(binding.getName())) { //$NON-NLS-1$ if (binding.isAnonymous()) { ITypeBinding[] baseBindings= binding.getInterfaces(); if (baseBindings.length > 0) { return baseBindings[0]; } return binding.getSuperclass(); } if (binding.isCapture()) { return binding.getWildcard(); } return binding; } return null; }
/** * Normalizes a type binding received from an expression to a type binding that can be used in a declaration signature. * Anonymous types are normalized, to the super class or interface. For null or void bindings * <code>null</code> is returned. * @param binding the binding to normalize * @return the normalized binding */ public static ITypeBinding normalizeTypeBinding(ITypeBinding binding) { if (binding != null && !binding.isNullType() && !isVoidType(binding)) { if (binding.isAnonymous()) { ITypeBinding[] baseBindings= binding.getInterfaces(); if (baseBindings.length > 0) { return baseBindings[0]; } return binding.getSuperclass(); } if (binding.isCapture()) { return binding.getWildcard(); } return binding; } return null; }
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; }
private static ImageDescriptor getBaseImageDescriptor(IBinding binding, int flags) { if (binding instanceof ITypeBinding) { ITypeBinding typeBinding= (ITypeBinding) binding; if (typeBinding.isArray()) { typeBinding= typeBinding.getElementType(); } if (typeBinding.isCapture()) { typeBinding.getWildcard(); } return getTypeImageDescriptor(typeBinding.getDeclaringClass() != null, typeBinding, flags); } else if (binding instanceof IMethodBinding) { ITypeBinding type= ((IMethodBinding) binding).getDeclaringClass(); int modifiers= binding.getModifiers(); if (type.isEnum() && (!Modifier.isPublic(modifiers) && !Modifier.isProtected(modifiers) && !Modifier.isPrivate(modifiers)) && ((IMethodBinding) binding).isConstructor()) return JavaPluginImages.DESC_MISC_PRIVATE; return getMethodImageDescriptor(binding.getModifiers()); } else if (binding instanceof IVariableBinding) return getFieldImageDescriptor((IVariableBinding) binding); return JavaPluginImages.DESC_OBJS_UNKNOWN; }
private static ImageDescriptor getBaseImageDescriptor(IBinding binding, int flags) { if (binding instanceof ITypeBinding) { ITypeBinding typeBinding= (ITypeBinding) binding; if (typeBinding.isArray()) { typeBinding= typeBinding.getElementType(); } if (typeBinding.isCapture()) { typeBinding.getWildcard(); } return getTypeImageDescriptor(typeBinding.getDeclaringClass() != null, typeBinding, flags); } else if (binding instanceof IMethodBinding) { ITypeBinding type= ((IMethodBinding) binding).getDeclaringClass(); int modifiers= binding.getModifiers(); if (type.isEnum() && (!Modifier.isPublic(modifiers) && !Modifier.isProtected(modifiers) && !Modifier.isPrivate(modifiers)) && ((IMethodBinding) binding).isConstructor()) return JavaPluginImages.DESC_MISC_PRIVATE; return getMethodImageDescriptor(binding.getModifiers()); } else if (binding instanceof IVariableBinding) return getFieldImageDescriptor((IVariableBinding) binding); return JavaPluginImages.DESC_OBJS_UNKNOWN; }
private static ImageDescriptor getBaseImageDescriptor(IBinding binding, int flags) { if (binding instanceof ITypeBinding) { ITypeBinding typeBinding= (ITypeBinding) binding; if (typeBinding.isArray()) { typeBinding= typeBinding.getElementType(); } if (typeBinding.isCapture()) { typeBinding.getWildcard(); } return getTypeImageDescriptor(typeBinding.getDeclaringClass() != null, typeBinding, flags); } else if (binding instanceof IMethodBinding) { ITypeBinding type= ((IMethodBinding) binding).getDeclaringClass(); int modifiers= binding.getModifiers(); if (type.isEnum() && (!Modifier.isPublic(modifiers) && !Modifier.isProtected(modifiers) && !Modifier.isPrivate(modifiers)) && ((IMethodBinding) binding).isConstructor()) return JavaPluginImages.DESC_MISC_PRIVATE; return getMethodImageDescriptor(binding.getModifiers()); } else if (binding instanceof IVariableBinding) return getFieldImageDescriptor((IVariableBinding) binding); return JavaPluginImages.DESC_OBJS_UNKNOWN; }