use of com.github.javaparser.symbolsolver.resolution.typesolvers.ReflectionTypeSolver in project javaparser by javaparser.
the class VariadicResolutionTest method issue7.
@Test
public void issue7() {
CompilationUnit cu = parseSample("Generics_issue7");
ClassOrInterfaceDeclaration clazz = Navigator.demandClass(cu, "SomeCollection");
MethodDeclaration method = Navigator.demandMethod(clazz, "foo3");
ReturnStmt stmt = (ReturnStmt) method.getBody().get().getStatements().get(0);
Expression expression = stmt.getExpression().get();
JavaParserFacade javaParserFacade = JavaParserFacade.get(new ReflectionTypeSolver());
ResolvedType type = javaParserFacade.getType(expression);
assertEquals(true, type.isReferenceType());
assertEquals(List.class.getCanonicalName(), type.asReferenceType().getQualifiedName());
assertEquals("java.util.List<java.lang.Long>", type.describe());
}
use of com.github.javaparser.symbolsolver.resolution.typesolvers.ReflectionTypeSolver in project javaparser by javaparser.
the class ClassOrInterfaceDeclarationContextResolutionTest method solveMethodOverrideCase.
@Test
public void solveMethodOverrideCase() {
CompilationUnit cu = parseSample("ClassWithMethods");
ClassOrInterfaceDeclaration classOrInterfaceDeclaration = Navigator.demandClass(cu, "A");
Context context = new ClassOrInterfaceDeclarationContext(classOrInterfaceDeclaration, typeSolver);
SymbolReference<ResolvedMethodDeclaration> ref = context.solveMethod("foo1", ImmutableList.of(), false, new ReflectionTypeSolver());
assertEquals(true, ref.isSolved());
assertEquals("A", ref.getCorrespondingDeclaration().declaringType().getName());
assertEquals(0, ref.getCorrespondingDeclaration().getNumberOfParams());
}
use of com.github.javaparser.symbolsolver.resolution.typesolvers.ReflectionTypeSolver in project javaparser by javaparser.
the class ClassOrInterfaceDeclarationContextResolutionTest method solveMethodAsUsageSimpleCase.
@Test
public void solveMethodAsUsageSimpleCase() {
CompilationUnit cu = parseSample("ClassWithMethods");
ClassOrInterfaceDeclaration classOrInterfaceDeclaration = Navigator.demandClass(cu, "A");
Context context = new ClassOrInterfaceDeclarationContext(classOrInterfaceDeclaration, typeSolver);
Optional<MethodUsage> ref = context.solveMethodAsUsage("foo0", ImmutableList.of(), new ReflectionTypeSolver());
assertEquals(true, ref.isPresent());
assertEquals("A", ref.get().declaringType().getName());
assertEquals(0, ref.get().getNoParams());
}
use of com.github.javaparser.symbolsolver.resolution.typesolvers.ReflectionTypeSolver in project javaparser by javaparser.
the class ClassOrInterfaceDeclarationContextResolutionTest method solveMethodInheritedCase.
@Test
public void solveMethodInheritedCase() {
CompilationUnit cu = parseSample("ClassWithMethods");
ClassOrInterfaceDeclaration classOrInterfaceDeclaration = Navigator.demandClass(cu, "A");
Context context = new ClassOrInterfaceDeclarationContext(classOrInterfaceDeclaration, typeSolver);
SymbolReference<ResolvedMethodDeclaration> ref = context.solveMethod("foo2", ImmutableList.of(), false, new ReflectionTypeSolver());
assertEquals(true, ref.isSolved());
assertEquals("Super", ref.getCorrespondingDeclaration().declaringType().getName());
assertEquals(0, ref.getCorrespondingDeclaration().getNumberOfParams());
}
use of com.github.javaparser.symbolsolver.resolution.typesolvers.ReflectionTypeSolver in project javaparser by javaparser.
the class ClassOrInterfaceDeclarationContextResolutionTest method solveMethodWithAmbiguosCall.
@Test(expected = MethodAmbiguityException.class)
public void solveMethodWithAmbiguosCall() {
CompilationUnit cu = parseSample("ClassWithMethods");
ClassOrInterfaceDeclaration classOrInterfaceDeclaration = Navigator.demandClass(cu, "A");
Context context = new ClassOrInterfaceDeclarationContext(classOrInterfaceDeclaration, typeSolver);
SymbolReference<ResolvedMethodDeclaration> ref = context.solveMethod("foo5", ImmutableList.of(NullType.INSTANCE), false, new ReflectionTypeSolver());
}
Aggregations