use of com.github.javaparser.symbolsolver.resolution.typesolvers.ReflectionTypeSolver 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.resolution.typesolvers.ReflectionTypeSolver in project javaparser by javaparser.
the class Issue300 method fieldAccessIssue.
@Test
public void fieldAccessIssue() throws ParseException, FileNotFoundException {
String pathToSourceFile = adaptPath("src/test/resources/issue300/Issue300.java");
CompilationUnit cu = JavaParser.parse(new File(pathToSourceFile));
final FieldAccessExpr fieldAccess = Navigator.findNodeOfGivenClass(cu, FieldAccessExpr.class);
assertNotNull(fieldAccess);
TypeSolver typeSolver = new CombinedTypeSolver(new ReflectionTypeSolver(), new JavaParserTypeSolver(adaptPath(new File("src/test/resources/issue300"))));
final JavaParserFacade javaParserFacade = JavaParserFacade.get(typeSolver);
final SymbolReference<? extends ResolvedValueDeclaration> ref = javaParserFacade.solve(fieldAccess);
assertEquals(ResolvedPrimitiveType.INT, ref.getCorrespondingDeclaration().getType().asPrimitive());
}
use of com.github.javaparser.symbolsolver.resolution.typesolvers.ReflectionTypeSolver in project javaparser by javaparser.
the class Issue343 method setup.
@Before
public void setup() {
typeResolver = new ReflectionTypeSolver();
javaParserFacade = JavaParserFacade.get(typeResolver);
}
use of com.github.javaparser.symbolsolver.resolution.typesolvers.ReflectionTypeSolver in project javaparser by javaparser.
the class Issue314 method setup.
@Before
public void setup() {
typeResolver = new ReflectionTypeSolver();
javaParserFacade = JavaParserFacade.get(typeResolver);
}
use of com.github.javaparser.symbolsolver.resolution.typesolvers.ReflectionTypeSolver in project javaparser by javaparser.
the class JavaParserAPIIntegrationTest method setup.
@Before
public void setup() {
File src = adaptPath(new File("src/test/test_sourcecode/javaparser_new_src/javaparser-core"));
CombinedTypeSolver combinedTypeSolverNewCode = new CombinedTypeSolver();
combinedTypeSolverNewCode.add(new ReflectionTypeSolver());
combinedTypeSolverNewCode.add(new JavaParserTypeSolver(src));
combinedTypeSolverNewCode.add(new JavaParserTypeSolver(adaptPath(new File("src/test/test_sourcecode/javaparser_new_src/javaparser-generated-sources"))));
typeSolver = combinedTypeSolverNewCode;
TypeSolver ts = new ReflectionTypeSolver();
string = new ReferenceTypeImpl(ts.solveType(String.class.getCanonicalName()), ts);
ResolvedReferenceType booleanC = new ReferenceTypeImpl(ts.solveType(Boolean.class.getCanonicalName()), ts);
listOfBoolean = new ReferenceTypeImpl(ts.solveType(List.class.getCanonicalName()), ImmutableList.of(booleanC), ts);
}
Aggregations