use of com.github.javaparser.ast.body.AnnotationDeclaration in project javaparser by javaparser.
the class CloneVisitor method visit.
@Override
public Node visit(AnnotationDeclaration _n, Object _arg) {
JavadocComment javaDoc = cloneNodes(_n.getJavaDoc(), _arg);
List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg);
List<BodyDeclaration> members = visit(_n.getMembers(), _arg);
Comment comment = cloneNodes(_n.getComment(), _arg);
AnnotationDeclaration r = new AnnotationDeclaration(_n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), _n.getModifiers(), annotations, _n.getName(), members);
r.setComment(comment);
return r;
}
use of com.github.javaparser.ast.body.AnnotationDeclaration in project javaparser by javaparser.
the class LexicalDifferenceCalculatorTest method annotationDeclarationModifiersExampleModified.
@Test
public void annotationDeclarationModifiersExampleModified() throws IOException {
considerExample("AnnotationDeclaration_Example1_original");
AnnotationDeclaration annotationDeclaration = (AnnotationDeclaration) cu.getType(0);
CsmElement element = ConcreteSyntaxModel.forClass(annotationDeclaration.getClass());
LexicalDifferenceCalculator.CalculatedSyntaxModel csm = new LexicalDifferenceCalculator().calculatedSyntaxModelAfterPropertyChange(element, annotationDeclaration, ObservableProperty.MODIFIERS, EnumSet.noneOf(Modifier.class), EnumSet.of(Modifier.PUBLIC));
csm.removeIndentationElements();
int i = 0;
assertEquals(new CsmToken(GeneratedJavaParserConstants.PUBLIC), csm.elements.get(i++));
assertEquals(new CsmToken(spaceTokenKind()), csm.elements.get(i++));
assertEquals(new CsmToken(GeneratedJavaParserConstants.AT), csm.elements.get(i++));
assertEquals(new CsmToken(GeneratedJavaParserConstants.INTERFACE), csm.elements.get(i++));
assertEquals(new CsmToken(spaceTokenKind()), csm.elements.get(i++));
assertEquals(new LexicalDifferenceCalculator.CsmChild(annotationDeclaration.getName()), csm.elements.get(i++));
assertEquals(new CsmToken(spaceTokenKind()), csm.elements.get(i++));
assertEquals(new CsmToken(GeneratedJavaParserConstants.LBRACE), csm.elements.get(i++));
assertEquals(new CsmToken(eolTokenKind()), csm.elements.get(i++));
assertEquals(new LexicalDifferenceCalculator.CsmChild(annotationDeclaration.getMember(0)), csm.elements.get(i++));
assertEquals(new CsmToken(eolTokenKind()), csm.elements.get(i++));
assertEquals(new LexicalDifferenceCalculator.CsmChild(annotationDeclaration.getMember(1)), csm.elements.get(i++));
assertEquals(new CsmToken(eolTokenKind()), csm.elements.get(i++));
assertEquals(new LexicalDifferenceCalculator.CsmChild(annotationDeclaration.getMember(2)), csm.elements.get(i++));
assertEquals(new CsmToken(eolTokenKind()), csm.elements.get(i++));
assertEquals(new LexicalDifferenceCalculator.CsmChild(annotationDeclaration.getMember(3)), csm.elements.get(i++));
assertEquals(new CsmToken(eolTokenKind()), csm.elements.get(i++));
assertEquals(new LexicalDifferenceCalculator.CsmChild(annotationDeclaration.getMember(4)), csm.elements.get(i++));
assertEquals(new CsmToken(eolTokenKind()), csm.elements.get(i++));
assertEquals(new LexicalDifferenceCalculator.CsmChild(annotationDeclaration.getMember(5)), csm.elements.get(i++));
assertEquals(new CsmToken(eolTokenKind()), csm.elements.get(i++));
assertEquals(new CsmToken(GeneratedJavaParserConstants.RBRACE), csm.elements.get(i++));
assertEquals(i, csm.elements.size());
}
use of com.github.javaparser.ast.body.AnnotationDeclaration in project javaparser by javaparser.
the class LexicalDifferenceCalculatorTest method annotationDeclaratioJavadocExampleOriginal.
@Test
public void annotationDeclaratioJavadocExampleOriginal() throws IOException {
considerExample("AnnotationDeclaration_Example3_original");
AnnotationDeclaration annotationDeclaration = (AnnotationDeclaration) cu.getType(0);
CsmElement element = ConcreteSyntaxModel.forClass(annotationDeclaration.getClass());
LexicalDifferenceCalculator.CalculatedSyntaxModel csm = new LexicalDifferenceCalculator().calculatedSyntaxModelForNode(element, annotationDeclaration);
csm.removeIndentationElements();
int i = 0;
assertEquals(new CsmToken(GeneratedJavaParserConstants.PUBLIC), csm.elements.get(i++));
assertEquals(new CsmToken(spaceTokenKind()), csm.elements.get(i++));
assertEquals(new CsmToken(GeneratedJavaParserConstants.AT), csm.elements.get(i++));
assertEquals(new CsmToken(GeneratedJavaParserConstants.INTERFACE), csm.elements.get(i++));
assertEquals(new CsmToken(spaceTokenKind()), csm.elements.get(i++));
assertEquals(new LexicalDifferenceCalculator.CsmChild(annotationDeclaration.getName()), csm.elements.get(i++));
assertEquals(new CsmToken(spaceTokenKind()), csm.elements.get(i++));
assertEquals(new CsmToken(GeneratedJavaParserConstants.LBRACE), csm.elements.get(i++));
assertEquals(new CsmToken(eolTokenKind()), csm.elements.get(i++));
assertEquals(new LexicalDifferenceCalculator.CsmChild(annotationDeclaration.getMember(0)), csm.elements.get(i++));
assertEquals(new CsmToken(eolTokenKind()), csm.elements.get(i++));
assertEquals(new LexicalDifferenceCalculator.CsmChild(annotationDeclaration.getMember(1)), csm.elements.get(i++));
assertEquals(new CsmToken(eolTokenKind()), csm.elements.get(i++));
assertEquals(new LexicalDifferenceCalculator.CsmChild(annotationDeclaration.getMember(2)), csm.elements.get(i++));
assertEquals(new CsmToken(eolTokenKind()), csm.elements.get(i++));
assertEquals(new LexicalDifferenceCalculator.CsmChild(annotationDeclaration.getMember(3)), csm.elements.get(i++));
assertEquals(new CsmToken(eolTokenKind()), csm.elements.get(i++));
assertEquals(new LexicalDifferenceCalculator.CsmChild(annotationDeclaration.getMember(4)), csm.elements.get(i++));
assertEquals(new CsmToken(eolTokenKind()), csm.elements.get(i++));
assertEquals(new LexicalDifferenceCalculator.CsmChild(annotationDeclaration.getMember(5)), csm.elements.get(i++));
assertEquals(new CsmToken(eolTokenKind()), csm.elements.get(i++));
assertEquals(new CsmToken(GeneratedJavaParserConstants.RBRACE), csm.elements.get(i++));
assertEquals(i, csm.elements.size());
}
use of com.github.javaparser.ast.body.AnnotationDeclaration in project javaparser by javaparser.
the class LexicalDifferenceCalculatorTest method annotationDeclarationModifiersExampleOriginal.
@Test
public void annotationDeclarationModifiersExampleOriginal() throws IOException {
considerExample("AnnotationDeclaration_Example1_original");
AnnotationDeclaration annotationDeclaration = (AnnotationDeclaration) cu.getType(0);
CsmElement element = ConcreteSyntaxModel.forClass(annotationDeclaration.getClass());
LexicalDifferenceCalculator.CalculatedSyntaxModel csm = new LexicalDifferenceCalculator().calculatedSyntaxModelForNode(element, annotationDeclaration);
csm.removeIndentationElements();
int i = 0;
assertEquals(new CsmToken(GeneratedJavaParserConstants.AT), csm.elements.get(i++));
assertEquals(new CsmToken(GeneratedJavaParserConstants.INTERFACE), csm.elements.get(i++));
assertEquals(new CsmToken(spaceTokenKind()), csm.elements.get(i++));
assertEquals(new LexicalDifferenceCalculator.CsmChild(annotationDeclaration.getName()), csm.elements.get(i++));
assertEquals(new CsmToken(spaceTokenKind()), csm.elements.get(i++));
assertEquals(new CsmToken(GeneratedJavaParserConstants.LBRACE), csm.elements.get(i++));
assertEquals(new CsmToken(eolTokenKind()), csm.elements.get(i++));
assertEquals(new LexicalDifferenceCalculator.CsmChild(annotationDeclaration.getMember(0)), csm.elements.get(i++));
assertEquals(new CsmToken(eolTokenKind()), csm.elements.get(i++));
assertEquals(new LexicalDifferenceCalculator.CsmChild(annotationDeclaration.getMember(1)), csm.elements.get(i++));
assertEquals(new CsmToken(eolTokenKind()), csm.elements.get(i++));
assertEquals(new LexicalDifferenceCalculator.CsmChild(annotationDeclaration.getMember(2)), csm.elements.get(i++));
assertEquals(new CsmToken(eolTokenKind()), csm.elements.get(i++));
assertEquals(new LexicalDifferenceCalculator.CsmChild(annotationDeclaration.getMember(3)), csm.elements.get(i++));
assertEquals(new CsmToken(eolTokenKind()), csm.elements.get(i++));
assertEquals(new LexicalDifferenceCalculator.CsmChild(annotationDeclaration.getMember(4)), csm.elements.get(i++));
assertEquals(new CsmToken(eolTokenKind()), csm.elements.get(i++));
assertEquals(new LexicalDifferenceCalculator.CsmChild(annotationDeclaration.getMember(5)), csm.elements.get(i++));
assertEquals(new CsmToken(eolTokenKind()), csm.elements.get(i++));
assertEquals(new CsmToken(GeneratedJavaParserConstants.RBRACE), csm.elements.get(i++));
assertEquals(i, csm.elements.size());
}
use of com.github.javaparser.ast.body.AnnotationDeclaration in project javaparser by javaparser.
the class CompilationUnitBuildersTest method testAddAnnotationDeclaration.
@Test
public void testAddAnnotationDeclaration() {
AnnotationDeclaration myAnnotationDeclaration = cu.addAnnotationDeclaration("test");
assertEquals(1, cu.getTypes().size());
assertEquals("test", cu.getType(0).getNameAsString());
assertTrue(myAnnotationDeclaration.isPublic());
assertEquals(AnnotationDeclaration.class, cu.getType(0).getClass());
}
Aggregations