Search in sources :

Example 1 with DExcept

use of edu.rice.cs.caper.bayou.core.dsl.DExcept in project bayou by capergroup.

the class DOMTryStatement method handle.

@Override
public DSubTree handle() {
    DSubTree tree = new DSubTree();
    // restriction: considering only the first catch clause
    DSubTree Ttry = new DOMBlock(statement.getBody(), visitor).handle();
    DSubTree Tcatch;
    if (!statement.catchClauses().isEmpty())
        Tcatch = new DOMCatchClause((CatchClause) statement.catchClauses().get(0), visitor).handle();
    else
        Tcatch = new DSubTree();
    DSubTree Tfinally = new DOMBlock(statement.getFinally(), visitor).handle();
    boolean except = Ttry.isValid() && Tcatch.isValid();
    if (except)
        tree.addNode(new DExcept(Ttry.getNodes(), Tcatch.getNodes()));
    else {
        // only one of these will add nodes
        tree.addNodes(Ttry.getNodes());
        tree.addNodes(Tcatch.getNodes());
    }
    tree.addNodes(Tfinally.getNodes());
    return tree;
}
Also used : DExcept(edu.rice.cs.caper.bayou.core.dsl.DExcept) DSubTree(edu.rice.cs.caper.bayou.core.dsl.DSubTree) CatchClause(org.eclipse.jdt.core.dom.CatchClause)

Aggregations

DExcept (edu.rice.cs.caper.bayou.core.dsl.DExcept)1 DSubTree (edu.rice.cs.caper.bayou.core.dsl.DSubTree)1 CatchClause (org.eclipse.jdt.core.dom.CatchClause)1