Java Code Examples for org.eclipse.jdt.core.dom.ITypeBinding#getWildcard()
The following examples show how to use
org.eclipse.jdt.core.dom.ITypeBinding#getWildcard() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Bindings.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Normalizes a type binding received from an expression to a type binding that can be used inside a * declaration signature, but <em>not</em> as type of a declaration (use {@link #normalizeForDeclarationUse(ITypeBinding, AST)} for that). * <p> * Anonymous types are normalized to the super class or interface. For * null or void bindings, <code>null</code> is returned. * </p> * * @param binding the binding to normalize * @return the normalized binding, can be <code>null</code> * * @see #normalizeForDeclarationUse(ITypeBinding, AST) */ 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; }
Example 2
Source File: BindingLabelProvider.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
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; }
Example 3
Source File: ASTResolving.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public static boolean isUseableTypeInContext(ITypeBinding type, IBinding context, boolean noWildcards) { if (type.isArray()) { type= type.getElementType(); } if (type.isAnonymous()) { return false; } if (type.isRawType() || type.isPrimitive()) { return true; } if (type.isTypeVariable()) { return isVariableDefinedInContext(context, type); } if (type.isGenericType()) { ITypeBinding[] typeParameters= type.getTypeParameters(); for (int i= 0; i < typeParameters.length; i++) { if (!isUseableTypeInContext(typeParameters[i], context, noWildcards)) { return false; } } return true; } if (type.isParameterizedType()) { ITypeBinding[] typeArguments= type.getTypeArguments(); for (int i= 0; i < typeArguments.length; i++) { if (!isUseableTypeInContext(typeArguments[i], context, noWildcards)) { return false; } } return true; } if (type.isCapture()) { type= type.getWildcard(); } if (type.isWildcardType()) { if (noWildcards) { return false; } if (type.getBound() != null) { return isUseableTypeInContext(type.getBound(), context, noWildcards); } } return true; }