use of com.github.javaparser.symbolsolver.resolution.typesolvers.JavaParserTypeSolver in project javaparser by javaparser.
the class FieldsResolutionTest method accessClassFieldThroughThisWithCompetingSymbolInParentContext.
@Test
public void accessClassFieldThroughThisWithCompetingSymbolInParentContext() {
CompilationUnit cu = parseSample("AccessClassMemberThroughThis");
com.github.javaparser.ast.body.ClassOrInterfaceDeclaration clazz = Navigator.demandClass(cu, "AccessClassMemberThroughThis");
MethodDeclaration method = Navigator.demandMethod(clazz, "setLabel");
ExpressionStmt expressionStmt = (ExpressionStmt) method.getBody().get().getStatements().get(0);
AssignExpr assignExpr = (AssignExpr) expressionStmt.getExpression();
FieldAccessExpr fieldAccessExpr = (FieldAccessExpr) assignExpr.getTarget();
File src = adaptPath(new File("src/test/resources"));
CombinedTypeSolver typeSolver = new CombinedTypeSolver(new JavaParserTypeSolver(src), new ReflectionTypeSolver());
SymbolSolver symbolSolver = new SymbolSolver(typeSolver);
SymbolReference<? extends ResolvedValueDeclaration> ref = symbolSolver.solveSymbol(fieldAccessExpr.getName().getId(), fieldAccessExpr);
assertTrue(ref.isSolved());
assertTrue(ref.getCorrespondingDeclaration().isField());
}
use of com.github.javaparser.symbolsolver.resolution.typesolvers.JavaParserTypeSolver in project javaparser by javaparser.
the class MethodsResolutionLogicTest method setup.
@Before
public void setup() {
File srcNewCode = adaptPath(new File("src/test/test_sourcecode/javaparser_new_src/javaparser-core"));
CombinedTypeSolver combinedTypeSolverNewCode = new CombinedTypeSolver();
combinedTypeSolverNewCode.add(new ReflectionTypeSolver());
combinedTypeSolverNewCode.add(new JavaParserTypeSolver(srcNewCode));
combinedTypeSolverNewCode.add(new JavaParserTypeSolver(adaptPath(new File("src/test/test_sourcecode/javaparser_new_src/javaparser-generated-sources"))));
typeSolver = combinedTypeSolverNewCode;
}
use of com.github.javaparser.symbolsolver.resolution.typesolvers.JavaParserTypeSolver in project javaparser by javaparser.
the class MethodCallExprContextResolutionTest method createTypeSolver.
private CombinedTypeSolver createTypeSolver() {
File src = adaptPath(new File("src/test/resources"));
CombinedTypeSolver combinedTypeSolver = new CombinedTypeSolver();
combinedTypeSolver.add(new ReflectionTypeSolver());
combinedTypeSolver.add(new JavaParserTypeSolver(src));
return combinedTypeSolver;
}
Aggregations