I have setup the JavaSymbolSolver like below:
Instance Variables:
private CombinedTypeSolver combinedTypeSolver = new CombinedTypeSolver();
private JavaSymbolSolver symbolSolver;
private ParserConfiguration parserConfiguration = new
ParserConfiguration();
private JavaParser parser;
private CompilationUnit compilationUnit = null;
private ParseResult<CompilationUnit> parseResultcompilationUnit = null;
from constructor:
this.combinedTypeSolver.add(new ReflectionTypeSolver());
this.combinedTypeSolver.add((new JavaParserTypeSolver("C:\\Users\\nfountou\\git\\TestingJavaParser\\rsc")));
this.combinedTypeSolver.add((new JavaParserTypeSolver("C:\\Users\\nfountou\\git\\TestingJavaParser")));
this.symbolSolver = new JavaSymbolSolver(this.combinedTypeSolver);
this.parserConfiguration.setSymbolResolver(this.symbolSolver);
this.parser = new JavaParser(parserConfiguration);
FileInputStream in = new FileInputStream(filepath);
this.parseResultcompilationUnit = this.parser.parse(in);
this.compilationUnit = parseResultcompilationUnit.getResult().get();
The test code seems to work fine and I am being able to resolve e.g. class B of class A as can be seen below:
public class A extends B{
}
the problem is that it seems that I cannot resolve anything else and whatever I tried I receive the message below:
Exception in thread "main" java.lang.IllegalStateException: No data of this type found. Use containsData to check for this first.
For example the source code that I am running for resolving e.g an AssignExpr:
ResolvedType declaringType = ((AssignExpr) value).calculateResolvedType();
(where value is an object that holds an AssignExpr node)
Resolving a superclass works fine and returns the right values:
ResolvedClassDeclaration declaringType = ((ClassOrInterfaceType) value).resolve().getTypeDeclaration().asClass();
Any ideas what am I doing wrong?