private static void addFix( SuggestedFix.Builder fix, JCExpression expr, AssertTree foundAssert, VisitorState state, String isMethod) { String assertToUse; if (foundAssert.getDetail() == null) { fix.addImport(STATIC_ASSERT_THAT_IMPORT); assertToUse = String.format(ASSERT_THAT, normalizedSourceForExpression(expr, state)); } else { fix.addImport(STATIC_ASSERT_WITH_MESSAGE_IMPORT); assertToUse = String.format( ASSERT_WITH_MESSAGE, convertToString(foundAssert.getDetail(), state), normalizedSourceForExpression(expr, state)); } fix.replace(foundAssert, assertToUse + isMethod); }
@Override public Choice<Unifier> visitAssert(AssertTree node, Unifier unifier) { return getCondition() .unify(node.getCondition(), unifier) .thenChoose(unifications(getDetail(), node.getDetail())); }
@Override public String visitAssert(AssertTree node, Void v) { StringBuilder out = new StringBuilder(); ExpressionTree condition = node.getCondition(); ExpressionTree detail = node.getDetail(); out.append("assert "); out.append(condition.accept(this, v)); if (detail != null) { out.append(" : "); out.append(detail.accept(this, v)); } return out.toString(); }
@Override public Void visitAssert(AssertTree expected, Tree actual) { Optional<AssertTree> other = checkTypeAndCast(expected, actual); if (!other.isPresent()) { addTypeMismatch(expected, actual); return null; } scan(expected.getCondition(), other.get().getCondition()); scan(expected.getDetail(), other.get().getDetail()); return null; }
@Override public Void visitAssert(AssertTree expected, Tree actual) { Optional<AssertTree> other = checkTypeAndCast(expected, actual); if (!other.isPresent()) { addTypeMismatch(expected, actual); return null; } scan(expected.getCondition(), other.get().getCondition()); scan(expected.getDetail(), other.get().getDetail()); return null; }
@Override public String visitAssert( AssertTree node, Object v ) { StringBuilder out = new StringBuilder(); appendComment( node, out ); ExpressionTree condition = node.getCondition(); ExpressionTree detail = node.getDetail(); out.append( "assert " ); out.append( condition.accept( this, v ) ); if( detail != null ) { out.append( " : " ); out.append( detail.accept( this, v ) ); } return out.toString(); }
@Override public Void visitAssert(AssertTree expected, Tree actual) { Optional<AssertTree> other = checkTypeAndCast(expected, actual); if (!other.isPresent()) { addTypeMismatch(expected, actual); return null; } scan(expected.getCondition(), other.get().getCondition()); scan(expected.getDetail(), other.get().getDetail()); return null; }
public R visitAssert(AssertTree node, P p) { R r = scan(node.getCondition(), p); r = scanAndReduce(node.getDetail(), p, r); return r; }
@Override public Void visitAssert(AssertTree tree, EnumSet<UseTypes> p) { if (tree.getCondition().getKind() == Kind.IDENTIFIER) handlePossibleIdentifier(new TreePath(getCurrentPath(), tree.getCondition()), EnumSet.of(UseTypes.READ)); if (tree.getDetail() != null && tree.getDetail().getKind() == Kind.IDENTIFIER) handlePossibleIdentifier(new TreePath(getCurrentPath(), tree.getDetail()), EnumSet.of(UseTypes.READ)); return super.visitAssert(tree, EnumSet.of(UseTypes.READ)); }
public R visitAssert(AssertTree node, P p) { R r = scan(node.getCondition(), p); r = scanAndReduce(node.getDetail(), p, r); return r; }
public R visitAssert(AssertTree node, P p) { R r = scan(node.getCondition(), p); r = scanAndReduce(node.getDetail(), p, r); return r; }
public R visitAssert(AssertTree node, P p) { R r = scan(node.getCondition(), p); r = scanAndReduce(node.getDetail(), p, r); return r; }
public List<Tree> visitAssert(AssertTree node, ExpressionScanner.ExpressionsInfo p) { List<Tree> result = scan(node.getCondition(), p); result = reduce(result, scan(node.getDetail(), p)); return result; }
protected final AssertTree rewriteChildren(AssertTree tree) { ExpressionTree cond = (ExpressionTree)translate(tree.getCondition()); ExpressionTree detail = (ExpressionTree)translate(tree.getDetail()); if (cond!=tree.getCondition() || detail!=tree.getDetail()) { AssertTree n = make.Assert(cond, detail); model.setType(n, model.getType(tree)); copyCommentTo(tree,n); copyPosTo(tree,n); tree = n; } return tree; }
@Override public List<Tree> visitAssert(AssertTree node, ExpressionScanner.ExpressionsInfo p) { if (acceptsTree(node)) { List<Tree> result = scan(node.getCondition(), p); result = reduce(result, scan(node.getDetail(), p)); return result; } else { return null; } }
@Override public Choice<Unifier> visitAssert(AssertTree node, Unifier unifier) { return getCondition() .unify(node.getCondition(), unifier) .thenChoose(unifications(getDetail(), node.getDetail())); }
@Override public Tree visitAssert(AssertTree tree, Void p) { AssertTree n = make.Assert(tree.getCondition(), tree.getDetail()); model.setType(n, model.getType(tree)); comments.copyComments(tree, n); model.setPos(n, model.getPos(tree)); return n; }