use of com.google.devtools.j2objc.ast.UnionType in project j2objc by google.
the class TreeConverter method convertUnionType.
private static TreeNode convertUnionType(org.eclipse.jdt.core.dom.UnionType node) {
UnionType newNode = new UnionType();
convertType(node, newNode);
for (Object type : node.types()) {
newNode.addType((Type) TreeConverter.convert(type));
}
return newNode;
}
use of com.google.devtools.j2objc.ast.UnionType in project j2objc by google.
the class StatementGenerator method visit.
@Override
public boolean visit(TryStatement node) {
assert node.getResources().isEmpty() : "try-with-resources is handled by Rewriter.";
buffer.append("@try ");
node.getBody().accept(this);
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.UnionType in project j2objc by google.
the class StatementGenerator method printMultiCatch.
private void printMultiCatch(CatchClause node) {
SingleVariableDeclaration exception = node.getException();
for (Type exceptionType : ((UnionType) exception.getType()).getTypes()) {
buffer.append("@catch (");
exceptionType.accept(this);
buffer.append(" *");
buffer.append(nameTable.getVariableQualifiedName(exception.getVariableElement()));
buffer.append(") {\n");
printStatements(node.getBody().getStatements());
buffer.append("}\n");
}
}
Aggregations