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

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -