Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 496821

Summary: call hierarchy for static methods is broken, sometimes
Product: [Eclipse Project] JDT Reporter: Jilles van Gurp <incoming>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: andreaslmmr, gautier.desaintmartinlacaze, jarthana, manoj.palat, simeon.danailov.andreev, stephan.herrmann
Version: 4.7   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS X   
Whiteboard: stalebug

Description Jilles van Gurp CLA 2016-06-27 07:02:13 EDT
public static Contact from(JsonObject c) {
        if(c==null) {
            throw new IllegalStateException("json is empty");
        }
        return new Contact(c);
    }

    public Contact deepClone() {
        return Contact.from(getJsonObject().deepClone());
    }

In this bit of code, the call hierarchy for the from method in both eclipse Neon (osx, just updated this morning) and Mars shows no results. This is incorrect, the method in question is in fact used in many dozens of places in the same project and even in the same class. 

I can see the call hierarchy is working for some static methods in the same project but never for this one. This particular class is implementing several interfaces, with default methods. But aside from that I can't see anything that is special about this class. I've observed the same problem in several other places. The method has loads of similarly named static methods in other classes (it's a pattern we use a lot). I've also seen rename functionality on static methods being a bit wonky; possibly for the same reason. Sometimes it works, sometimes it doesn't.

I've been trying to create a test case for this but can't reproduce this outside of our project: it always fails on this method in this project and loads of other static methods but not all. This means it is somehow related to this project. Some kind of combination of stuff is causing call hierarchy to go wonky here. I've seen similar issues closed with a worksforme, including e.g. #433462. So, I'd thought I at least report that something is going on here. 

I'd be happy to assist debugging if needed.
Comment 1 Stephan Herrmann CLA 2016-06-28 06:54:25 EDT
call hierarchy internally uses search for finding callers, so it would be interesting to see if search for references (Ctrl+Shift+G) works for the method in question. If it doesn't I could think of an inconsistent index as the cause, so: does the problem remain after Project > Clean ... ?

Sure a reproducing example would make a huge difference here.
So if recreating the problem in a small problem was not successful, it would be could if you could go the opposite direction: create a full copy of your project, and try removing stuff until the problem disappears.

Alternatively, would you be willing to create a JDT development workspace (e.g., using Oomph) and connect a debugger to the Eclipse instance where the bug occurs? If so, I could send further hints.
Comment 2 Jilles van Gurp CLA 2016-11-30 07:23:41 EST
Sorry for my slow response. This is still broken for me in the latest Neon. I've actually completely rebuilt my workspace so that was not it. Cleaning or refreshing eclipse doesn't work either.

However, I stumbled on a work around that may point to a solution.

If I go to filters -> search in, and disable Application Libraries, it works. As soon as I renable that, it breaks again.

Given the comment by Stephan Herman, I suspect the issue is that including Application Libraries generates so many intermediate but invalid results that it just stops searching before finding any valid results. Find references in workspace definitely finds a ton of stuff. I've no idea how this is implemented but I'd suggest never dropping any results coming project sources and treating the other 3 as nice to have but optional. 99% of the time I use this I couldn't care less about anything but my own code in the same project.

BTW. In my search on Google on this issue, most links seem to land me to stackoverflow where apparently a lot of people are struggling with this. Search for "eclipse call hierarchy not working static" produces several examples of this. 

Given that and the number of issues related to this that are either still in the new state or closed as won't fix or can't reproduce in the issue tracker, there definitely seem to be many open issues with call hierarchy that are possibly/likely. Maybe a good idea to track these in one issue to gather information?

If helpful, I can try attaching a debugger or output some logs. I don't really use oomph and would prefer not to wipe out my workspace.
Comment 3 Jay Arthanareeswaran CLA 2016-12-04 23:36:32 EST
Copying Manoj for comments, as he is our expert on search.
Comment 4 Andreas Lemmer CLA 2019-07-04 11:14:32 EDT
Also broken in 2019-06, but it seemed to work in 2019-03. Not easy to provide a minimal example, because it seems to work for small projects.
Comment 5 Stephan Herrmann CLA 2019-07-04 11:19:51 EDT
(In reply to Andreas Lemmer from comment #4)
> Also broken in 2019-06, but it seemed to work in 2019-03. Not easy to
> provide a minimal example, because it seems to work for small projects.

please see comment 1
Comment 6 Eclipse Genie CLA 2021-06-24 14:46:54 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 7 Simeon Andreev CLA 2023-03-14 06:32:18 EDT
Not much to be done without a snippet here, closing.