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

The following examples show how to use org.eclipse.jdt.core.dom.Modifier#isSynchronized() . 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: NumberOfFields.java    From ck with Apache License 2.0 5 votes vote down vote up
@Override
public void visit(FieldDeclaration node) {
	fields++;
	fieldNames.addAll(getVariableName(node.fragments()));

	boolean isPublic = Modifier.isPublic(node.getModifiers());
	boolean isPrivate = Modifier.isPrivate(node.getModifiers());
	boolean isProtected = Modifier.isProtected(node.getModifiers());

	if(isPublic)
		publicFields++;
	else if(isPrivate)
		privateFields++;
	else if(isProtected)
		protectedFields++;
	else
		defaultFields++;

	// other characteristics rather than visibility
	boolean isStatic = Modifier.isStatic(node.getModifiers());
	boolean isFinal = Modifier.isFinal(node.getModifiers());
	boolean isSynchronized = Modifier.isSynchronized(node.getModifiers());
	
	if(isStatic)
		staticFields++;

	if(isFinal)
		finalFields++;

	if(isSynchronized)
		synchronizedFields++;

}
 
Example 2
Source File: NumberOfMethods.java    From ck with Apache License 2.0 5 votes vote down vote up
@Override
public void visit(MethodDeclaration node) {
	methods++;

	// visibility
	boolean isPublic = Modifier.isPublic(node.getModifiers());
	boolean isPrivate = Modifier.isPrivate(node.getModifiers());
	boolean isProtected = Modifier.isProtected(node.getModifiers());

	if(isPublic)
		publicMethods++;
	else if(isPrivate)
		privateMethods++;
	else if(isProtected)
		protectedMethods++;
	else
		defaultMethods++;

	// other characteristics

	boolean isFinal = Modifier.isFinal(node.getModifiers());
	boolean isSynchronized = Modifier.isSynchronized(node.getModifiers());
	boolean isAbstract = Modifier.isAbstract(node.getModifiers());
	boolean isStatic = Modifier.isStatic(node.getModifiers());

	if(isStatic)
		staticMethods++;

	if(isAbstract)
		abstractMethods++;

	if(isFinal)
		finalMethods++;

	if(isSynchronized)
		synchronizedMethods++;
}
 
Example 3
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 4
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;
}
 
Example 5
Source File: JavaASTVisitor.java    From SnowGraph with Apache License 2.0 4 votes vote down vote up
private static boolean isSynchronized(MethodDeclaration decl) {
    int modifiers = decl.getModifiers();
    return (Modifier.isSynchronized(modifiers));
}