use of com.github.javaparser.ast.body.ClassOrInterfaceDeclaration in project javaparser by javaparser.
the class JavaParserAnonymousClassDeclarationTest method callingSuperClassInnerClassMethod.
@Test
public void callingSuperClassInnerClassMethod() {
CompilationUnit cu = parseSample("AnonymousClassDeclarations");
ClassOrInterfaceDeclaration aClass = Navigator.demandClass(cu, "AnonymousClassDeclarations");
MethodDeclaration method = Navigator.demandMethod(aClass, "fooBar2");
MethodCallExpr methodCall = Navigator.findMethodCall(method, "innerClassMethod").get();
CombinedTypeSolver combinedTypeSolver = new CombinedTypeSolver();
combinedTypeSolver.add(new ReflectionTypeSolver());
MethodUsage methodUsage = JavaParserFacade.get(combinedTypeSolver).solveMethodAsUsage(methodCall);
assertThat(methodUsage.getQualifiedSignature(), is("AnonymousClassDeclarations.DoFn.ProcessContext.innerClassMethod()"));
}
use of com.github.javaparser.ast.body.ClassOrInterfaceDeclaration in project javaparser by javaparser.
the class ClassOrInterfaceDeclarationTransformationsTest method replacingFieldWithAnotherField.
@Test
public void replacingFieldWithAnotherField() throws IOException {
ClassOrInterfaceDeclaration cid = consider("public class A {float f;}");
cid.getMembers().set(0, new FieldDeclaration(EnumSet.noneOf(Modifier.class), new VariableDeclarator(PrimitiveType.intType(), "bar")));
assertTransformedToString("public class A {int bar;}", cid);
}
use of com.github.javaparser.ast.body.ClassOrInterfaceDeclaration in project javaparser by javaparser.
the class ClassOrInterfaceDeclarationTransformationsTest method replacingImplementedTypes.
@Test
public void replacingImplementedTypes() throws IOException {
ClassOrInterfaceDeclaration cid = consider("public class A implements Foo {}");
cid.getImplementedTypes().set(0, parseClassOrInterfaceType("Bar"));
assertTransformedToString("public class A implements Bar {}", cid);
}
use of com.github.javaparser.ast.body.ClassOrInterfaceDeclaration in project javaparser by javaparser.
the class ClassOrInterfaceDeclarationTransformationsTest method removingModifiers.
@Test
public void removingModifiers() throws IOException {
ClassOrInterfaceDeclaration cid = consider("public class A {}");
cid.setModifiers(EnumSet.noneOf(Modifier.class));
assertTransformedToString("class A {}", cid);
}
use of com.github.javaparser.ast.body.ClassOrInterfaceDeclaration in project javaparser by javaparser.
the class ClassOrInterfaceDeclarationTransformationsTest method removingImplementedTypes.
@Test
public void removingImplementedTypes() throws IOException {
ClassOrInterfaceDeclaration cid = consider("public class A implements Foo {}");
cid.getImplementedTypes().remove(0);
assertTransformedToString("public class A {}", cid);
}
Aggregations