Structure view depicts structure twice

Issue #2448 resolved
Alan Birchenough created an issue

I’m kinda annoyed with myself because I think I resolved this once before, but I don’t remember exactly what the resolution was. It may have been to do with how the module roots get set up. At any rate, I don’t recall. Can you advise me how to de-duplicate the information in this view? I attach a screenshot by way of an example that shows the problem.

Comments (21)

  1. Alan Birchenough reporter

    Sorry the attachment got included twice. I don’t know how to get rid of one of them now. Thanks.

  2. Scott Wells repo owner

    I’ll start with a simple question, but can you confirm that you’re on the latest-and-greatest build of IC2? And of course if you’re not, please update to that and let me know if the problem still occurs. If it does, please use File | Invalidate caches, then restart the IDE and let me know if it’s still there. I can’t imagine that resolving it because the structure view is built off the live class members, but let’s just see if either of those actions helps.

  3. Alan Birchenough reporter

    I upgraded to IC2 2.2.8.7, and ran “Invalidate Caches and Restart” invalidating just the file system cache and local history. It did not resolve the issue.

  4. Scott Wells repo owner

    Yeah, that’s what I expected, but no harm in trying for the simple “fix”. Does this happen in all classes or just specific ones? If all classes, does it happen in all projects as well? If just specific classes, can you create a standalone class (containing no proprietary info) that reproduces the behavior and attach it here?

  5. Alan Birchenough reporter

    I haven’t had a chance to sanitize an example yet, but I can give you some more information which may help:

    1. If I deselect “Show Inherited” in the structure view, I never see the duplicated display.
    2. Immediately after I re-select “Show Inherited”, the display remains singular.
    3. If I then switch to any other editor window, the duplication comes back.

    So it seems that this display bug occurs when refreshing the structure view to catch up with an editor switch (including original file open), but as long as one does not switch files, one can exploit the “Show inherited” setting to suppress the appearance of the duplicated information.

    Also, I can’t yet absolutely give you chapter and verse on when it does or doesn’t happen, except that I believe it happens when viewing any Apex class or trigger. It does not happen when viewing, say, VisualForce.

    I can compile some information for you more systematically if you need that, but in the meantime I thought it might be helpful to get a few more clues right away, even if they aren’t fully characterized.

  6. Alan Birchenough reporter

    Here’s another odd thing:

    1. Start with two editor windows side by side, and with the structure tool window showing (on the left as it happens, in my setup). One of the editor windows has the selection.
    2. De-select “Show Inherited”.
    3. The structure window shows no duplication.
    4. Select the other editor window.
    5. Not only does the duplication appear, but “Show Inherited” has been selected again. Now wherever I go, it remains selected until I de-select it again. Also, the duplication persists while “Show Inherited” is checked.

    Weird.

  7. Alan Birchenough reporter

    I finally got the chance to take a few more minutes to investigate this behavior.

    • It happens with all classes and triggers.
    • It does not happen with any, e.g., VisualForce pages or Javascript.
    • The bizarre behavior surrounding the “Show Inherited” option always accompanies the problem when displaying Apex. However, a subtlety is that “Show Inherited” can work correctly, showing, say, the Object superclass information in Apex, until the editor refresh or switch at which point the inherited flag is set and the duplication occurs.
    • A further subtlety is that, if I am looking at Javascript, and I de-select “Show Inherited”, then switch to Apex, then switch back to Javascript, “Show Inherited” has been switched back on (which is usually not a good thing in LWCs, since the superclasses / inherited prototypes for LWC Javascript are very extensive, and include large chunks of the Aura framework). When I look at the Javascript, it does not have duplicated information in the structure tool, but when I look at the Apex, it does.

    I am not sure what to make of the relationship between the “Show Inherited” behavior and the duplication. They are both defects, but whether they are related seems unproven. I can imagine problem diagnosis being thrown off by assuming incorrectly either that they are, or are not, related.

    To review software versions, I am on IntelliJ Ultimate 2023.2.2, and IC2 2.2.8.7.

  8. Scott Wells repo owner

    Unfortunately I’m still unable to reproduce it even with complex classes and trying to follow your steps:

    One thing that does stand out to me in your screenshot is that it includes the class two different ways, i.e., ClassName.cls and then ClassName. Do you perhaps have duplicate copies of your classes in the project?

  9. Alan Birchenough reporter

    No. You’re seeing separate nodes for the file and class. FFAPayableInvoiceExpenseLineItemHandler.cls is the file (and is accompanied by a path in the structure tool), while `FFAPayableInvoiceExpenseLineItemHandler` is the Apex class right inside the file. It is the class whose display is duplicated.

    However, I do agree that your screenshot looks significantly different from mine, and I don’t know why. In your screenshot there appears to be no node for the file, but the filename instead appears in the top panel, which I don’t even have. Are we talking about the same tool here? I was referring to the Structure Tool, invokable via Cmd+7.

  10. Scott Wells repo owner

    Ah, okay. We are actually not talking about the same thing. I’m showing the structure view using Ctrl/Cmd+F12 and you’re using the Structure View tool window. When I do the latter, I do see the same thing where the file is shown at the top and then the class is shown twice. Now that I’ve reproduced it, I’ll investigate a bit and see why it’s showing the class twice. I know it didn’t in the past, so I’m guessing that something changed in the way that the plugin SDK calls into IC2’s Apex structure view implementation so that it’s querying twice or something.

  11. Scott Wells repo owner

    Yep, there was some behavioral change in the caller of the “inherited members node provider”. I haven’t tracked down when the change was introduced, but originally if that was called with something other than an Apex type declaration, the implementation had to respond with the children of the provided node; now it has to respond with an empty list of children, and evidently the children of the provided node are queried elsewhere for you. That’s why things were duplicated. I’m going to test this quite a bit more to ensure I’m not breaking something by fixing something, but if all goes well, the fix will be in next week’s build.

  12. Alan Birchenough reporter

    Thanks. That’s great news.

    I’m glad we exchanged screenshots. We could have gone on for some time talking past one another. I guess I also ought to take a look at the structure view at Ctrl/Cmd+F12. I don’t think I’ve ever paid it a visit.

  13. Alan Birchenough reporter

    By the way, I am still curious about the expected behavior of “Show Inherited”. Right now it is completely evanescent, in that, when deselected, it only remains that way until the editor is next activated at which point it flips right back to being selected. This could just be the way that it is supposed to behave per IntelliJ guidelines, but to me as a naive user it seems like quite a nuisance that it doesn’t “stick”.

  14. Scott Wells repo owner

    It’s all part of the same bug, and the same fix addresses it. When that’s checked, it should show inherited members; when it’s not, it shouldn’t. And that’s how it works even with the current issue in the pop-up structure view. The issue is with the tool window and how it calls into this plugin extension point (now vs before). If you don’t see the expected/correct behavior consistently starting with next week’s build, definitely let me know, but it should be addressed.

  15. Alan Birchenough reporter

    Perfect. Thanks.

    Now I’ve got a silly IntelliJ question. I seem to be stuck on 2.2.8.8. It says “downloaded” next to it in the plugins list. Perhaps that’s why I can’t ask for an update? What do I do to switch back to having IJ download the updates for me? (I should know this - sorry.)

  16. Scott Wells repo owner

    This is where you configure the IDE to check for plugin updates:

    If that’s already checked, I’d recommend closing all open IC2 projects, uninstalling the IC2 plugin and installing the latest from the plugin repo.

  17. Log in to comment