@Override public JCTry inline(Inliner inliner) throws CouldNotResolveImportException { return inliner .maker() .Try( inliner.<JCTree>inlineList(getResources()), getBlock().inline(inliner), inliner.inlineList(getCatches()), inlineFinallyBlock(inliner)); }
@Override public Choice<State<JCTry>> visitTry(final TryTree node, State<?> state) { return chooseSubtrees( state, s -> unify(node.getResources(), s), s -> unifyStatement(node.getBlock(), s), s -> unify(node.getCatches(), s), s -> unifyStatement(node.getFinallyBlock(), s), (resources, block, catches, finallyBlock) -> maker() .Try( resources, (JCBlock) block, List.convert(JCCatch.class, catches), (JCBlock) finallyBlock)); }
public JCTry Try(List<JCTree> resources, JCBlock body, List<JCCatch> catchers, JCBlock finalizer) { JCTry tree = new JCTry(resources, body, catchers, finalizer); tree.pos = pos; return tree; }
public JCTry Try(List<JCTree> resources, JCBlock body, List<JCCatch> catchers, JCBlock finalizer) { JCTry tree = new JCTry(resources, body, catchers, finalizer); tree.pos = pos; return tree; }
@Override public boolean visitTry(Try node) { List<JCCatch> catches = toList(JCCatch.class, node.astCatches()); return posSet(node, treeMaker.Try((JCBlock) toTree(node.astBody()), catches, (JCBlock) toTree(node.astFinally()))); }
@Override public boolean visitTry(Try node) { List<JCCatch> catches = toList(JCCatch.class, node.astCatches()); return posSet(node, treeMaker.Try((JCBlock) toTree(node.astBody()), catches, (JCBlock) toTree(node.astFinally()))); }
@Override public boolean visitTry(Try node) { List<JCCatch> catches = toList(JCCatch.class, node.astCatches()); return posSet(node, treeMaker.Try((JCBlock) toTree(node.astBody()), catches, (JCBlock) toTree(node.astFinally()))); }
public JCTree visitTry(TryTree node, P p) { JCTry t = (JCTry) node; JCBlock body = copy(t.body, p); List<JCCatch> catchers = copy(t.catchers, p); JCBlock finalizer = copy(t.finalizer, p); return M.at(t.pos).Try(body, catchers, finalizer); }
public JCTree visitTry(TryTree node, P p) { JCTry t = (JCTry) node; JCBlock body = copy(t.body, p); List<JCCatch> catchers = copy(t.catchers, p); JCBlock finalizer = copy(t.finalizer, p); return M.at(t.pos).Try(body, catchers, finalizer); }
public JCTree visitTry(TryTree node, P p) { JCTry t = (JCTry) node; List<JCTree> resources = copy(t.resources, p); JCBlock body = copy(t.body, p); List<JCCatch> catchers = copy(t.catchers, p); JCBlock finalizer = copy(t.finalizer, p); return M.at(t.pos).Try(resources, body, catchers, finalizer); }
public JCTree visitTry(TryTree node, P p) { JCTry t = (JCTry) node; List<JCTree> resources = copy(t.resources, p); JCBlock body = copy(t.body, p); List<JCCatch> catchers = copy(t.catchers, p); JCBlock finalizer = copy(t.finalizer, p); return M.at(t.pos).Try(resources, body, catchers, finalizer); }
public TryTree Try(List<? extends Tree> resources, BlockTree tryBlock, List<? extends CatchTree> catchList, BlockTree finallyBlock) { ListBuffer<JCTree> res = new ListBuffer<JCTree>(); for (Tree t : resources) res.append((JCTree)t); ListBuffer<JCCatch> catches = new ListBuffer<JCCatch>(); for (CatchTree t : catchList) catches.append((JCCatch)t); return make.at(NOPOS).Try(res.toList(), (JCBlock)tryBlock, catches.toList(), (JCBlock)finallyBlock); }
@Override public JCTry inline(Inliner inliner) throws CouldNotResolveImportException { return inliner .maker() .Try( inliner.<JCTree>inlineList(getResources()), getBlock().inline(inliner), inliner.inlineList(getCatches()), inlineFinallyBlock(inliner)); }
@Override public Choice<State<JCTry>> visitTry(final TryTree node, State<?> state) { return chooseSubtrees( state, s -> unify(node.getResources(), s), s -> unifyStatement(node.getBlock(), s), s -> unify(node.getCatches(), s), s -> unifyStatement(node.getFinallyBlock(), s), (resources, block, catches, finallyBlock) -> maker() .Try( resources, (JCBlock) block, List.convert(JCCatch.class, catches), (JCBlock) finallyBlock)); }
result = translate(twrBlock); else result = translate(make.Try(twrBlock, tree.catchers, tree.finalizer)); twrVars = twrVars.leave(); return result;
.setType(syms.intType); JCStatement exec = make.Exec(assign); JCStatement _try = make.Try(make.Block(0, List.of(exec)), catcher, null); stmts.append(_try);
.setType(syms.intType); JCStatement exec = make.Exec(assign); JCStatement _try = make.Try(make.Block(0, List.of(exec)), catcher, null); stmts.append(_try);
.setType(syms.intType); JCStatement exec = make.Exec(assign); JCStatement _try = make.Try(make.Block(0, List.of(exec)), catcher, null); stmts.append(_try);
private JCBlock makeTwrFinallyClause(Symbol primaryException, JCExpression resource) { // primaryException.addSuppressed(catchException); VarSymbol catchException = new VarSymbol(SYNTHETIC, make.paramName(2), syms.throwableType, currentMethodSym); JCStatement addSuppressionStatement = make.Exec(makeCall(make.Ident(primaryException), names.addSuppressed, List.<JCExpression>of(make.Ident(catchException)))); // try { resource.close(); } catch (e) { primaryException.addSuppressed(e); } JCBlock tryBlock = make.Block(0L, List.<JCStatement>of(makeResourceCloseInvocation(resource))); JCVariableDecl catchExceptionDecl = make.VarDef(catchException, null); JCBlock catchBlock = make.Block(0L, List.<JCStatement>of(addSuppressionStatement)); List<JCCatch> catchClauses = List.<JCCatch>of(make.Catch(catchExceptionDecl, catchBlock)); JCTry tryTree = make.Try(tryBlock, catchClauses, null); tryTree.finallyCanCompleteNormally = true; // if (primaryException != null) {try...} else resourceClose; JCIf closeIfStatement = make.If(makeNonNullCheck(make.Ident(primaryException)), tryTree, makeResourceCloseInvocation(resource)); // if (#resource != null) { if (primaryException ... } return make.Block(0L, List.<JCStatement>of(make.If(makeNonNullCheck(resource), closeIfStatement, null))); }
private JCBlock makeTwrFinallyClause(Symbol primaryException, JCExpression resource) { // primaryException.addSuppressed(catchException); VarSymbol catchException = new VarSymbol(SYNTHETIC, make.paramName(2), syms.throwableType, currentMethodSym); JCStatement addSuppressionStatement = make.Exec(makeCall(make.Ident(primaryException), names.addSuppressed, List.<JCExpression>of(make.Ident(catchException)))); // try { resource.close(); } catch (e) { primaryException.addSuppressed(e); } JCBlock tryBlock = make.Block(0L, List.<JCStatement>of(makeResourceCloseInvocation(resource))); JCVariableDecl catchExceptionDecl = make.VarDef(catchException, null); JCBlock catchBlock = make.Block(0L, List.<JCStatement>of(addSuppressionStatement)); List<JCCatch> catchClauses = List.<JCCatch>of(make.Catch(catchExceptionDecl, catchBlock)); JCTry tryTree = make.Try(tryBlock, catchClauses, null); tryTree.finallyCanCompleteNormally = true; // if (primaryException != null) {try...} else resourceClose; JCIf closeIfStatement = make.If(makeNonNullCheck(make.Ident(primaryException)), tryTree, makeResourceCloseInvocation(resource)); // if (#resource != null) { if (primaryException ... } return make.Block(0L, List.<JCStatement>of(make.If(makeNonNullCheck(resource), closeIfStatement, null))); }