use of com.github.javaparser.resolution.declarations.ResolvedMethodDeclaration in project javaparser by javaparser.
the class MethodsResolutionTest method solveMethodWithTypePromotionsToByte.
@Test
public void solveMethodWithTypePromotionsToByte() {
CompilationUnit cu = parseSample("Issue338");
ClassOrInterfaceDeclaration clazz = Navigator.demandClass(cu, "TypePromotions");
MethodDeclaration method = Navigator.demandMethod(clazz, "callingByte");
{
MethodCallExpr expression = method.getBody().get().getStatements().get(0).asExpressionStmt().getExpression().asMethodCallExpr();
SymbolReference<ResolvedMethodDeclaration> reference = JavaParserFacade.get(new ReflectionTypeSolver()).solve(expression);
assertEquals(true, reference.isSolved());
assertEquals("byteParam", reference.getCorrespondingDeclaration().getName());
}
{
MethodCallExpr expression = method.getBody().get().getStatements().get(1).asExpressionStmt().getExpression().asMethodCallExpr();
SymbolReference<ResolvedMethodDeclaration> reference = JavaParserFacade.get(new ReflectionTypeSolver()).solve(expression);
assertEquals(false, reference.isSolved());
}
{
MethodCallExpr expression = method.getBody().get().getStatements().get(2).asExpressionStmt().getExpression().asMethodCallExpr();
SymbolReference<ResolvedMethodDeclaration> reference = JavaParserFacade.get(new ReflectionTypeSolver()).solve(expression);
assertEquals(false, reference.isSolved());
}
{
MethodCallExpr expression = method.getBody().get().getStatements().get(3).asExpressionStmt().getExpression().asMethodCallExpr();
SymbolReference<ResolvedMethodDeclaration> reference = JavaParserFacade.get(new ReflectionTypeSolver()).solve(expression);
assertEquals(false, reference.isSolved());
}
}
use of com.github.javaparser.resolution.declarations.ResolvedMethodDeclaration in project javaparser by javaparser.
the class MethodsResolutionTest method solveMethodWithTypePromotionsToInt.
@Test
public void solveMethodWithTypePromotionsToInt() {
CompilationUnit cu = parseSample("Issue338");
ClassOrInterfaceDeclaration clazz = Navigator.demandClass(cu, "TypePromotions");
MethodDeclaration method = Navigator.demandMethod(clazz, "callingInt");
{
MethodCallExpr expression = method.getBody().get().getStatements().get(0).asExpressionStmt().getExpression().asMethodCallExpr();
SymbolReference<ResolvedMethodDeclaration> reference = JavaParserFacade.get(new ReflectionTypeSolver()).solve(expression);
assertEquals(true, reference.isSolved());
assertEquals("intParam", reference.getCorrespondingDeclaration().getName());
}
{
MethodCallExpr expression = method.getBody().get().getStatements().get(1).asExpressionStmt().getExpression().asMethodCallExpr();
SymbolReference<ResolvedMethodDeclaration> reference = JavaParserFacade.get(new ReflectionTypeSolver()).solve(expression);
assertEquals(true, reference.isSolved());
assertEquals("intParam", reference.getCorrespondingDeclaration().getName());
}
{
MethodCallExpr expression = method.getBody().get().getStatements().get(2).asExpressionStmt().getExpression().asMethodCallExpr();
SymbolReference<ResolvedMethodDeclaration> reference = JavaParserFacade.get(new ReflectionTypeSolver()).solve(expression);
assertEquals(true, reference.isSolved());
assertEquals("intParam", reference.getCorrespondingDeclaration().getName());
}
{
MethodCallExpr expression = method.getBody().get().getStatements().get(3).asExpressionStmt().getExpression().asMethodCallExpr();
SymbolReference<ResolvedMethodDeclaration> reference = JavaParserFacade.get(new ReflectionTypeSolver()).solve(expression);
assertEquals(false, reference.isSolved());
}
}
use of com.github.javaparser.resolution.declarations.ResolvedMethodDeclaration in project javaparser by javaparser.
the class MethodsResolutionTest method solveMethodWithTypePromotionsToShort.
@Test
public void solveMethodWithTypePromotionsToShort() {
CompilationUnit cu = parseSample("Issue338");
ClassOrInterfaceDeclaration clazz = Navigator.demandClass(cu, "TypePromotions");
MethodDeclaration method = Navigator.demandMethod(clazz, "callingShort");
{
MethodCallExpr expression = method.getBody().get().getStatements().get(0).asExpressionStmt().getExpression().asMethodCallExpr();
SymbolReference<ResolvedMethodDeclaration> reference = JavaParserFacade.get(new ReflectionTypeSolver()).solve(expression);
assertEquals(true, reference.isSolved());
assertEquals("shortParam", reference.getCorrespondingDeclaration().getName());
}
{
MethodCallExpr expression = method.getBody().get().getStatements().get(1).asExpressionStmt().getExpression().asMethodCallExpr();
SymbolReference<ResolvedMethodDeclaration> reference = JavaParserFacade.get(new ReflectionTypeSolver()).solve(expression);
assertEquals(true, reference.isSolved());
assertEquals("shortParam", reference.getCorrespondingDeclaration().getName());
}
{
MethodCallExpr expression = method.getBody().get().getStatements().get(2).asExpressionStmt().getExpression().asMethodCallExpr();
SymbolReference<ResolvedMethodDeclaration> reference = JavaParserFacade.get(new ReflectionTypeSolver()).solve(expression);
assertEquals(false, reference.isSolved());
}
{
MethodCallExpr expression = method.getBody().get().getStatements().get(3).asExpressionStmt().getExpression().asMethodCallExpr();
SymbolReference<ResolvedMethodDeclaration> reference = JavaParserFacade.get(new ReflectionTypeSolver()).solve(expression);
assertEquals(false, reference.isSolved());
}
}
use of com.github.javaparser.resolution.declarations.ResolvedMethodDeclaration in project javaparser by javaparser.
the class MethodsResolutionTest method callOnThisInAnonymousClass.
@Test
public void callOnThisInAnonymousClass() {
CompilationUnit cu = parseSample("ThisInAnonymousClass");
ClassOrInterfaceDeclaration clazz = Navigator.demandClass(cu, "Bar");
MethodCallExpr fooCall = Navigator.findMethodCall(clazz, "foo").get();
SymbolReference<ResolvedMethodDeclaration> reference = JavaParserFacade.get(new ReflectionTypeSolver()).solve(fooCall);
assertEquals(true, reference.isSolved());
}
use of com.github.javaparser.resolution.declarations.ResolvedMethodDeclaration in project javaparser by javaparser.
the class MethodsResolutionTest method solveMethodWithTypePromotionsToIntWithExtraParam.
@Test
public void solveMethodWithTypePromotionsToIntWithExtraParam() {
CompilationUnit cu = parseSample("Issue338");
ClassOrInterfaceDeclaration clazz = Navigator.demandClass(cu, "TypePromotionsWithExtraParam");
MethodDeclaration method = Navigator.demandMethod(clazz, "callingInt");
{
MethodCallExpr expression = method.getBody().get().getStatements().get(0).asExpressionStmt().getExpression().asMethodCallExpr();
SymbolReference<ResolvedMethodDeclaration> reference = JavaParserFacade.get(new ReflectionTypeSolver()).solve(expression);
assertEquals(true, reference.isSolved());
assertEquals("intParam", reference.getCorrespondingDeclaration().getName());
}
{
MethodCallExpr expression = method.getBody().get().getStatements().get(1).asExpressionStmt().getExpression().asMethodCallExpr();
SymbolReference<ResolvedMethodDeclaration> reference = JavaParserFacade.get(new ReflectionTypeSolver()).solve(expression);
assertEquals(true, reference.isSolved());
assertEquals("intParam", reference.getCorrespondingDeclaration().getName());
}
{
MethodCallExpr expression = method.getBody().get().getStatements().get(2).asExpressionStmt().getExpression().asMethodCallExpr();
SymbolReference<ResolvedMethodDeclaration> reference = JavaParserFacade.get(new ReflectionTypeSolver()).solve(expression);
assertEquals(true, reference.isSolved());
assertEquals("intParam", reference.getCorrespondingDeclaration().getName());
}
{
MethodCallExpr expression = method.getBody().get().getStatements().get(3).asExpressionStmt().getExpression().asMethodCallExpr();
SymbolReference<ResolvedMethodDeclaration> reference = JavaParserFacade.get(new ReflectionTypeSolver()).solve(expression);
assertEquals(false, reference.isSolved());
}
}
Aggregations