}
}));
}
}
BlockContext blockContext = getChild(context, BlockContext.class);
if (blockContext != null) {
tryStatement.setBody(getAdapter(BlockAdapter.class).adapt(blockContext));
}
tryStatement.setCatchClauses(transform(context, CatchClauseContext.class,
new Function<CatchClauseContext, CatchClause>() {
@Override
public CatchClause apply(CatchClauseContext context) {
CatchClause catchClause = createNode(context, CatchClause.class);
setModifiers(context, catchClause);
CatchTypeContext catchTypeContext = getChild(context, CatchTypeContext.class);
if (catchTypeContext != null) {
catchClause.setExceptions(transform(catchTypeContext, QualifiedNameContext.class,
new Function<QualifiedNameContext, QualifiedName>() {
@Override
public QualifiedName apply(QualifiedNameContext context) {
return getAdapter(QualifiedNameAdapter.class).adapt(context);
}
}));
}
TerminalNode identifierNode = getTerminalNode(context, JavaParser.Identifier);
if (identifierNode != null) {
catchClause.setVariable(getAdapter(IdentifierAdapter.class).adapt(identifierNode));
}
BlockContext blockContext = getChild(context, BlockContext.class);
if (blockContext != null) {
catchClause.setBody(getAdapter(BlockAdapter.class).adapt(blockContext));
}
return catchClause;
}
}));
FinallyBlockContext finallyBlockContext = getChild(context, FinallyBlockContext.class);
if (finallyBlockContext != null) {
BlockContext finallyBodyContext = getChild(finallyBlockContext, BlockContext.class);
if (finallyBodyContext != null) {
tryStatement.setFinallyBlock(getAdapter(BlockAdapter.class).adapt(finallyBodyContext));
}
}