Suppose I have the following Class A
in pkg1
and a Class B
in pkg2
and function calculate()
is defined in pkg2
class B
as follows:
B.calculate(A a1, A a2);
I want to identify the the type of parameters a1
and a2
. For instance, here it will be pkg1.A
and pkg1.A
as class A
belongs to pkg1
.
My main concern is, I do not want to build the project, I want to do static analysis(I have all the source files).
I know a way to infer the the parameter types using Eclipse JDT but how do I do it using javaparser(https://github.com/javaparser/javaparser) and javasymbolsolver(https://github.com/javaparser/javasymbolsolver).
In Eclipse JDT, i have just set the source files' path in the parser environment and it worked. But in javasymbolsolver, even after I add the source files in the typesolver, it is not working.
CombinedTypeSolver combinedTypeSolver = new CombinedTypeSolver();
combinedTypeSolver.add(new JavaParserTypeSolver("path to the sourcefiles"));
JavaParserFacade j=JavaParserFacade.get(combinedTypeSolver);
SymbolReference<MethodDeclaration> ref = j.solve((MethodCallExpr) n);