use of com.google.devtools.j2objc.ast.SynchronizedStatement in project j2objc by google.
the class OcniExtractor method endVisit.
@Override
public void endVisit(MethodDeclaration node) {
int modifiers = node.getModifiers();
if (Modifier.isNative(modifiers)) {
NativeStatement nativeStmt = extractNativeStatement(node);
if (nativeStmt != null) {
Block body = new Block();
body.addStatement(nativeStmt);
node.setBody(body);
node.removeModifiers(Modifier.NATIVE);
}
}
if (Modifier.isSynchronized(modifiers)) {
TypeElement declaringClass = ElementUtil.getDeclaringClass(node.getExecutableElement());
SynchronizedStatement syncStmt = new SynchronizedStatement(Modifier.isStatic(modifiers) ? new TypeLiteral(declaringClass.asType(), typeUtil) : new ThisExpression(declaringClass.asType()));
syncStmt.setBody(TreeUtil.remove(node.getBody()));
Block newBody = new Block();
newBody.addStatement(syncStmt);
node.setBody(newBody);
node.removeModifiers(Modifier.SYNCHRONIZED);
}
}
Aggregations