Telling the intellij debugger to re-position break-point information
已回答
I have this code transformation of a .groovy file using AST transformations.
@AddExtraParam
def func1() {
someRandomFunction()
}
def func2() {
func1()
}
is converted to
@AddExtraParam
def func1(MyCustomInjectedParam _custom) {
injectCodeToSomethingWith(_custom)
someRandomFunction()
}
def func2() {
func2(new MyCustomInjectedParam())
}
This will compile fine with my ASTTransformation for AddExtraParam. But now if I set a breakpoint in intellij inside func1, it will not hit because the signature has changed. However if I place my breakpoint inside func2, it will hit and everything will work as expected as far as debugging goes
The question I have is this
I just want to tell IDEA that my breakpoint is at a different spot in a different function. How do I do this?
请先登录再写评论。
It should work out of the box as long as line numbers are correct. Please check generated `LineNumberTable` in compiled class file.
Daniil,
You are absolutely right. Thank you for the response. I figured out what is happening but am at a loss for how to fix it.
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?
Do I need to extend the GroovyPositionManager to help it understand that the breakpoint is really pointing to a different class file? Can you point me to the code that does this today for closures in the groovy plugin?
I moved this to a separate thread.
https://intellij-support.jetbrains.com/hc/en-us/community/posts/360003169920-Debugging-groovy-closure-using-ASTTransformations