Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extracting class usage from within Java methods using ctags

I would like to know if it is possible to use ctags to extract class usage from within Java methods. So far, I was able to only use it to get a listing of methods and instance variables but not which classes are utilized within methods.

E.g.

...
public void doSomething(MyClass myClassInst) {
     int someVar = myClassInst.getSomeVar();
     System.out.println("Some var is " + someVar);
}
...

Right now all I get is a recognition of the method declaration. But I would like to extract that doSomething is also utilizing the classes MyClass and System but not just to parse the text but also know the full class address including the package (java.lang.System and com.mypackage.MyClass).

In order to be able to extract this kind of metadata, ctags would need to have access to the compiler's abstract syntax tree and I am not sure if it does that or it simply does text parsing of the source code.

Is there a way to accomplish what I am trying to do using ctags or does it eclipse the scope of its functionality?

like image 948
amphibient Avatar asked Dec 20 '13 21:12

amphibient


1 Answers

You can use asm or BCEL to achieve this.

like image 67
Arun Avanathan Avatar answered Nov 15 '22 19:11

Arun Avanathan