protected int diffThrow(JCThrow oldT, JCThrow newT, int[] bounds) { int localPointer = bounds[0]; // expr int[] exprBounds = getBounds(oldT.expr); copyTo(localPointer, exprBounds[0]); localPointer = diffTree(oldT.expr, newT.expr, exprBounds); copyTo(localPointer, bounds[1]); return bounds[1]; }
/** * Checks if the statement is of the form 'if (x == null) {throw WHATEVER;}, * where the block braces are optional. If it is of this form, returns "x". * If it is not of this form, returns null. */ public String returnVarNameIfNullCheck(JCStatement stat) { if (!(stat instanceof JCIf)) return null; /* Check that the if's statement is a throw statement, possibly in a block. */ { JCStatement then = ((JCIf) stat).thenpart; if (then instanceof JCBlock) { List<JCStatement> stats = ((JCBlock) then).stats; if (stats.length() == 0) return null; then = stats.get(0); } if (!(then instanceof JCThrow)) return null; } /* Check that the if's conditional is like 'x == null'. Return from this method (don't generate a nullcheck) if 'x' is equal to our own variable's name: There's already a nullcheck here. */ { JCExpression cond = ((JCIf) stat).cond; while (cond instanceof JCParens) cond = ((JCParens) cond).expr; if (!(cond instanceof JCBinary)) return null; JCBinary bin = (JCBinary) cond; if (!CTC_EQUAL.equals(treeTag(bin))) return null; if (!(bin.lhs instanceof JCIdent)) return null; if (!(bin.rhs instanceof JCLiteral)) return null; if (!CTC_BOT.equals(typeTag(bin.rhs))) return null; return ((JCIdent) bin.lhs).name.toString(); } }
public void visitThrow(JCThrow that) { try { print("JCThrow:"); } catch (Exception e) { } super.visitThrow(that); }
public void visitThrow(JCThrow tree) { try { print("throw "); printExpr(tree.expr); print(";"); } catch (IOException e) { throw new UncheckedIOException(e); } }
@Override public void visitLambda(JCLambda tree) { if (tree.getBodyKind() == BodyKind.STATEMENT) { JCExpression ident = make.at(tree).QualIdent(symtab.assertionErrorType.tsym); JCThrow throwTree = make.Throw(make.NewClass(null, List.nil(), ident, List.nil(), null)); tree.body = make.Block(0, List.of(throwTree)); } }
public JCThrow Throw(JCExpression expr) { return invoke(Throw, expr); }
@Override public void visitThrow(JCThrow tree) { aPrint("throw "); print(tree.expr); println(";", tree); }
public AJCThrow(JCThrow ltree) { super(ltree.expr); }
public AJCThrow(JCThrow ltree, String lcomment) { this(ltree); setComment(lcomment); }
@Override public JCThrow inline(Inliner inliner) throws CouldNotResolveImportException { return inliner.maker().Throw(getExpression().inline(inliner)); }
@Override public void visitThrow(JCThrow tree) { printNode(tree); child("expr", tree.expr); indent--; }
@Override public void visitThrow(JCThrow node) { set(node, new Throw().rawThrowable(toTree(node.getExpression()))); }
@Override public Choice<State<JCThrow>> visitThrow(ThrowTree node, State<?> state) { return chooseSubtrees(state, s -> unifyExpression(node.getExpression(), s), maker()::Throw); }
public void visitThrow(JCThrow tree) { attribExpr(tree.expr, env, syms.throwableType); result = null; }