Reply to IDEABKL-7249

Hi

I can't seem to be able to comment on the bug report I opened
https://youtrack.jetbrains.com/issue/IDEABKL-7249
Probably because I don't have comment priviliges in the project IDEABKL, where it was moved to lately.

So I thought I'd reply here. Hope to reach out to @Egor Ushakov

First of all thanks for your reply.

I can't see any harm in adding a condition in order to break the recursion (sort of an infinite loop, btw) in the very specific scenario where a variable has a field whose value is `this`.

I'll try to explain myself with code.
https://gist.github.com/alb-i986/dcdc682c9239457ffa5e#file-varinspector-java

This program prints the following output:

VarInspector$SelfObj@7440e464
   selfField: VarInspector$SelfObj@7440e464
   integerField: 1
   VarInspector$NonSelfObj@78308db1
      numField: 2

As you can see, the self reference is printed only once.
Yet, everything is printed correctly.

So, translating the concept into IDEA's GUI, it should read more or less like this:

def drawVar(var):

  drawExpandable(var);

  for
(Field field : fields) {

    [...]

    Object fieldValue = field.get(var);
    // break the recursion if var has a field whose value is `this`
    if
(fieldValue == var) {
        drawNotExpandable(field, var);
        continue;
    }
    
    drawVar(fieldValue); // recursive call
  }
}
3 comments
Comment actions Permalink

Hi,

There are no problems with the implementation of this, the problems I see are in the usability of the solution.
It is clear now if a field has subfields (from the expandable/not expandable node state) and if user needs to know field value - he can simply expand the node and see.
I do not see a way (for now) how to show recursion refs with not expandable state of the node and not loose this ability.



Attachment(s):
2.png
1.png
0
Comment actions Permalink

also commenting in backlog project should be possible now, sorry

0
Comment actions Permalink

Hi Egor

> I do not see a way (for now) how to show recursion refs with not expandable state of the node and not loose this ability.

Your screenshot #2 with the special "recursive" icon looks good to me.
Maybe, as a further feedback to the user, the text next to the recursive icon could say "m = this" instead of "m=SelfRef@450".

In terms of your concern about losing the ability to expand a recursive object, well that's exactly the idea: to lose it. I may be wrong but I can't think of a scenario where one would want to (infinitely) expand. Any subsequent expansion after the first doesn't provide any added value, does it?

But it's certainly important to give feedback to the user, so that he/she knows why the object is not expandable. So, different icon, "this" as the value, maybe even a popup on hovering that says "this item is not expandable because it's a self reference", are all welcome.

0

Please sign in to leave a comment.