javaparser
javaparser copied to clipboard
Is there a way to obtain method calls just inside the project?
I want to get all method calls inside methods of the classes of local project, not method calls external the local project packages.
I try this:
// finding all method calls
List<MethodCallExpr> allMethodCalls = declaration.findAll(MethodCallExpr.class);
for (MethodCallExpr methodcall : allMethodCalls)
{
MethodInvocation mcall=new MethodInvocation();
System.out.println("CALLLLL : " + methodcall.getName());
System.out.println(" LL : " + methodcall.getScope());
try {
System.out.println(" CCCCC : " + methodcall.calculateResolvedType().describe());
System.out.println(" CCCCC : " + methodcall.getParentNode().get().toString());
}
catch (Exception e) {
// TODO: handle exception
}
try {
System.out.println(" QQQQQ : " + methodcall.resolve().getSignature());
System.out.println(" QQQQQ : " + methodcall.resolve().getQualifiedSignature());
System.out.println(" QQQQQ : " + methodcall.resolve().getQualifiedName());
System.out.println(" QQQQQ : " + methodcall.resolve().getPackageName());
//System.out.println(" QQQQQ : " + methodcall.resolve().toString());
}
catch (Exception e) {
// TODO: handle exception
}
}
but I could not distinguish among them.
Hi @GholamaliIrani have you tried to resolve the scope of the method call and then filter on the qualified name? Can you provide us a simple unit test that illustrates your problem?
I am closing this issue but you can reopen it if the answer does not suit you.