use of com.github.javaparser.ast.CompilationUnit in project javaparser by javaparser.
the class VisitorListTest method visitorListRetainAll.
@Test
public void visitorListRetainAll() {
List<CompilationUnit> list = new ArrayList<>();
list.add(JavaParser.parse("class X{}"));
list.add(JavaParser.parse("class X{}"));
VisitorList<CompilationUnit> vList = new VisitorList<>(new ObjectIdentityHashCodeVisitor(), new ObjectIdentityEqualsVisitor());
vList.addAll(list);
vList.add(JavaParser.parse("class X{}"));
vList.retainAll(list);
assertTrue(vList.size() == 2);
}
use of com.github.javaparser.ast.CompilationUnit in project javaparser by javaparser.
the class VisitorSetTest method visitorSetRemove.
@Test
public void visitorSetRemove() {
CompilationUnit x1 = JavaParser.parse("class X{}");
Set<CompilationUnit> set = new VisitorSet<>(new ObjectIdentityHashCodeVisitor(), new ObjectIdentityEqualsVisitor());
set.add(x1);
assertTrue(set.remove(x1));
}
use of com.github.javaparser.ast.CompilationUnit in project javaparser by javaparser.
the class VisitorSetTest method visitorSetContains.
@Test
public void visitorSetContains() {
CompilationUnit x1 = JavaParser.parse("class X{}");
Set<CompilationUnit> set = new VisitorSet<>(new ObjectIdentityHashCodeVisitor(), new ObjectIdentityEqualsVisitor());
set.add(x1);
assertTrue(set.contains(x1));
}
use of com.github.javaparser.ast.CompilationUnit in project javaparser by javaparser.
the class CommentsInserterTest method issue234LosingCommentsInArrayInitializerExpr.
@Test
public void issue234LosingCommentsInArrayInitializerExpr() {
CompilationUnit cu = parse("@Anno(stuff={" + EOL + " // Just," + EOL + " // an," + EOL + " // example" + EOL + "})" + EOL + "class ABC {" + EOL + "" + EOL + "}");
assertEqualsNoEol("@Anno(stuff = {// Just,\n" + "// an,\n" + "// example\n" + "})\n" + "class ABC {\n" + "}\n", cu.toString());
}
use of com.github.javaparser.ast.CompilationUnit in project javaparser by javaparser.
the class CommentsInserterTest method issue200EnumConstantsWithCommentsForceVerticalAlignment.
@Test
public void issue200EnumConstantsWithCommentsForceVerticalAlignment() {
CompilationUnit cu = parse("public enum X {" + EOL + " /** const1 javadoc */" + EOL + " BORDER_CONSTANT," + EOL + " /** const2 javadoc */" + EOL + " ANOTHER_CONSTANT" + EOL + "}");
assertEqualsNoEol("public enum X {\n" + "\n" + " /**\n" + " * const1 javadoc\n" + " */\n" + " BORDER_CONSTANT,\n" + " /**\n" + " * const2 javadoc\n" + " */\n" + " ANOTHER_CONSTANT\n" + "}\n", cu.toString());
}
Aggregations