How to get surrounding method in Java source file for a given line number
- by roesslerj
I have a line number of a Java source file and want to get the sourounding method for that line number programatically.
I looked into ANTLR which didn't help me much.
Janino (http://www.janino.net) seems promising, I would scan and parse (and if necessary compile) the code. Then I could use JDI and
ReferenceType.locationsOfLine(int lineNumber)
Still I don't know how to use JDI for doing this and didn't find a tutorial that goes anywhere in this direction.
Maybe there is some other way that I am completely missing.