use of com.github.javaparser.symbolsolver.resolution.typesolvers.ReflectionTypeSolver in project javaparser by javaparser.
the class ClassOrInterfaceDeclarationContextResolutionTest method solveMethodWithPrimitiveParameters.
@Test
public void solveMethodWithPrimitiveParameters() {
CompilationUnit cu = parseSample("ClassWithMethods");
ClassOrInterfaceDeclaration classOrInterfaceDeclaration = Navigator.demandClass(cu, "A");
Context context = new ClassOrInterfaceDeclarationContext(classOrInterfaceDeclaration, typeSolver);
ResolvedType intType = ResolvedPrimitiveType.INT;
SymbolReference<ResolvedMethodDeclaration> ref = context.solveMethod("foo3", ImmutableList.of(intType), false, new ReflectionTypeSolver());
assertEquals(true, ref.isSolved());
assertEquals("A", ref.getCorrespondingDeclaration().declaringType().getName());
assertEquals(1, ref.getCorrespondingDeclaration().getNumberOfParams());
}
use of com.github.javaparser.symbolsolver.resolution.typesolvers.ReflectionTypeSolver in project javaparser by javaparser.
the class ClassOrInterfaceDeclarationContextResolutionTest method solveMethodSimpleCase.
@Test
public void solveMethodSimpleCase() {
CompilationUnit cu = parseSample("ClassWithMethods");
ClassOrInterfaceDeclaration classOrInterfaceDeclaration = Navigator.demandClass(cu, "A");
Context context = new ClassOrInterfaceDeclarationContext(classOrInterfaceDeclaration, typeSolver);
SymbolReference<ResolvedMethodDeclaration> ref = context.solveMethod("foo0", 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 solveMethodAsUsageWithMoreSpecializedParameter.
@Test
public void solveMethodAsUsageWithMoreSpecializedParameter() {
CompilationUnit cu = parseSample("ClassWithMethods");
ClassOrInterfaceDeclaration classOrInterfaceDeclaration = Navigator.demandClass(cu, "A");
Context context = new ClassOrInterfaceDeclarationContext(classOrInterfaceDeclaration, typeSolver);
ResolvedType stringType = new ReferenceTypeImpl(new ReflectionClassDeclaration(String.class, typeSolver), typeSolver);
Optional<MethodUsage> ref = context.solveMethodAsUsage("foo4", ImmutableList.of(stringType), new ReflectionTypeSolver());
assertEquals(true, ref.isPresent());
assertEquals("A", ref.get().declaringType().getName());
assertEquals(1, ref.get().getNoParams());
}
use of com.github.javaparser.symbolsolver.resolution.typesolvers.ReflectionTypeSolver in project javaparser by javaparser.
the class CompilationUnitContextResolutionTest method solveSymbolReferringToStaticField.
@Test
public void solveSymbolReferringToStaticField() throws ParseException, IOException {
CompilationUnit cu = parseSample("CompilationUnitSymbols");
Context context = new CompilationUnitContext(cu, typeSolver);
SymbolReference<? extends ResolvedValueDeclaration> ref = context.solveSymbol("java.lang.System.out", new ReflectionTypeSolver());
assertEquals(true, ref.isSolved());
assertEquals("java.io.PrintStream", ref.getCorrespondingDeclaration().getType().asReferenceType().getQualifiedName());
}
use of com.github.javaparser.symbolsolver.resolution.typesolvers.ReflectionTypeSolver in project javaparser by javaparser.
the class CompilationUnitContextResolutionTest method solveSymbolAsValueReferringToStaticField.
@Test
public void solveSymbolAsValueReferringToStaticField() throws ParseException, IOException {
CompilationUnit cu = parseSample("CompilationUnitSymbols");
Context context = new CompilationUnitContext(cu, typeSolver);
Optional<Value> ref = context.solveSymbolAsValue("java.lang.System.out", new ReflectionTypeSolver());
assertEquals(true, ref.isPresent());
assertEquals("java.io.PrintStream", ref.get().getType().describe());
}
Aggregations