I have a program that is like this :
class A {
String abc;
public void f1(){
String abc = 'test';
System.out.println(abc);
if (true){
String abc = 'something else';
System.out.println(abc);
}
}
public void f2(){
String abc = 'something else';
System.out.println(abc);
}
}
Now as we can see here we have three different variable declarations of the string abc. I wish to make a dependency matrix which will have slots for all the three declarations , that point to different memory locations. Is there any way I could get the declarations for each variable name along with the parent class or method it belongs to? Or more precisely , can I get the scope of a variable ,I.E whether it is a class variable or a variable that belongs to a method ?
I have tried using JavaParser but couldn’t find a suitable method that would do the same. Kindly help me out. Thanks a lot!!