use of com.github.javaparser.symbolsolver.javaparsermodel.JavaParserFacade in project javaparser by javaparser.
the class Issue200 method issue200.
@Test
public void issue200() {
CompilationUnit cu = parseSample("Issue200");
ClassOrInterfaceDeclaration clazz = Navigator.demandClass(cu, "JavaTest");
MethodDeclaration methodDeclaration = Navigator.demandMethod(clazz, "foo");
TypeSolver typeSolver = new ReflectionTypeSolver();
JavaParserFacade javaParserFacade = JavaParserFacade.get(typeSolver);
List<ReturnStmt> nodesByType = methodDeclaration.findAll(ReturnStmt.class);
assertEquals("java.util.stream.Stream<JavaTest.Solved>", javaParserFacade.getType((nodesByType.get(0)).getExpression().get()).describe());
}
use of com.github.javaparser.symbolsolver.javaparsermodel.JavaParserFacade 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.symbolsolver.javaparsermodel.JavaParserFacade 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.symbolsolver.javaparsermodel.JavaParserFacade in project javaparser by javaparser.
the class ContextTest method resolveReferenceToLambdaParamBase.
@Test
public void resolveReferenceToLambdaParamBase() {
CompilationUnit cu = parseSample("NavigatorSimplified");
com.github.javaparser.ast.body.ClassOrInterfaceDeclaration clazz = Navigator.demandClass(cu, "Navigator");
MethodDeclaration method = Navigator.demandMethod(clazz, "findType");
NameExpr refToT = Navigator.findNameExpression(method, "t").get();
TypeSolver typeSolver = new ReflectionTypeSolver();
JavaParserFacade javaParserFacade = JavaParserFacade.get(typeSolver);
ResolvedType ref = javaParserFacade.getType(refToT);
assertEquals("? super java.lang.String", ref.describe());
}
use of com.github.javaparser.symbolsolver.javaparsermodel.JavaParserFacade in project javaparser by javaparser.
the class GenericsResolutionTest method methodWithGenericParameterTypes.
@Test
public void methodWithGenericParameterTypes() {
CompilationUnit cu = parseSample("GenericCollectionWithExtension");
ClassOrInterfaceDeclaration clazz = Navigator.demandClass(cu, "Foo");
MethodDeclaration method = Navigator.demandMethod(clazz, "bar");
MethodCallExpr methodCall = Navigator.findMethodCall(method, "foo").get();
TypeSolver typeSolver = new ReflectionTypeSolver();
JavaParserFacade javaParserFacade = JavaParserFacade.get(typeSolver);
MethodUsage methodUsage = javaParserFacade.solveMethodAsUsage(methodCall);
assertEquals("foo", methodUsage.getName());
}
Aggregations