use of com.github.javaparser.ast.body.MethodDeclaration in project javaparser by javaparser.
the class DifferentiateDotExpressionTest method staticMethodCallsFromInnerClasses.
@Test
public void staticMethodCallsFromInnerClasses() {
ClassOrInterfaceDeclaration clazz = ((JavaParserClassDeclaration) typeSolver.solveType("InnerClassDotExpressions")).getWrappedNode();
MethodDeclaration mainMethod = Navigator.demandMethod(clazz, "main");
JavaParserFacade javaParserFacade = JavaParserFacade.get(typeSolver);
MethodCallExpr methodCall = Navigator.findMethodCall(mainMethod, "methodCall").get();
MethodCallExpr innerMethodCall = Navigator.findMethodCall(mainMethod, "innerMethodCall").get();
MethodCallExpr innerInnerMethodCall = Navigator.findMethodCall(mainMethod, "innerInnerMethodCall").get();
assertEquals(true, javaParserFacade.solve(methodCall).isSolved());
assertEquals(true, javaParserFacade.solve(innerMethodCall).isSolved());
assertEquals(true, javaParserFacade.solve(innerInnerMethodCall).isSolved());
}
use of com.github.javaparser.ast.body.MethodDeclaration in project javaparser by javaparser.
the class DifferentiateDotExpressionTest method staticFieldCallsFromInnerClasses.
@Test
public void staticFieldCallsFromInnerClasses() {
ClassOrInterfaceDeclaration clazz = ((JavaParserClassDeclaration) typeSolver.solveType("InnerStaticClassFieldDotExpressions")).getWrappedNode();
MethodDeclaration mainMethod = Navigator.demandMethod(clazz, "main");
JavaParserFacade javaParserFacade = JavaParserFacade.get(typeSolver);
MethodCallExpr methodCallWithNestedStaticFieldParam = Navigator.findMethodCall(mainMethod, "parseInt").get();
assertEquals(true, javaParserFacade.solve(methodCallWithNestedStaticFieldParam).isSolved());
}
use of com.github.javaparser.ast.body.MethodDeclaration 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.MethodDeclaration in project javaparser by javaparser.
the class MethodDeclarationTransformationsTest method removingModifiers.
@Test
public void removingModifiers() throws IOException {
MethodDeclaration it = consider("public void A(){}");
it.setModifiers(EnumSet.noneOf(Modifier.class));
assertTransformedToString("void A(){}", it);
}
use of com.github.javaparser.ast.body.MethodDeclaration in project javaparser by javaparser.
the class MethodDeclarationTransformationsTest method addingModifiers.
// JavaDoc
// Modifiers
@Test
public void addingModifiers() throws IOException {
MethodDeclaration it = consider("void A(){}");
it.setModifiers(EnumSet.of(Modifier.PUBLIC));
assertTransformedToString("public void A(){}", it);
}
Aggregations