use of com.github.javaparser.ast.expr.MethodCallExpr in project javaparser by javaparser.
the class DifferentiateDotExpressionTest method methodCallsFromFieldObjects.
@Test
public void methodCallsFromFieldObjects() {
ClassOrInterfaceDeclaration clazz = ((JavaParserClassDeclaration) typeSolver.solveType("FieldDotExpressions")).getWrappedNode();
MethodDeclaration mainMethod = Navigator.demandMethod(clazz, "main");
JavaParserFacade javaParserFacade = JavaParserFacade.get(typeSolver);
MethodCallExpr firstFieldMethodCall = Navigator.findMethodCall(mainMethod, "firstContainerMethod").get();
MethodCallExpr secondFieldMethodCall = Navigator.findMethodCall(mainMethod, "secondContainerMethod").get();
MethodCallExpr thirdFieldMethodCall = Navigator.findMethodCall(mainMethod, "thirdContainerMethod").get();
assertEquals(true, javaParserFacade.solve(firstFieldMethodCall).isSolved());
assertEquals(true, javaParserFacade.solve(secondFieldMethodCall).isSolved());
assertEquals(true, javaParserFacade.solve(thirdFieldMethodCall).isSolved());
}
use of com.github.javaparser.ast.expr.MethodCallExpr in project javaparser by javaparser.
the class DifferentiateDotExpressionTest method packageStaticMethodCalls.
@Test
public void packageStaticMethodCalls() {
ClassOrInterfaceDeclaration clazz = ((JavaParserClassDeclaration) typeSolver.solveType("PackageDotExpressions")).getWrappedNode();
MethodDeclaration mainMethod = Navigator.demandMethod(clazz, "main");
JavaParserFacade javaParserFacade = JavaParserFacade.get(typeSolver);
MethodCallExpr staticMethodCall = Navigator.findMethodCall(mainMethod, "staticMethod").get();
MethodCallExpr methodCall = Navigator.findMethodCall(mainMethod, "methodCall").get();
MethodCallExpr innerMethodCall = Navigator.findMethodCall(mainMethod, "innerMethodCall").get();
MethodCallExpr innerInnerMethodCall = Navigator.findMethodCall(mainMethod, "innerInnerMethodCall").get();
MethodCallExpr firstFieldMethodCall = Navigator.findMethodCall(mainMethod, "firstContainerMethod").get();
MethodCallExpr secondFieldMethodCall = Navigator.findMethodCall(mainMethod, "secondContainerMethod").get();
MethodCallExpr thirdFieldMethodCall = Navigator.findMethodCall(mainMethod, "thirdContainerMethod").get();
assertEquals(true, javaParserFacade.solve(staticMethodCall).isSolved());
assertEquals(true, javaParserFacade.solve(methodCall).isSolved());
assertEquals(true, javaParserFacade.solve(innerMethodCall).isSolved());
assertEquals(true, javaParserFacade.solve(innerInnerMethodCall).isSolved());
assertEquals(true, javaParserFacade.solve(firstFieldMethodCall).isSolved());
assertEquals(true, javaParserFacade.solve(secondFieldMethodCall).isSolved());
assertEquals(true, javaParserFacade.solve(thirdFieldMethodCall).isSolved());
}
use of com.github.javaparser.ast.expr.MethodCallExpr in project javaparser by javaparser.
the class JavaParserAnonymousClassDeclarationTest method callingAnonymousClassInnerMethod.
@Test
public void callingAnonymousClassInnerMethod() {
CompilationUnit cu = parseSample("AnonymousClassDeclarations");
ClassOrInterfaceDeclaration aClass = Navigator.demandClass(cu, "AnonymousClassDeclarations");
MethodDeclaration method = Navigator.demandMethod(aClass, "fooBar3");
MethodCallExpr methodCall = Navigator.findMethodCall(method, "callAnnonClassInnerMethod").get();
CombinedTypeSolver combinedTypeSolver = new CombinedTypeSolver();
combinedTypeSolver.add(new ReflectionTypeSolver());
MethodUsage methodUsage = JavaParserFacade.get(combinedTypeSolver).solveMethodAsUsage(methodCall);
assertTrue(methodUsage.getQualifiedSignature().startsWith("AnonymousClassDeclarations"));
assertTrue(methodUsage.getQualifiedSignature().contains("Anonymous-"));
assertTrue(methodUsage.getQualifiedSignature().endsWith("callAnnonClassInnerMethod()"));
}
use of com.github.javaparser.ast.expr.MethodCallExpr in project javaparser by javaparser.
the class JavaParserAnonymousClassDeclarationTest method anonymousClassAsMethodArgument.
@Test
public void anonymousClassAsMethodArgument() {
CompilationUnit cu = parseSample("AnonymousClassDeclarations");
ClassOrInterfaceDeclaration aClass = Navigator.demandClass(cu, "AnonymousClassDeclarations");
MethodDeclaration method = Navigator.demandMethod(aClass, "fooBar1");
MethodCallExpr methodCall = Navigator.findMethodCall(method, "of").get();
CombinedTypeSolver combinedTypeSolver = new CombinedTypeSolver();
combinedTypeSolver.add(new ReflectionTypeSolver());
MethodUsage methodUsage = JavaParserFacade.get(combinedTypeSolver).solveMethodAsUsage(methodCall);
assertThat(methodUsage.getQualifiedSignature(), is("AnonymousClassDeclarations.ParDo.of(AnonymousClassDeclarations.DoFn<I, O>)"));
}
use of com.github.javaparser.ast.expr.MethodCallExpr in project javaparser by javaparser.
the class JavaParserAnonymousClassDeclarationTest method usingAnonymousSuperClassInnerType.
@Test
public void usingAnonymousSuperClassInnerType() {
CompilationUnit cu = parseSample("AnonymousClassDeclarations");
ClassOrInterfaceDeclaration aClass = Navigator.demandClass(cu, "AnonymousClassDeclarations");
MethodDeclaration method = Navigator.demandMethod(aClass, "fooBar4");
MethodCallExpr methodCall = Navigator.findMethodCall(method, "toString").get();
CombinedTypeSolver combinedTypeSolver = new CombinedTypeSolver();
combinedTypeSolver.add(new ReflectionTypeSolver());
MethodUsage methodUsage = JavaParserFacade.get(combinedTypeSolver).solveMethodAsUsage(methodCall);
assertThat(methodUsage.getQualifiedSignature(), is("java.lang.Enum.toString()"));
}
Aggregations