Java Code Examples for org.eclipse.jdt.core.Flags#isDeprecated()
The following examples show how to use
org.eclipse.jdt.core.Flags#isDeprecated() .
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: JDTUtils.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
/** * {@code true} if the element is deprecated. Otherwise, {@code false}. */ public static boolean isDeprecated(IJavaElement element) throws JavaModelException { Assert.isNotNull(element, "element"); if (element instanceof ITypeRoot) { return Flags.isDeprecated(((ITypeRoot) element).findPrimaryType().getFlags()); } else if (element instanceof IMember) { return Flags.isDeprecated(((IMember) element).getFlags()); } return false; }
Example 2
Source File: TypeNameMatchLabelProvider.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public static ImageDescriptor getImageDescriptor(TypeNameMatch typeRef, int flags) { if (isSet(SHOW_TYPE_CONTAINER_ONLY, flags)) { if (typeRef.getPackageName().equals(typeRef.getTypeContainerName())) return JavaPluginImages.DESC_OBJS_PACKAGE; // XXX cannot check outer type for interface efficiently (5887) return JavaPluginImages.DESC_OBJS_CLASS; } else if (isSet(SHOW_PACKAGE_ONLY, flags)) { return JavaPluginImages.DESC_OBJS_PACKAGE; } else { boolean isInner= typeRef.getTypeContainerName().indexOf('.') != -1; int modifiers= typeRef.getModifiers(); ImageDescriptor desc= JavaElementImageProvider.getTypeImageDescriptor(isInner, false, modifiers, false); int adornmentFlags= 0; if (Flags.isFinal(modifiers)) { adornmentFlags |= JavaElementImageDescriptor.FINAL; } if (Flags.isAbstract(modifiers) && !Flags.isInterface(modifiers)) { adornmentFlags |= JavaElementImageDescriptor.ABSTRACT; } if (Flags.isStatic(modifiers)) { adornmentFlags |= JavaElementImageDescriptor.STATIC; } if (Flags.isDeprecated(modifiers)) { adornmentFlags |= JavaElementImageDescriptor.DEPRECATED; } return new JavaElementImageDescriptor(desc, adornmentFlags, JavaElementImageProvider.BIG_SIZE); } }
Example 3
Source File: InterfaceIndicatorLabelDecorator.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void addOverlaysFromFlags(int flags, IDecoration decoration) { ImageDescriptor type; if (Flags.isAnnotation(flags)) { type= JavaPluginImages.DESC_OVR_ANNOTATION; } else if (Flags.isEnum(flags)) { type= JavaPluginImages.DESC_OVR_ENUM; } else if (Flags.isInterface(flags)) { type= JavaPluginImages.DESC_OVR_INTERFACE; } else if (/* is class */ Flags.isAbstract(flags)) { type= JavaPluginImages.DESC_OVR_ABSTRACT_CLASS; } else { type= null; } boolean deprecated= Flags.isDeprecated(flags); boolean packageDefault= Flags.isPackageDefault(flags); /* Each decoration position can only be used once. Since we don't want to take all positions * away from other decorators, we confine ourselves to only use the top right position. */ if (type != null && !deprecated && !packageDefault) { decoration.addOverlay(type, IDecoration.TOP_RIGHT); } else if (type == null && deprecated && !packageDefault) { decoration.addOverlay(JavaPluginImages.DESC_OVR_DEPRECATED, IDecoration.TOP_RIGHT); } else if (type != null || deprecated || packageDefault) { decoration.addOverlay(new TypeIndicatorOverlay(type, deprecated, packageDefault), IDecoration.TOP_RIGHT); } }
Example 4
Source File: DOMMember.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * @see IDOMMember#setFlags(int) */ public void setFlags(int flags) { becomeDetailed(); if (Flags.isDeprecated(this.fFlags)) { this.fFlags= flags | ClassFileConstants.AccDeprecated; } else { this.fFlags= flags & (~ClassFileConstants.AccDeprecated); } fragment(); this.fModifiers= generateFlags(); }
Example 5
Source File: JdtFlags.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 4 votes |
public static boolean isDeprecated(IMember member) throws JavaModelException{ return Flags.isDeprecated(member.getFlags()); }
Example 6
Source File: DocumentSymbolHandler.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 4 votes |
private boolean isDeprecated(IJavaElement element) throws JavaModelException { if (element instanceof ITypeRoot) { return Flags.isDeprecated(((ITypeRoot) element).findPrimaryType().getFlags()); } return false; }
Example 7
Source File: JdtFlags.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public static boolean isDeprecated(IMember member) throws JavaModelException{ return Flags.isDeprecated(member.getFlags()); }
Example 8
Source File: CompletionProposalLabelProvider.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
/** * Returns a version of <code>descriptor</code> decorated according to * the passed <code>modifier</code> flags. * * @param descriptor the image descriptor to decorate * @param proposal the proposal * @return an image descriptor for a method proposal * @see Flags */ private ImageDescriptor decorateImageDescriptor(ImageDescriptor descriptor, CompletionProposal proposal) { int adornments= 0; int flags= proposal.getFlags(); int kind= proposal.getKind(); boolean deprecated= Flags.isDeprecated(flags); if (!deprecated) { CompletionProposal[] requiredProposals= proposal.getRequiredProposals(); if (requiredProposals != null) { for (int i= 0; i < requiredProposals.length; i++) { CompletionProposal requiredProposal= requiredProposals[i]; if (requiredProposal.getKind() == CompletionProposal.TYPE_REF) { deprecated |= Flags.isDeprecated(requiredProposal.getFlags()); } } } } if (deprecated) adornments |= JavaElementImageDescriptor.DEPRECATED; if (kind == CompletionProposal.FIELD_REF || kind == CompletionProposal.METHOD_DECLARATION || kind == CompletionProposal.METHOD_NAME_REFERENCE || kind == CompletionProposal.METHOD_REF || kind == CompletionProposal.CONSTRUCTOR_INVOCATION) if (Flags.isStatic(flags)) adornments |= JavaElementImageDescriptor.STATIC; if (kind == CompletionProposal.METHOD_DECLARATION || kind == CompletionProposal.METHOD_NAME_REFERENCE || kind == CompletionProposal.METHOD_REF || kind == CompletionProposal.CONSTRUCTOR_INVOCATION) if (Flags.isSynchronized(flags)) adornments |= JavaElementImageDescriptor.SYNCHRONIZED; if (kind == CompletionProposal.METHOD_DECLARATION || kind == CompletionProposal.METHOD_NAME_REFERENCE || kind == CompletionProposal.METHOD_REF) if (Flags.isDefaultMethod(flags)) adornments|= JavaElementImageDescriptor.DEFAULT_METHOD; if (kind == CompletionProposal.ANNOTATION_ATTRIBUTE_REF) if (Flags.isAnnnotationDefault(flags)) adornments|= JavaElementImageDescriptor.ANNOTATION_DEFAULT; if (kind == CompletionProposal.TYPE_REF && Flags.isAbstract(flags) && !Flags.isInterface(flags)) adornments |= JavaElementImageDescriptor.ABSTRACT; if (kind == CompletionProposal.FIELD_REF) { if (Flags.isFinal(flags)) adornments |= JavaElementImageDescriptor.FINAL; if (Flags.isTransient(flags)) adornments |= JavaElementImageDescriptor.TRANSIENT; if (Flags.isVolatile(flags)) adornments |= JavaElementImageDescriptor.VOLATILE; } return new JavaElementImageDescriptor(descriptor, adornments, JavaElementImageProvider.SMALL_SIZE); }
Example 9
Source File: HierarchyLabelProvider.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private ImageDescriptor getTypeImageDescriptor(IType type) { ITypeHierarchy hierarchy= fHierarchy.getHierarchy(); if (hierarchy == null) { return new JavaElementImageDescriptor(JavaPluginImages.DESC_OBJS_CLASS, 0, JavaElementImageProvider.BIG_SIZE); } int flags= hierarchy.getCachedFlags(type); if (flags == -1) { return new JavaElementImageDescriptor(JavaPluginImages.DESC_OBJS_CLASS, 0, JavaElementImageProvider.BIG_SIZE); } boolean isInterface= Flags.isInterface(flags); IType declaringType= type.getDeclaringType(); boolean isInner= declaringType != null; boolean isInInterfaceOrAnnotation= false; if (isInner) { int declaringTypeFlags= hierarchy.getCachedFlags(declaringType); if (declaringTypeFlags != -1) { isInInterfaceOrAnnotation= Flags.isInterface(declaringTypeFlags); } else { // declaring type is not in hierarchy, so we have to pay the price for resolving here try { isInInterfaceOrAnnotation= declaringType.isInterface(); } catch (JavaModelException e) { } } } ImageDescriptor desc= JavaElementImageProvider.getTypeImageDescriptor(isInner, isInInterfaceOrAnnotation, flags, isInDifferentHierarchyScope(type)); int adornmentFlags= 0; if (Flags.isFinal(flags)) { adornmentFlags |= JavaElementImageDescriptor.FINAL; } if (Flags.isAbstract(flags) && !isInterface) { adornmentFlags |= JavaElementImageDescriptor.ABSTRACT; } if (Flags.isStatic(flags)) { adornmentFlags |= JavaElementImageDescriptor.STATIC; } if (Flags.isDeprecated(flags)) { adornmentFlags |= JavaElementImageDescriptor.DEPRECATED; } return new JavaElementImageDescriptor(desc, adornmentFlags, JavaElementImageProvider.BIG_SIZE); }
Example 10
Source File: FilteredTypesSelectionDialog.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private int compareDeprecation(int leftType, int rightType) { boolean rightIsDeprecated= Flags.isDeprecated(rightType); if (Flags.isDeprecated(leftType)) return rightIsDeprecated ? 0 : +1; return rightIsDeprecated ? -1 : 0; }
Example 11
Source File: JavaElementImageProvider.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private int computeJavaAdornmentFlags(IJavaElement element, int renderFlags) { int flags= 0; if (showOverlayIcons(renderFlags)) { try { if (element instanceof IMember) { IMember member= (IMember)element; int modifiers= member.getFlags(); if (confirmAbstract(member) && JdtFlags.isAbstract(member)) flags|= JavaElementImageDescriptor.ABSTRACT; if (Flags.isFinal(modifiers) || isInterfaceOrAnnotationField(member) || isEnumConstant(member, modifiers)) flags|= JavaElementImageDescriptor.FINAL; if (Flags.isStatic(modifiers) || isInterfaceOrAnnotationFieldOrType(member) || isEnumConstant(member, modifiers)) flags|= JavaElementImageDescriptor.STATIC; if (Flags.isDeprecated(modifiers)) flags|= JavaElementImageDescriptor.DEPRECATED; int elementType= element.getElementType(); if (elementType == IJavaElement.METHOD) { if (((IMethod)element).isConstructor()) flags|= JavaElementImageDescriptor.CONSTRUCTOR; if (Flags.isSynchronized(modifiers)) // collides with 'super' flag flags|= JavaElementImageDescriptor.SYNCHRONIZED; if (Flags.isNative(modifiers)) flags|= JavaElementImageDescriptor.NATIVE; if (Flags.isDefaultMethod(modifiers)) flags|= JavaElementImageDescriptor.DEFAULT_METHOD; if (Flags.isAnnnotationDefault(modifiers)) flags|= JavaElementImageDescriptor.ANNOTATION_DEFAULT; } if (member.getElementType() == IJavaElement.TYPE) { if (JavaModelUtil.hasMainMethod((IType)member)) { flags|= JavaElementImageDescriptor.RUNNABLE; } } if (member.getElementType() == IJavaElement.FIELD) { if (Flags.isVolatile(modifiers)) flags|= JavaElementImageDescriptor.VOLATILE; if (Flags.isTransient(modifiers)) flags|= JavaElementImageDescriptor.TRANSIENT; } } else if (element instanceof ILocalVariable && Flags.isFinal(((ILocalVariable)element).getFlags())) { flags|= JavaElementImageDescriptor.FINAL; } } catch (JavaModelException e) { // do nothing. Can't compute runnable adornment or get flags } } return flags; }
Example 12
Source File: ReflectExtensions.java From sarl with Apache License 2.0 | 4 votes |
private static boolean isDeprecated(Method method) { return Flags.isDeprecated(method.getModifiers()) || method.getAnnotation(Deprecated.class) != null; }