For debugging purposes, I would like, at Runtime, to be able to display the .groovy source file that defined a given Class. Is it possibly natively ?
Note that the groovy class might not be in the stacktrace, but a class given in argument. The result will be a function with the signature:
String getSourceInfo(Class<?> clazz) {...} //returns /home/user/work/..../SomeClass.groovy
As an extension, we could also retrieve line numbers or use this function on fields and methods:
String getSourceInfo(Field field) {...} //returns /..../SomeClass.groovy#13:5
If not, I was thinking of adding a Groovy AST adding an annotation on the ClassNode. It should not be too difficult, as we have all the required information (in SEMANTIC_ANALYSIS for example) but there might be some standard way. Any suggestion?