本文整理匯總了Java中org.eclipse.jdt.core.dom.Modifier.isSynchronized方法的典型用法代碼示例。如果您正苦於以下問題:Java Modifier.isSynchronized方法的具體用法?Java Modifier.isSynchronized怎麽用?Java Modifier.isSynchronized使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jdt.core.dom.Modifier
的用法示例。
在下文中一共展示了Modifier.isSynchronized方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: endVisit
import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
@Override
public void endVisit(MethodDeclaration node) {
int modifiers = node.getModifiers();
if (Modifier.isNative(modifiers)) {
String nativeCode = extractNativeCode(node);
if (nativeCode != null) {
Block body = new Block();
body.getStatements().add(new NativeStatement(nativeCode));
node.setBody(body);
node.removeModifiers(Modifier.NATIVE);
}
}
if (Modifier.isSynchronized(modifiers)) {
ITypeBinding declaringClass = node.getMethodBinding().getDeclaringClass();
SynchronizedStatement syncStmt = new SynchronizedStatement(
Modifier.isStatic(modifiers) ? new TypeLiteral(declaringClass)
: new ThisExpression(declaringClass));
syncStmt.setBody(TreeUtil.remove(node.getBody()));
Block newBody = new Block();
newBody.getStatements().add(syncStmt);
node.setBody(newBody);
node.removeModifiers(Modifier.SYNCHRONIZED);
}
}
示例2: getAdornmentFlags
import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
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;
}
示例3: printModifiers
import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
private void printModifiers(int modifiers) {
if (Modifier.isPublic(modifiers)) {
sb.print("public ");
}
if (Modifier.isProtected(modifiers)) {
sb.print("protected ");
}
if (Modifier.isPrivate(modifiers)) {
sb.print("private ");
}
if (Modifier.isStatic(modifiers)) {
sb.print("static ");
}
if (Modifier.isAbstract(modifiers)) {
sb.print("abstract ");
}
if (Modifier.isFinal(modifiers)) {
sb.print("final ");
}
if (Modifier.isSynchronized(modifiers)) {
sb.print("synchronized ");
}
if (Modifier.isVolatile(modifiers)) {
sb.print("volatile ");
}
if (Modifier.isNative(modifiers)) {
sb.print("native ");
}
if (Modifier.isStrictfp(modifiers)) {
sb.print("strictfp ");
}
if (Modifier.isTransient(modifiers)) {
sb.print("transient ");
}
if ((modifiers & BindingUtil.ACC_SYNTHETIC) > 0) {
sb.print("synthetic ");
}
}
示例4: extractBasicModifiersFromBinding
import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
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 */
}
示例5: isSynchronized
import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
private static boolean isSynchronized(MethodDeclaration decl) {
int modifiers = decl.getModifiers();
return (Modifier.isSynchronized(modifiers));
}
示例6: isSynchronized
import org.eclipse.jdt.core.dom.Modifier; //導入方法依賴的package包/類
public static boolean isSynchronized(IBinding binding) {
return Modifier.isSynchronized(binding.getModifiers());
}