Method name from line number
问题 Given a line number of a particular class source code (Java/C#) - is there an easy way to get the name of the method it falls within? (If it falls within one) (Presumably using an Abstract Syntax Tree) (This would be useful in limiting the output of checkstyle to just the method touched). I'm assuming you'd have to use an Abstract Syntax Tree to do Line#->MethodName. 回答1: (Java-specific) If the class file was compiled with debug info then the line number table will contain a mapping of code<-