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

The following examples show how to use org.eclipse.jdt.core.Flags#AccDefault . 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: XbaseImages.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected int toFlags(JvmVisibility visibility) {
	switch (visibility) {
		case PRIVATE:
			return Flags.AccPrivate;
		case PROTECTED:
			return Flags.AccProtected;
		case PUBLIC:
			return Flags.AccPublic;
		default:
			return Flags.AccDefault;
	}
}
 
Example 2
Source File: XbaseImages2.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected int toFlags(JvmVisibility visibility) {
	switch (visibility) {
		case PRIVATE:
			return Flags.AccPrivate;
		case PROTECTED:
			return Flags.AccProtected;
		case PUBLIC:
			return Flags.AccPublic;
		default:
			return Flags.AccDefault;
	}
}
 
Example 3
Source File: XbaseReferenceProposalCreator.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
protected Image computeImage(JvmFeature feature) {
	int flags = 0;
	int decorator = 0;
	switch(feature.getVisibility()) {
		case PUBLIC: flags = Flags.AccPublic; break;
		case PROTECTED: flags = Flags.AccProtected; break;
		case PRIVATE: flags = Flags.AccPrivate; break;
		case DEFAULT: flags = Flags.AccDefault; break;
	}
	JvmDeclaredType declaringType = feature.getDeclaringType();
	boolean interfaceOrAnnotation = false;
	if (declaringType instanceof JvmGenericType) {
		interfaceOrAnnotation = ((JvmGenericType) declaringType).isInterface();
	} else if (declaringType instanceof JvmAnnotationType) {
		interfaceOrAnnotation = true;
	}
	if (feature instanceof JvmConstructor) {
		decorator = JavaElementImageDescriptor.CONSTRUCTOR;
		if (declaringType.isAbstract()) {
			flags |= Flags.AccAbstract;
			decorator |= JavaElementImageDescriptor.ABSTRACT;
		}
		return computeConstructorImage(declaringType.getDeclaringType() != null, interfaceOrAnnotation, flags, decorator);
	} else if (feature instanceof JvmOperation) {
		JvmOperation operation = (JvmOperation) feature;
		if (operation.isStatic()) {
			flags |= Flags.AccStatic;
			decorator |= JavaElementImageDescriptor.STATIC;
		}
		if (operation.isAbstract()) {
			flags |= Flags.AccAbstract;
			decorator |= JavaElementImageDescriptor.ABSTRACT;
		}
		if (operation.isFinal()) {
			flags |= Flags.AccFinal;
			decorator |= JavaElementImageDescriptor.FINAL;
		}
		return computeMethodImage(interfaceOrAnnotation, flags, decorator);
	} else if (feature instanceof JvmField) {
		JvmField field = (JvmField) feature;
		if (field.isStatic()) {
			flags |= Flags.AccStatic;
			decorator |= JavaElementImageDescriptor.STATIC;
		}
		if (field.isFinal()) {
			flags |= Flags.AccFinal;
			decorator |= JavaElementImageDescriptor.FINAL;
		}
		if (declaringType instanceof JvmEnumerationType)
			flags |= Flags.AccEnum;
		return computeFieldImage(interfaceOrAnnotation, flags, decorator);
	} 
	return null;
}
 
Example 4
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;
}