use of com.google.devtools.j2objc.ast.CatchClause in project j2objc by google.
the class StatementGenerator method visit.
@Override
public boolean visit(TryStatement node) {
List<VariableDeclarationExpression> resources = node.getResources();
boolean hasResources = !resources.isEmpty();
boolean extendedTryWithResources = hasResources && (!node.getCatchClauses().isEmpty() || node.getFinally() != null);
if (hasResources && !extendedTryWithResources) {
printBasicTryWithResources(node.getBody(), resources);
return false;
}
buffer.append("@try ");
if (extendedTryWithResources) {
// Put resources inside the body of this statement (JSL 14.20.3.2).
printBasicTryWithResources(node.getBody(), resources);
} else {
node.getBody().accept(this);
}
buffer.append(' ');
for (CatchClause cc : node.getCatchClauses()) {
if (cc.getException().getType() instanceof UnionType) {
printMultiCatch(cc);
} else {
buffer.append("@catch (");
cc.getException().accept(this);
buffer.append(") {\n");
printStatements(cc.getBody().getStatements());
buffer.append("}\n");
}
}
if (node.getFinally() != null) {
buffer.append(" @finally {\n");
printStatements(node.getFinally().getStatements());
buffer.append("}\n");
}
return false;
}
use of com.google.devtools.j2objc.ast.CatchClause in project j2objc by google.
the class NilCheckResolver method visit.
@Override
public boolean visit(TryStatement node) {
pushTryScope();
for (VariableDeclarationExpression resource : node.getResources()) {
resource.accept(this);
}
node.getBody().accept(this);
popAndMerge();
pushScope();
for (CatchClause catchClause : node.getCatchClauses()) {
scope.mergeDownAndReset();
catchClause.accept(this);
}
popAndMerge();
Block finallyBlock = node.getFinally();
if (finallyBlock != null) {
finallyBlock.accept(this);
}
return false;
}
Aggregations