private AnnotationTree modifyAnnotationAttrValue(AnnotationTree annotation, int index, ExpressionTree attrValue, Operation op) { AnnotationTree copy = annotation.getKind() == Kind.ANNOTATION ? Annotation(annotation.getAnnotationType(), c(annotation.getArguments(), index, attrValue, op)) : TypeAnnotation(annotation.getAnnotationType(), c(annotation.getArguments(), index, attrValue, op)); return copy; }
protected final AnnotationTree rewriteChildren(AnnotationTree tree) { Tree annotationType = translate(tree.getAnnotationType()); List<? extends ExpressionTree> args = translate(tree.getArguments()); if (annotationType!=tree.getAnnotationType() || !args.equals(tree.getArguments())) { if (args != tree.getArguments()) args = optimize(args); AnnotationTree n = tree.getKind() == Kind.ANNOTATION ? make.Annotation(annotationType, args) : make.TypeAnnotation(annotationType, args); model.setType(n, model.getType(tree)); copyCommentTo(tree,n); tree = n; if (tree.getArguments().size() != args.size()) model.setPos(tree, NOPOS); else copyPosTo(tree,n); } return tree; }
@Override public Tree visitAnnotation(AnnotationTree tree, Void p) { AnnotationTree n = tree.getKind() == Tree.Kind.ANNOTATION ? make.Annotation(tree.getAnnotationType(), tree.getArguments()) : make.TypeAnnotation(tree.getAnnotationType(), tree.getArguments()); model.setType(n, model.getType(tree)); comments.copyComments(tree, n); model.setPos(n, model.getPos(tree)); return n; }