"Virtual" breakpoint for groovy embedded in XML
Hi everyone,
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":
<script>
<code>
String test = "world"
System.out.println("Hello " + test + " from script")
return test
</code>
</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.
Please sign in to leave a comment.
I've solved same issue once. But it was a solution on ide, debugger and fremework sides.
Breakpoints were set as usual and sent to debugger with original fine names and line numbers.
When framework compiled an embedded code into regular code, it was building a map of original line numbers to the new line numbers and passed this info to a debugger.
Debugger could map breakpoints received using this map.