Java Code Examples for org.eclipse.jdt.core.Flags#isAnnotation()

The following examples show how to use org.eclipse.jdt.core.Flags#isAnnotation() . 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: TypeInfoFilter.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private boolean matchesModifiers(TypeNameMatch type) {
	if (fElementKind == IJavaSearchConstants.TYPE)
		return true;
	int modifiers= type.getModifiers() & TYPE_MODIFIERS;
	switch (fElementKind) {
		case IJavaSearchConstants.CLASS:
			return modifiers == 0;
		case IJavaSearchConstants.ANNOTATION_TYPE:
			return Flags.isAnnotation(modifiers);
		case IJavaSearchConstants.INTERFACE:
			return modifiers == Flags.AccInterface;
		case IJavaSearchConstants.ENUM:
			return Flags.isEnum(modifiers);
		case IJavaSearchConstants.CLASS_AND_INTERFACE:
			return modifiers == 0 || modifiers == Flags.AccInterface;
		case IJavaSearchConstants.CLASS_AND_ENUM:
			return modifiers == 0 || Flags.isEnum(modifiers);
		case IJavaSearchConstants.INTERFACE_AND_ANNOTATION:
			return Flags.isInterface(modifiers);
	}
	return false;
}
 
Example 2
Source File: SimilarElementsRequestor.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
private static final int getKind(int flags, char[] typeNameSig) {
	if (Signature.getTypeSignatureKind(typeNameSig) == Signature.TYPE_VARIABLE_SIGNATURE) {
		return VARIABLES;
	}
	if (Flags.isAnnotation(flags)) {
		return ANNOTATIONS;
	}
	if (Flags.isInterface(flags)) {
		return INTERFACES;
	}
	if (Flags.isEnum(flags)) {
		return ENUMS;
	}
	return CLASSES;
}
 
Example 3
Source File: JavaContext.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private boolean isOfKind(TypeNameMatch curr, int typeKinds, boolean is50OrHigher) {
	int flags= curr.getModifiers();
	if (Flags.isAnnotation(flags)) {
		return is50OrHigher && ((typeKinds & SimilarElementsRequestor.ANNOTATIONS) != 0);
	}
	if (Flags.isEnum(flags)) {
		return is50OrHigher && ((typeKinds & SimilarElementsRequestor.ENUMS) != 0);
	}
	if (Flags.isInterface(flags)) {
		return (typeKinds & SimilarElementsRequestor.INTERFACES) != 0;
	}
	return (typeKinds & SimilarElementsRequestor.CLASSES) != 0;
}
 
Example 4
Source File: OrganizeImportsOperation.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private boolean isOfKind(TypeNameMatch curr, int typeKinds, boolean is50OrHigher) {
	int flags= curr.getModifiers();
	if (Flags.isAnnotation(flags)) {
		return is50OrHigher && (typeKinds & SimilarElementsRequestor.ANNOTATIONS) != 0;
	}
	if (Flags.isEnum(flags)) {
		return is50OrHigher && (typeKinds & SimilarElementsRequestor.ENUMS) != 0;
	}
	if (Flags.isInterface(flags)) {
		return (typeKinds & SimilarElementsRequestor.INTERFACES) != 0;
	}
	return (typeKinds & SimilarElementsRequestor.CLASSES) != 0;
}
 
Example 5
Source File: AddImportsOperation.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private boolean isOfKind(TypeNameMatch curr, int typeKinds, boolean is50OrHigher) {
	int flags= curr.getModifiers();
	if (Flags.isAnnotation(flags)) {
		return is50OrHigher && (typeKinds & SimilarElementsRequestor.ANNOTATIONS) != 0;
	}
	if (Flags.isEnum(flags)) {
		return is50OrHigher && (typeKinds & SimilarElementsRequestor.ENUMS) != 0;
	}
	if (Flags.isInterface(flags)) {
		return (typeKinds & SimilarElementsRequestor.INTERFACES) != 0;
	}
	return (typeKinds & SimilarElementsRequestor.CLASSES) != 0;
}
 
