use of com.github.javaparser.ast.CompilationUnit in project javaparser by javaparser.
the class MethodChanger_2 method main.
public static void main(String[] args) throws Exception {
// creates an input stream for the file to be parsed
FileInputStream in = new FileInputStream("test.java");
// parse the file
CompilationUnit cu = JavaParser.parse(in);
// change the methods names and parameters
changeMethods(cu);
// prints the changed compilation unit
System.out.println(cu.toString());
}
use of com.github.javaparser.ast.CompilationUnit in project javaparser by javaparser.
the class MyVisitor method main.
public static void main(String... args) throws Exception {
// parse the file
CompilationUnit cu = JavaParser.parse(new FileInputStream("forGitHubTest.java"));
// The visitor should remove all a=20 variable declarations.
cu.accept(new MyVisitor(), null);
System.out.println(cu.toString());
}
use of com.github.javaparser.ast.CompilationUnit in project javaparser by javaparser.
the class VisitorListTest method visitorListIterator.
@Test
public void visitorListIterator() {
VisitorList<CompilationUnit> list = new VisitorList<>(new ObjectIdentityHashCodeVisitor(), new ObjectIdentityEqualsVisitor());
CompilationUnit x1 = JavaParser.parse("class X{}");
list.add(x1);
CompilationUnit x2 = JavaParser.parse("class X{}");
list.add(x2);
Iterator<CompilationUnit> itr = list.iterator();
assertEquals(x1, itr.next());
itr.remove();
assertTrue(list.size() == 1);
assertEquals(x2, itr.next());
itr.remove();
assertTrue(list.size() == 0);
}
use of com.github.javaparser.ast.CompilationUnit in project javaparser by javaparser.
the class VisitorListTest method visitorListRemove.
@Test
public void visitorListRemove() {
CompilationUnit x1 = JavaParser.parse("class X{}");
VisitorList<CompilationUnit> list = new VisitorList<>(new ObjectIdentityHashCodeVisitor(), new ObjectIdentityEqualsVisitor());
list.add(x1);
assertTrue(list.remove(x1));
}
use of com.github.javaparser.ast.CompilationUnit in project javaparser by javaparser.
the class VisitorListTest method visitorListContains.
@Test
public void visitorListContains() {
CompilationUnit x1 = JavaParser.parse("class X{}");
VisitorList<CompilationUnit> list = new VisitorList<>(new ObjectIdentityHashCodeVisitor(), new ObjectIdentityEqualsVisitor());
list.add(x1);
assertTrue(list.contains(x1));
}
Aggregations