Groovy field watchpoints new / old values in condition

Answered

In the condition for a Groovy field watchpoint, how can I get the new value and/or the old value?

I assume the value of the field will be the old value, but, since there is no explicit setter, the code doesn't explicitly include a method parameter name for the new value.

Maybe Groovy creates a method parameter with a specific name, but I don't use Groovy, so I don't know if it does.  (I'm trying to debug third-party Groovy code).

0
12 comments

According to the responsible developer it's not supported for Groovy and is unlikely to be possible to support at all.

0

Thanks for info. Does IntelliJ use the old or new value of the field in the watch point condition?

0

Depends on how you write the condition, you can use both:

0

Are you saying that `this.property` is the old value, and `property` is the new value?

If so, then that's what I wanted.

0

This is how it works for Java code with getters and setters, but it's not supported for Groovy.

0

That makes sense. Would opening up a ticket in the Groovy issue system for support for this make sense? If so, could someone from the JetBrains debugger and/or groovy team submit it? I assume they’d know the correct wording for such an issue. If submitted, let me know what issue it is and I’ll vote for it. Thanks

0

I was looking for how to do this in Java and stumbled across this...

It doesn't seem to work as advertised.  Namely, using "hello" seems to get the old value as well.  Is there a way to get the new value?

0

Please share the sample project to reproduce with the screenshots of the conditions you are using: https://uploads.jetbrains.com.

0

Having trouble uploading so will just copy/paste steps to create it:

  1. new java project, no template no libraries
  2. create one java file which looks something like this
    class Main {
    int w;
    int x;
    int y;
    int z;

    public static void main(String... args) {
    new Main().w = 9;
    new Main().x = 9;
    new Main().y = 9;
    new Main().z = 9;
    }
    }
  3. Create watchpoints on all 4 fields, with the following conditions: w==9, this.x==9, y==0, this.z==0.
  4. Observe that only the last two ever get triggered.

Alternatively don't bother with new project and use IntelliJ's lovely scratch file feature.

0

voted, thanks!

0

Please sign in to leave a comment.