use of com.github.javaparser.ast.CompilationUnit in project javaparser by javaparser.
the class VisitorMapTest method visitorMapContainsKey.
@Test
public void visitorMapContainsKey() {
CompilationUnit x1 = JavaParser.parse("class X{}");
Map<CompilationUnit, Integer> map = new VisitorMap<>(new ObjectIdentityHashCodeVisitor(), new ObjectIdentityEqualsVisitor());
map.put(x1, 1);
assertTrue(map.containsKey(x1));
}
use of com.github.javaparser.ast.CompilationUnit in project javaparser by javaparser.
the class VisitorMapTest method normalEqualsDoesDeepCompare.
@Test
public void normalEqualsDoesDeepCompare() {
CompilationUnit x1 = JavaParser.parse("class X{}");
CompilationUnit x2 = JavaParser.parse("class X{}");
Map<CompilationUnit, Integer> map = new HashMap<>();
map.put(x1, 1);
map.put(x2, 2);
assertEquals(1, map.size());
}
use of com.github.javaparser.ast.CompilationUnit in project javaparser by javaparser.
the class VisitorMapTest method visitorMapPutAll.
@Test
public void visitorMapPutAll() {
CompilationUnit x1 = JavaParser.parse("class X{}");
CompilationUnit x2 = JavaParser.parse("class Y{}");
Map<CompilationUnit, Integer> map = new HashMap<>();
map.put(x1, 1);
map.put(x2, 2);
Map<CompilationUnit, Integer> visitorMap = new VisitorMap<>(new ObjectIdentityHashCodeVisitor(), new ObjectIdentityEqualsVisitor());
visitorMap.putAll(map);
assertEquals(2, visitorMap.size());
}
use of com.github.javaparser.ast.CompilationUnit in project javaparser by javaparser.
the class VisitorMapTest method visitorMapGet.
@Test
public void visitorMapGet() {
CompilationUnit x1 = JavaParser.parse("class X{}");
Map<CompilationUnit, Integer> map = new VisitorMap<>(new ObjectIdentityHashCodeVisitor(), new ObjectIdentityEqualsVisitor());
map.put(x1, 1);
assertEquals(1, (int) map.get(x1));
}
use of com.github.javaparser.ast.CompilationUnit in project javaparser by javaparser.
the class MethodChanger_1 method main.
public static void main(String[] args) throws Exception {
// parse a file
CompilationUnit cu = JavaParser.parse(new File("test.java"));
// visit and change the methods names and parameters
cu.accept(new MethodChangerVisitor(), null);
// prints the changed compilation unit
System.out.println(cu);
}
Aggregations