Debugging groovy closure created in ASTTransformations
Hello
I am using a groovy AST to wrap all code in my function. This happens without the IDE knowing about it because it happens at runtime. Therefore when I setup my breakpoint, it thinks the breakpoint is at file Flow.groovy:23 but at runtime, because the closure is a separate class, the breakpoint really needs to be in another closure class at a different location. Per the IDE. The first image is before I started to debug. Notice that a closure in the script shows breakpoint info reflecting the same file name. But during debug, the breakpoint is actually in a diffferent class/location. How does Groovy achieve this? I possibly need to do something similar right?


Please sign in to leave a comment.
To do this better you should work with closures in Groovy, these closures can be mapped to separate classes or objects at runtime, creating a difference between the source code location in the IDE and the actual running program.
https://intellij-support.jetbrains.com/hc/en-us/community/posts/206635495-Groovy-generated-classes-causing-compilation-issues Geometry Dash Lite
This is a great question! Debugging code that’s manipulated at runtime via AST Transformations can be tricky since the IDE doesn't have visibility into those changes until execution. Has anyone found a workaround for setting breakpoints in these dynamically generated closures, or any best practices for inspecting runtime-transformed Groovy code in IntelliJ? Any tips or tools that help bridge the gap between runtime modifications and IDE debugging would be hugely helpful!
https://intellij-support.jetbrains.com/hc/en-us/community/posts/206635495-Groovy-generated-classes-causing-compilation-issues texttoolz
This is a fascinating deep dive into a really tricky problem! I've also run into the "invisible" closure issue when working with AST transforms, and it's such a pain to debug when the IDE can't see the generated code. If you have some free time, please play Scritchy Scratchy with me.
Fingers crossed for better IDE support in the future, but this at least gives me a path forward. Appreciate you posting the question and the follow-up! Your Daily NYT Pips Solution is Here--pips hint
Interesting issue with Groovy AST transformations and how breakpoints shift due to generated closure classes at runtime. Debugging becomes tricky when source mapping differs from execution. It’s a bit like how different representations, even something like a Wingdings font, can change interpretation. Curious to see how this gets resolved.
This is an interesting Groovy debugging challenge. AST transformations can make breakpoints difficult to manage because the generated closure code often maps to different runtime classes and line numbers. Understanding how Groovy preserves source mappings could help solve this issue. Similar to Toca Boca Mod, having clear visibility into underlying changes makes troubleshooting and customization much easier.