use of com.github.javaparser.symbolsolver.javaparsermodel.contexts.MethodContext in project javaparser by javaparser.
the class Issue276 method testSolveStaticallyImportedMemberType.
@Test
public void testSolveStaticallyImportedMemberType() throws FileNotFoundException {
CompilationUnit cu = JavaParser.parse(new File(adaptPath("src/test/resources/issue276/foo/C.java")));
ClassOrInterfaceDeclaration cls = Navigator.demandClassOrInterface(cu, "C");
TypeSolver typeSolver = new CombinedTypeSolver(new ReflectionTypeSolver(), new JavaParserTypeSolver(adaptPath(new File("src/test/resources/issue276"))));
List<MethodDeclaration> methods = cls.findAll(MethodDeclaration.class);
boolean isSolved = false;
for (MethodDeclaration method : methods) {
if (method.getNameAsString().equals("overrideMe")) {
MethodContext context = new MethodContext(method, typeSolver);
isSolved = context.solveType("FindMeIfYouCan", typeSolver).isSolved();
}
}
Assert.assertTrue(isSolved);
}
use of com.github.javaparser.symbolsolver.javaparsermodel.contexts.MethodContext in project javaparser by javaparser.
the class MethodContextResolutionTest method solveTypeRefToLocalClass.
@Test
public void solveTypeRefToLocalClass() {
CompilationUnit cu = parseSample("MethodWithTypes");
ClassOrInterfaceDeclaration cd = Navigator.demandClass(cu, "Main");
MethodDeclaration md = Navigator.demandMethod(cd, "methodWithLocalTypes");
Context context = new MethodContext(md, typeSolver);
SymbolReference<ResolvedTypeDeclaration> ref = context.solveType("LocalClass", new MemoryTypeSolver());
assertEquals(true, ref.isSolved());
}
Aggregations