use of com.github.javaparser.symbolsolver.resolution.typesolvers.CombinedTypeSolver in project javaparser by javaparser.
the class CompilationUnitContextResolutionTest method solveSymbolAsValueReferringToStaticallyImportedValue.
@Test
public void solveSymbolAsValueReferringToStaticallyImportedValue() throws ParseException, IOException {
CompilationUnit cu = parseSample("CompilationUnitSymbols");
Context context = new CompilationUnitContext(cu, typeSolver);
CombinedTypeSolver typeSolver = new CombinedTypeSolver();
typeSolver.add(new ReflectionTypeSolver());
typeSolver.add(new JarTypeSolver(adaptPath("src/test/resources/junit-4.8.1.jar")));
Optional<Value> ref = context.solveSymbolAsValue("out", typeSolver);
assertEquals(true, ref.isPresent());
assertEquals("java.io.PrintStream", ref.get().getType().describe());
}
use of com.github.javaparser.symbolsolver.resolution.typesolvers.CombinedTypeSolver in project javaparser by javaparser.
the class JavaParserAnonymousClassDeclarationTest method callingAnonymousClassInnerMethod.
@Test
public void callingAnonymousClassInnerMethod() {
CompilationUnit cu = parseSample("AnonymousClassDeclarations");
ClassOrInterfaceDeclaration aClass = Navigator.demandClass(cu, "AnonymousClassDeclarations");
MethodDeclaration method = Navigator.demandMethod(aClass, "fooBar3");
MethodCallExpr methodCall = Navigator.findMethodCall(method, "callAnnonClassInnerMethod").get();
CombinedTypeSolver combinedTypeSolver = new CombinedTypeSolver();
combinedTypeSolver.add(new ReflectionTypeSolver());
MethodUsage methodUsage = JavaParserFacade.get(combinedTypeSolver).solveMethodAsUsage(methodCall);
assertTrue(methodUsage.getQualifiedSignature().startsWith("AnonymousClassDeclarations"));
assertTrue(methodUsage.getQualifiedSignature().contains("Anonymous-"));
assertTrue(methodUsage.getQualifiedSignature().endsWith("callAnnonClassInnerMethod()"));
}
use of com.github.javaparser.symbolsolver.resolution.typesolvers.CombinedTypeSolver in project javaparser by javaparser.
the class JavaParserAnonymousClassDeclarationTest method anonymousClassAsMethodArgument.
@Test
public void anonymousClassAsMethodArgument() {
CompilationUnit cu = parseSample("AnonymousClassDeclarations");
ClassOrInterfaceDeclaration aClass = Navigator.demandClass(cu, "AnonymousClassDeclarations");
MethodDeclaration method = Navigator.demandMethod(aClass, "fooBar1");
MethodCallExpr methodCall = Navigator.findMethodCall(method, "of").get();
CombinedTypeSolver combinedTypeSolver = new CombinedTypeSolver();
combinedTypeSolver.add(new ReflectionTypeSolver());
MethodUsage methodUsage = JavaParserFacade.get(combinedTypeSolver).solveMethodAsUsage(methodCall);
assertThat(methodUsage.getQualifiedSignature(), is("AnonymousClassDeclarations.ParDo.of(AnonymousClassDeclarations.DoFn<I, O>)"));
}
use of com.github.javaparser.symbolsolver.resolution.typesolvers.CombinedTypeSolver in project javaparser by javaparser.
the class JavaParserAnonymousClassDeclarationTest method usingAnonymousSuperClassInnerType.
@Test
public void usingAnonymousSuperClassInnerType() {
CompilationUnit cu = parseSample("AnonymousClassDeclarations");
ClassOrInterfaceDeclaration aClass = Navigator.demandClass(cu, "AnonymousClassDeclarations");
MethodDeclaration method = Navigator.demandMethod(aClass, "fooBar4");
MethodCallExpr methodCall = Navigator.findMethodCall(method, "toString").get();
CombinedTypeSolver combinedTypeSolver = new CombinedTypeSolver();
combinedTypeSolver.add(new ReflectionTypeSolver());
MethodUsage methodUsage = JavaParserFacade.get(combinedTypeSolver).solveMethodAsUsage(methodCall);
assertThat(methodUsage.getQualifiedSignature(), is("java.lang.Enum.toString()"));
}
use of com.github.javaparser.symbolsolver.resolution.typesolvers.CombinedTypeSolver in project javaparser by javaparser.
the class JavaParserAnonymousClassDeclarationTest method usingAnonymousClassInnerType.
@Test
public void usingAnonymousClassInnerType() {
CompilationUnit cu = parseSample("AnonymousClassDeclarations");
ClassOrInterfaceDeclaration aClass = Navigator.demandClass(cu, "AnonymousClassDeclarations");
MethodDeclaration method = Navigator.demandMethod(aClass, "fooBar5");
MethodCallExpr methodCall = Navigator.findMethodCall(method, "toString").get();
CombinedTypeSolver combinedTypeSolver = new CombinedTypeSolver();
combinedTypeSolver.add(new ReflectionTypeSolver());
MethodUsage methodUsage = JavaParserFacade.get(combinedTypeSolver).solveMethodAsUsage(methodCall);
assertThat(methodUsage.getQualifiedSignature(), is("java.lang.Enum.toString()"));
}
Aggregations