private static Optional<JCCatch> catchesType( JCTry tryStatement, Type assertionErrorType, VisitorState state) { return tryStatement.getCatches().stream() .filter( catchTree -> { Type type = ASTHelpers.getType(catchTree.getParameter()); return (type.isUnion() ? Streams.stream(((UnionClassType) type).getAlternativeTypes()) : Stream.of(type)) .anyMatch(caught -> isSubtype(assertionErrorType, caught, state)); }) .findFirst(); }
if (tryStatement.getCatches().size() != 1) { JCCatch catchTree = Iterables.getOnlyElement(tryStatement.getCatches()); if (catchTree.getParameter().getType().getKind() == Kind.UNION_TYPE) {
for (JCCatch catchStmt : tree.getCatches()) { printStat(catchStmt);
if (tryStatement.getCatches().size() != 1) { JCCatch catchTree = Iterables.getOnlyElement(tryStatement.getCatches()); if (catchTree.getParameter().getType().getKind() == Kind.UNION_TYPE) {
localPointer = diffTree(oldT.body, newT.body, bodyPos); copyTo(localPointer, localPointer = bodyPos[1]); PositionEstimator est = EstimatorFactory.catches(oldT.getCatches(), newT.getCatches(), oldT.finalizer != null, diffContext); localPointer = diffList(oldT.catchers, newT.catchers, localPointer, est, Measure.DEFAULT, printer);
for (JCCatch catchStmt : tree.getCatches()) { printStat(catchStmt);
private static void analyzeTry(SourceContext context, JCTree.JCTry tryExpr) throws IOException { JCTree.JCBlock block = tryExpr.getBlock(); List<JCTree> resources = tryExpr.getResources(); List<JCTree.JCCatch> catches = tryExpr.getCatches(); JCTree.JCBlock lyBlock = tryExpr.getFinallyBlock(); if (nonNull(resources)) { for (JCTree resource : resources) { analyzeParsedTree(context, resource); } } analyzeParsedTree(context, block); if (nonNull(catches)) { for (JCTree.JCCatch jcCatch : catches) { JCTree.JCVariableDecl parameter = jcCatch.getParameter(); analyzeParsedTree(context, parameter); JCTree.JCBlock catchBlock = jcCatch.getBlock(); analyzeParsedTree(context, catchBlock); } } analyzeParsedTree(context, lyBlock); }
@Override public void visitTry(JCTry node) { Try t = new Try(); t.rawBody(toTree(node.getBlock())); t.rawFinally(toTree(node.getFinallyBlock())); fillList(node.getCatches(), t.rawCatches()); set(node, t); }
@Override public void visitTry(JCTry node) { Try t = new Try(); t.rawBody(toTree(node.getBlock())); t.rawFinally(toTree(node.getFinallyBlock())); fillList(node.getCatches(), t.rawCatches()); set(node, t); }
@Override public void visitTry(JCTry node) { Try t = new Try(); t.rawBody(toTree(node.getBlock())); t.rawFinally(toTree(node.getFinallyBlock())); fillList(node.getCatches(), t.rawCatches()); set(node, t); }
private static Optional<JCCatch> catchesType( JCTry tryStatement, Type assertionErrorType, VisitorState state) { return tryStatement.getCatches().stream() .filter( catchTree -> { Type type = ASTHelpers.getType(catchTree.getParameter()); return (type.isUnion() ? Streams.stream(((UnionClassType) type).getAlternativeTypes()) : Stream.of(type)) .anyMatch(caught -> isSubtype(assertionErrorType, caught, state)); }) .findFirst(); }
collectExecutionPaths(tryNode.getBlock(), allExecutionPaths, currentPaths, activeBreaks); JCStatement[] catchForks = (JCStatement[]) tryNode.getCatches().stream().map(catchExp -> catchExp.body) .collect(toList()).toArray(new JCStatement[0]);