Java Code Examples for org.eclipse.jdt.core.dom.Modifier#isVolatile()

The following examples show how to use org.eclipse.jdt.core.dom.Modifier#isVolatile() . 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: InJavaImporter.java    From jdt2famix with Eclipse Public License 1.0 5 votes vote down vote up
private void extractBasicModifiersFromBinding(int modifiers, NamedEntity entity) {
	Boolean publicModifier = Modifier.isPublic(modifiers);
	Boolean protectedModifier = Modifier.isProtected(modifiers);
	Boolean privateModifier = Modifier.isPrivate(modifiers);
	if (publicModifier)
		entity.addModifiers("public");
	if (protectedModifier)
		entity.addModifiers("protected");
	if (privateModifier)
		entity.addModifiers("private");
	if (!(publicModifier || protectedModifier || privateModifier))
		entity.addModifiers("package");
	if (Modifier.isFinal(modifiers))
		entity.addModifiers("final");
	if (Modifier.isAbstract(modifiers))
		entity.addModifiers("abstract");
	if (Modifier.isNative(modifiers))
		entity.addModifiers("native");
	if (Modifier.isSynchronized(modifiers))
		entity.addModifiers("synchronized");
	if (Modifier.isTransient(modifiers))
		entity.addModifiers("transient");
	if (Modifier.isVolatile(modifiers))
		entity.addModifiers("volatile");
	/*
	 * We do not extract the static modifier here because we want to set the
	 * hasClassScope property and we do that specifically only for attributes and
	 * methods
	 */
}
 
Example 2
Source File: VariableDeclarationFix.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private static boolean canAddFinal(IBinding binding, ASTNode declNode) {
	if (!(binding instanceof IVariableBinding))
		return false;

	IVariableBinding varbinding= (IVariableBinding)binding;
	int modifiers= varbinding.getModifiers();
	if (Modifier.isFinal(modifiers) || Modifier.isVolatile(modifiers) || Modifier.isTransient(modifiers))
		return false;

	ASTNode parent= ASTNodes.getParent(declNode, VariableDeclarationExpression.class);
	if (parent != null && ((VariableDeclarationExpression)parent).fragments().size() > 1)
		return false;

	if (varbinding.isField() && !Modifier.isPrivate(modifiers))
		return false;

	if (varbinding.isParameter()) {
		ASTNode varDecl= declNode.getParent();
		if (varDecl instanceof MethodDeclaration) {
			MethodDeclaration declaration= (MethodDeclaration)varDecl;
			if (declaration.getBody() == null)
				return false;
		}
	}

	return true;
}
 
Example 3
Source File: BindingLabelProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private static int getAdornmentFlags(IBinding binding) {
	int adornments= 0;
	final int modifiers= binding.getModifiers();
	if (Modifier.isAbstract(modifiers))
		adornments|= JavaElementImageDescriptor.ABSTRACT;
	if (Modifier.isFinal(modifiers))
		adornments|= JavaElementImageDescriptor.FINAL;
	if (Modifier.isStatic(modifiers))
		adornments|= JavaElementImageDescriptor.STATIC;
	
	if (binding.isDeprecated())
		adornments|= JavaElementImageDescriptor.DEPRECATED;
	
	if (binding instanceof IMethodBinding) {
		if (((IMethodBinding) binding).isConstructor())
			adornments|= JavaElementImageDescriptor.CONSTRUCTOR;
		if (Modifier.isSynchronized(modifiers))
			adornments|= JavaElementImageDescriptor.SYNCHRONIZED;
		if (Modifier.isNative(modifiers))
			adornments|= JavaElementImageDescriptor.NATIVE;
		ITypeBinding type= ((IMethodBinding) binding).getDeclaringClass();
		if (type.isInterface() && !Modifier.isAbstract(modifiers) && !Modifier.isStatic(modifiers))
			adornments|= JavaElementImageDescriptor.DEFAULT_METHOD;
		if (((IMethodBinding) binding).getDefaultValue() != null)
			adornments|= JavaElementImageDescriptor.ANNOTATION_DEFAULT;
	}
	if (binding instanceof IVariableBinding && ((IVariableBinding) binding).isField()) {
		if (Modifier.isTransient(modifiers))
			adornments|= JavaElementImageDescriptor.TRANSIENT;
		if (Modifier.isVolatile(modifiers))
			adornments|= JavaElementImageDescriptor.VOLATILE;
	}
	return adornments;
}