I have following situation. Application loads some XML files, then take portions of those XMLs and compiles them as groovy scripts - we'll get many Script[1..n] classes. I would like to be able to debug these groovy fragments through idea using XML files on filesystem. Simple example - "objects.xml":
String test = "world"
System.out.println("Hello " + test + " from script")
I would like to put breakpoint on line 4 (sysout). If this script was compiled as "Script1" class the I have to tell JVM to create breakpoint in Script1.class line 3, but in IDE it should stop in objects.xml file line 4. This means that I have to create some kind of virtual breakpoint which will do this.
So far I've just tried to create manually "Script1.groovy" file with content of <code> element and put breakpoint there. This worked just fine, but since there can be many scripts and in real world scenario I won't know which code fragment was translated to which "Script[0..]" class I would like to just create breapoint in xml and let IDE handle this situation.
I was also able to get some map from JVM containing script code as a key and class name as a value. This could be used to create JVM breakpoint. Now I'm stuck, only thing related to this I was able to find is https://intellij-support.jetbrains.com/hc/en-us/community/posts/360000600150-Programmatically-start-debugger?flash_digest=083b329bebf91d2f2fc4dd95a389ee82222ea602.
Any ideas how to achieve my goal? Or which classes should I look up to learn from?
Thanks a lot.