use of com.github.javaparser.symbolsolver.model.resolution.Value in project javaparser by javaparser.
the class LambdaExprContextResolutionTest method solveParameterOfLambdaInMethodCallExpr.
@Test
public void solveParameterOfLambdaInMethodCallExpr() {
CompilationUnit cu = parseSample("Lambda");
com.github.javaparser.ast.body.ClassOrInterfaceDeclaration clazz = Navigator.demandClass(cu, "Agenda");
MethodDeclaration method = Navigator.demandMethod(clazz, "lambdaMap");
ReturnStmt returnStmt = Navigator.findReturnStmt(method);
MethodCallExpr methodCallExpr = (MethodCallExpr) returnStmt.getExpression().get();
LambdaExpr lambdaExpr = (LambdaExpr) methodCallExpr.getArguments().get(0);
Context context = new LambdaExprContext(lambdaExpr, typeSolver);
Optional<Value> ref = context.solveSymbolAsValue("p", typeSolver);
assertTrue(ref.isPresent());
assertEquals("? super java.lang.String", ref.get().getType().describe());
}
Aggregations