Example 6
Source File: SimilarElementsRequestor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private static final int getKind(int flags, char[] typeNameSig) {
	if (Signature.getTypeSignatureKind(typeNameSig) == Signature.TYPE_VARIABLE_SIGNATURE) {
		return VARIABLES;
	}
	if (Flags.isAnnotation(flags)) {
		return ANNOTATIONS;
	}
	if (Flags.isInterface(flags)) {
		return INTERFACES;
	}
	if (Flags.isEnum(flags)) {
		return ENUMS;
	}
	return CLASSES;
}
 
Example 7
Source File: JavaElementImageProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public static ImageDescriptor getTypeImageDescriptor(boolean isInner, boolean isInInterfaceOrAnnotation, int flags, boolean useLightIcons) {
	if (Flags.isEnum(flags)) {
		if (useLightIcons) {
			return JavaPluginImages.DESC_OBJS_ENUM_ALT;
		}
		if (isInner) {
			return getInnerEnumImageDescriptor(isInInterfaceOrAnnotation, flags);
		}
		return getEnumImageDescriptor(flags);
	} else if (Flags.isAnnotation(flags)) {
		if (useLightIcons) {
			return JavaPluginImages.DESC_OBJS_ANNOTATION_ALT;
		}
		if (isInner) {
			return getInnerAnnotationImageDescriptor(isInInterfaceOrAnnotation, flags);
		}
		return getAnnotationImageDescriptor(flags);
	}  else if (Flags.isInterface(flags)) {
		if (useLightIcons) {
			return JavaPluginImages.DESC_OBJS_INTERFACEALT;
		}
		if (isInner) {
			return getInnerInterfaceImageDescriptor(isInInterfaceOrAnnotation, flags);
		}
		return getInterfaceImageDescriptor(flags);
	} else {
		if (useLightIcons) {
			return JavaPluginImages.DESC_OBJS_CLASSALT;
		}
		if (isInner) {
			return getInnerClassImageDescriptor(isInInterfaceOrAnnotation, flags);
		}
		return getClassImageDescriptor(flags);
	}
}
 
Example 8
Source File: InterfaceIndicatorLabelDecorator.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
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 9
Source File: JdtFlags.java    From eclipse.jdt.ls with Eclipse Public License 2.0 4 votes vote down vote up
public static boolean isAnnotation(IMember member) throws JavaModelException{
	return Flags.isAnnotation(member.getFlags());
}
 
Example 10
Source File: RefactoringAvailabilityTester.java    From eclipse.jdt.ls with Eclipse Public License 2.0 4 votes vote down vote up
public static boolean isChangeSignatureAvailable(final IMethod method) throws JavaModelException {
	return Checks.isAvailable(method) && !Flags.isAnnotation(method.getDeclaringType().getFlags());
}
 
Example 11
Source File: RefactoringAvailabilityTester.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public static boolean isChangeSignatureAvailable(final IMethod method) throws JavaModelException {
	return Checks.isAvailable(method) && !Flags.isAnnotation(method.getDeclaringType().getFlags());
}
 
Example 12
Source File: JdtFlags.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public static boolean isAnnotation(IMember member) throws JavaModelException{
	return Flags.isAnnotation(member.getFlags());
}
 
Example 13
Source File: CompletionProposalLabelProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
ImageDescriptor createTypeImageDescriptor(CompletionProposal proposal) {
	final int flags= proposal.getFlags();
	boolean isInterfaceOrAnnotation= Flags.isInterface(flags) || Flags.isAnnotation(flags);
	return decorateImageDescriptor(JavaElementImageProvider.getTypeImageDescriptor(true /* in order to get all visibility decorations */, isInterfaceOrAnnotation, flags, false), proposal);
}