use of com.github.javaparser.ast.body.AnnotationMemberDeclaration in project javaparser by javaparser.
the class JavaParserTest method rangeOfAnnotationMemberDeclarationIsCorrect.
@Test
public void rangeOfAnnotationMemberDeclarationIsCorrect() {
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, 29)), memberDeclaration.getRange().get());
}
use of com.github.javaparser.ast.body.AnnotationMemberDeclaration in project javaparser by javaparser.
the class AnnotationMemberDeclarationTransformationsTest method replacingAnnotation.
@Test
public void replacingAnnotation() {
AnnotationMemberDeclaration it = consider("@myAnno int foo();");
it.getAnnotations().set(0, new NormalAnnotationExpr(new Name("myOtherAnno"), new NodeList<>()));
assertTransformedToString("@myOtherAnno() int foo();", it);
}
use of com.github.javaparser.ast.body.AnnotationMemberDeclaration in project javaparser by javaparser.
the class AnnotationMemberDeclarationTransformationsTest method addingModifiers.
// Modifiers
@Test
public void addingModifiers() {
AnnotationMemberDeclaration md = consider("int foo();");
md.setModifiers(EnumSet.of(Modifier.PUBLIC));
assertTransformedToString("public int foo();", md);
}
use of com.github.javaparser.ast.body.AnnotationMemberDeclaration in project javaparser by javaparser.
the class AnnotationMemberDeclarationTransformationsTest method changingType.
// Type
@Test
public void changingType() {
AnnotationMemberDeclaration md = consider("int foo();");
md.setType("String");
assertTransformedToString("String foo();", md);
}
use of com.github.javaparser.ast.body.AnnotationMemberDeclaration in project javaparser by javaparser.
the class AnnotationMemberDeclarationTransformationsTest method removingAnnotationOnPrevLine.
@Test
public void removingAnnotationOnPrevLine() {
AnnotationMemberDeclaration it = consider("@myAnno" + EOL + "int foo();");
it.getAnnotations().remove(0);
assertTransformedToString("int foo();", it);
}
Aggregations