use of com.github.javaparser.ast.body.AnnotationMemberDeclaration in project javaparser by javaparser.
the class AnnotationMemberDeclarationTransformationsTest method replacingModifiers.
@Test
public void replacingModifiers() {
AnnotationMemberDeclaration md = consider("public int foo();");
md.setModifiers(EnumSet.of(Modifier.PROTECTED));
assertTransformedToString("protected int foo();", md);
}
use of com.github.javaparser.ast.body.AnnotationMemberDeclaration in project javaparser by javaparser.
the class AnnotationMemberDeclarationTransformationsTest method addingTwoAnnotations.
@Test
public void addingTwoAnnotations() {
AnnotationMemberDeclaration it = consider("int foo();");
it.addAnnotation("myAnno");
it.addAnnotation("myAnno2");
assertTransformedToString("@myAnno()" + EOL + "@myAnno2()" + EOL + "int foo();", it);
}
use of com.github.javaparser.ast.body.AnnotationMemberDeclaration in project javaparser by javaparser.
the class CloneVisitor method visit.
@Override
public Node visit(AnnotationMemberDeclaration _n, Object _arg) {
JavadocComment javaDoc = cloneNodes(_n.getJavaDoc(), _arg);
List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg);
Type type_ = cloneNodes(_n.getType(), _arg);
Expression defaultValue = cloneNodes(_n.getDefaultValue(), _arg);
Comment comment = cloneNodes(_n.getComment(), _arg);
AnnotationMemberDeclaration r = new AnnotationMemberDeclaration(_n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), _n.getModifiers(), annotations, type_, _n.getName(), defaultValue);
r.setComment(comment);
return r;
}
use of com.github.javaparser.ast.body.AnnotationMemberDeclaration in project javaparser by javaparser.
the class JavaParserTest method rangeOfAnnotationMemberDeclarationWithArrayTypeIsCorrect.
@Test
public void rangeOfAnnotationMemberDeclarationWithArrayTypeIsCorrect() {
String code = "@interface AD { String[] foo(); }";
CompilationUnit cu = JavaParser.parse(code);
AnnotationMemberDeclaration memberDeclaration = cu.getAnnotationDeclarationByName("AD").get().getMember(0).asAnnotationMemberDeclaration();
assertEquals(true, memberDeclaration.getRange().isPresent());
assertEquals(new Range(new Position(1, 17), new Position(1, 31)), memberDeclaration.getRange().get());
}
use of com.github.javaparser.ast.body.AnnotationMemberDeclaration in project javaparser by javaparser.
the class AnnotationMemberDeclarationTransformationsTest method changingName.
// Name
@Test
public void changingName() {
AnnotationMemberDeclaration md = consider("int foo();");
md.setName("bar");
assertTransformedToString("int bar();", md);
}
Aggregations