How to get method level variable declarations using javaparser? -


am trying method level variables using visit(fielddeclaration n, object arg) , it's not working. on appreciable.

first of need use javaparser on source code compilationunit (which represents single file). @ point can use visitor. can create anonymous class extending genericvisitoradapter , override public r visit(final variabledeclarator n, final arg). take compilation unit , run compilationunit.accept(myvisitor, null);. in method override can parent of variabledeclator see if method or else.

as alternative can take compilation unit, access classes in there, access methods of classes , body of methods looking variabledeclarators.

disclaimer: javaparser contributor.


Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -