use of com.github.javaparser.symbolsolver.javaparsermodel.declarations.JavaParserClassDeclaration 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.symbolsolver.javaparsermodel.declarations.JavaParserClassDeclaration 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.symbolsolver.javaparsermodel.declarations.JavaParserClassDeclaration in project javaparser by javaparser.
the class MethodsResolutionLogicTest method compatibilityShouldConsiderAlsoTypeVariablesRaw.
@Test
public void compatibilityShouldConsiderAlsoTypeVariablesRaw() {
JavaParserClassDeclaration constructorDeclaration = (JavaParserClassDeclaration) typeSolver.solveType("com.github.javaparser.ast.body.ConstructorDeclaration");
ResolvedReferenceType rawClassType = (ResolvedReferenceType) ReflectionFactory.typeUsageFor(Class.class, typeSolver);
MethodUsage mu = constructorDeclaration.getAllMethods().stream().filter(m -> m.getDeclaration().getSignature().equals("isThrows(java.lang.Class<? extends java.lang.Throwable>)")).findFirst().get();
assertEquals(true, MethodResolutionLogic.isApplicable(mu, "isThrows", ImmutableList.of(rawClassType), typeSolver));
}
Aggregations