Java Code Examples for org.eclipse.jdt.core.Flags#AccInterface

The following examples show how to use org.eclipse.jdt.core.Flags#AccInterface . 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: JdtTypesProposalProvider.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Compute the JVM modifiers that corresponds to the given description.
 *
 * <p>This function fixes the issue related to the missed modifiers given to the content assist.
 *
 * @param context the current content assist context.
 * @param description the description.
 * @return the JVM modifiers.
 * @since 2.11
 */
protected int getDirtyStateModifiers(ContentAssistContext context, IEObjectDescription description) {
	EObject eobject = description.getEObjectOrProxy();
	if (eobject.eIsProxy()) {
		eobject = EcoreUtil.resolve(eobject, context.getResource().getResourceSet());
	}
	int accessModifiers = Flags.AccPublic;
	int otherModifiers = 0;
	if (eobject instanceof JvmMember) {
		final JvmMember member = (JvmMember) eobject;
		switch (member.getVisibility()) {
		case PUBLIC:
			accessModifiers = Flags.AccPublic;
			break;
		case PRIVATE:
			accessModifiers = Flags.AccPrivate;
			break;
		case PROTECTED:
			accessModifiers = Flags.AccProtected;
			break;
		case DEFAULT:
		default:
			accessModifiers = Flags.AccDefault;
			break;
		}
		if (DeprecationUtil.isDeprecated(member)) {
			otherModifiers |= Flags.AccDeprecated;
		}
		if (eobject instanceof JvmDeclaredType) {
			final JvmDeclaredType type = (JvmDeclaredType) eobject;
			if (type.isFinal()) {
				otherModifiers |= Flags.AccFinal;
			}
			if (type.isAbstract()) {
				otherModifiers |= Flags.AccAbstract;
			}
			if (type.isStatic()) {
				otherModifiers |= Flags.AccStatic;
			}
			if (type instanceof JvmEnumerationType) {
                otherModifiers |= Flags.AccEnum;
            } else  if (type instanceof JvmAnnotationType) {
                otherModifiers |= Flags.AccAnnotation;
            } else if (type instanceof JvmGenericType) {
                if (((JvmGenericType) type).isInterface()) {
                    otherModifiers |= Flags.AccInterface;
                }
            }
		}
	}
	return accessModifiers | otherModifiers;
}