use of com.github.javaparser.ast.expr.MethodCallExpr in project javaparser by javaparser.
the class Issue185 method testIssue.
@Test
public void testIssue() throws FileNotFoundException {
File src = adaptPath(new File("src/test/resources/recursion-issue"));
CombinedTypeSolver combinedTypeSolver = new CombinedTypeSolver();
combinedTypeSolver.add(new JavaParserTypeSolver(src));
combinedTypeSolver.add(new ReflectionTypeSolver());
CompilationUnit agendaCu = JavaParser.parse(adaptPath(new File("src/test/resources/recursion-issue/Usage.java")));
MethodCallExpr foo = Navigator.findMethodCall(agendaCu, "foo").get();
assertNotNull(foo);
JavaParserFacade.get(combinedTypeSolver).getType(foo);
}
use of com.github.javaparser.ast.expr.MethodCallExpr in project javaparser by javaparser.
the class Issue228 method testSolvingMethodWitPrimitiveParameterTypeAsUsage.
@Test
public void testSolvingMethodWitPrimitiveParameterTypeAsUsage() {
String code = "class Test { " + " long l = call(1); " + " long call(final long i) { " + " return i; " + " }" + "}";
CompilationUnit cu = JavaParser.parse(code);
MethodCallExpr methodCall = cu.findAll(MethodCallExpr.class).get(0);
JavaParserFacade parserFacade = JavaParserFacade.get(new ReflectionTypeSolver());
MethodUsage solvedCall = parserFacade.solveMethodAsUsage(methodCall);
assertEquals("long", solvedCall.getParamType(0).describe());
}
use of com.github.javaparser.ast.expr.MethodCallExpr in project javaparser by javaparser.
the class Issue128 method loopOnStaticallyImportedType.
@Test
public void loopOnStaticallyImportedType() {
CompilationUnit cu = parseSampleWithStandardExtension("issue128/foo/Issue128");
ClassOrInterfaceDeclaration clazz = Navigator.demandClass(cu, "JavaTest");
ExpressionStmt expressionStmt = (ExpressionStmt) clazz.getMethodsByName("test").get(0).getBody().get().getStatement(0);
MethodCallExpr methodCallExpr = (MethodCallExpr) expressionStmt.getExpression();
JavaParserFacade javaParserFacade = JavaParserFacade.get(typeSolver);
assertEquals(false, javaParserFacade.solve(methodCallExpr).isSolved());
}
use of com.github.javaparser.ast.expr.MethodCallExpr in project javaparser by javaparser.
the class BlockStmtTest method issue748AddingIdenticalStatementsDoesParentingRight.
@Test
public void issue748AddingIdenticalStatementsDoesParentingRight() {
BlockStmt blockStmt = new BlockStmt();
Expression exp = new NameExpr("x");
MethodCallExpr expression = new MethodCallExpr(exp, "y");
blockStmt.addStatement(expression);
blockStmt.addStatement(expression.clone());
// This fails when the issue exists:
String s = blockStmt.toString();
}
use of com.github.javaparser.ast.expr.MethodCallExpr in project javaparser by javaparser.
the class ContextTest method resolveTypeUsageOfCascadeMethodInGenericClass.
@Test
public void resolveTypeUsageOfCascadeMethodInGenericClass() throws ParseException, IOException {
CompilationUnit cu = parseSample("Navigator");
com.github.javaparser.ast.body.ClassOrInterfaceDeclaration clazz = Navigator.demandClass(cu, "Navigator");
MethodDeclaration method = Navigator.demandMethod(clazz, "findType");
MethodCallExpr callToFilter = Navigator.findMethodCall(method, "filter").get();
String pathToJar = adaptPath("src/test/resources/javaparser-core-2.1.0.jar");
TypeSolver typeSolver = new CombinedTypeSolver(new ReflectionTypeSolver(), new JarTypeSolver(pathToJar));
MethodUsage filterUsage = JavaParserFacade.get(typeSolver).solveMethodAsUsage(callToFilter);
assertEquals("java.util.stream.Stream<com.github.javaparser.ast.body.TypeDeclaration>", filterUsage.returnType().describe());
}
Aggregations