Bug 468561 - [search] Call Hierarchy stops searching in doubly-nested lambda chain
Summary: [search] Call Hierarchy stops searching in doubly-nested lambda chain
Status: CLOSED DUPLICATE of bug 533524
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.4.1   Edit
Hardware: PC Windows 7
: P3 normal with 7 votes (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact: Vikas Chandra CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-05-27 22:36 EDT by AndyFang CLA
Modified: 2022-04-13 12:03 EDT (History)
12 users (show)

See Also:


Attachments
the NG capture (99.47 KB, image/png)
2015-05-27 22:36 EDT, AndyFang CLA
no flags Details
workaround (1.83 KB, patch)
2019-12-10 00:41 EST, Vikas Chandra CLA
no flags Details | Diff
examples (5.83 KB, application/octet-stream)
2019-12-12 00:48 EST, Vikas Chandra CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description AndyFang CLA 2015-05-27 22:36:25 EDT
Created attachment 253874 [details]
the NG capture

Here is my sample java code:

------------------------------------
public class Test {

    public static void main(String[] args) {
        methodDepth0(
            ()->
                methodDepth1(
                    ()->
                        methodDepth2()
                )
        );
    }

    static Object methodDepth2() {
        return null;
    }

    interface MyIF {
        void call();
    }

    static void methodDepth0(MyIF myIf){
        myIf.call();
    }

    interface MyIF2 {
        void call();
    }

    static void methodDepth1(MyIF2 myIf2){
        myIf2.call();
    }
}
------------------------------------

When I open call hierarchy of method methodDepth2() from Eclipse(4.4), open call hierarchy stop searching next caller: open call hierarchy stop searching next caller method

What I expect is like opening call hierarchy of method methodDepth1() which show until the main method. 

* Here is the same discussion on StackOverflow with more captures:

http://stackoverflow.com/questions/30254458/eclipse-open-call-hierarchy-stop-searching-in-lambda-chain
Comment 1 Stephan Herrmann CLA 2015-05-28 09:17:14 EDT
Thanks for the report.

My initial intuition was, that JDT/UI may create a bogus search for the nested element, but it could of course also be JDT/Core that fails to properly answer this search.
Comment 2 Markus Keller CLA 2015-06-02 15:40:14 EDT
The problem is in JDT Core.

Debugging hints:
- it's much easier to investigate if you rename the methods to unique names, e.g. call1 and call2
- in the Call Hierarchy view, you can right-click a node and choose Refresh

The missing result for references to the inner lambda can be seen in PatternLocator#resolveLevelForType(char[], TypeBinding): In this case, the qualifiedPattern is "Test.*.*", which doesn't match "Test.MyIF2".

I have a fix candidate in SearchPattern#enclosingTypeNames(IType).
Comment 3 Eclipse Genie CLA 2015-06-02 15:40:49 EDT
New Gerrit change created: https://git.eclipse.org/r/49247
Comment 4 AndyFang CLA 2015-06-03 23:07:28 EDT
Hi, with this Gerrit: https://git.eclipse.org/r/49247 

I can see 2 problems:

1)
Same Functional Interfaces method names were showed in call hierarchy.

2)
Not work when Functional Interfaces were defined in other package

* Here is the eclipse captures for explanation:

http://i.stack.imgur.com/xGm91.png
Comment 5 Manoj N Palat CLA 2018-05-16 01:38:46 EDT
Bulk move out of 4.8
Comment 6 AndyFang CLA 2018-05-16 01:43:36 EDT
Eclipse is dead:(
Comment 7 Stephan Herrmann CLA 2018-05-16 14:38:27 EDT
(In reply to AndyFang from comment #6)
> Eclipse is dead:(

Sorry this bug was left unattended. The assignee had meanwhile left the team.
Comment 8 Stephan Herrmann CLA 2019-03-12 06:41:19 EDT
Tentatively putting this on the radar for 4.12 since Markus did provide a gerrit. This just fell between the cracks when Markus left the team.
Comment 9 Stephan Herrmann CLA 2019-05-19 13:18:06 EDT
Not as easy as I'd hoped, since we don't yet have a JUnit.
Comment 10 Axel Uhl CLA 2019-07-17 16:14:03 EDT
Any progress here? This is really a pressing issue for us with functional styles becoming more prevalent in current Java code, rendering the Eclipse call hierarchy increasingly unreliable.
Comment 11 Vikas Chandra CLA 2019-12-10 00:41:14 EST
Created attachment 281178 [details]
workaround
Comment 12 Stephan Herrmann CLA 2019-12-10 17:09:05 EST
(In reply to Vikas Chandra from comment #11)
> Created attachment 281178 [details]
> workaround

Yes, quite likely we need some traversal to parent like this.

Did you try https://git.eclipse.org/r/49247 ? Can you argue which is better?
Comment 13 Vikas Chandra CLA 2019-12-12 00:48:23 EST
Created attachment 281206 [details]
examples
Comment 14 Vikas Chandra CLA 2019-12-12 00:52:05 EST
(In reply to Stephan Herrmann from comment #12)
> (In reply to Vikas Chandra from comment #11)
> > Created attachment 281178 [details]
> > workaround
> 
> Yes, quite likely we need some traversal to parent like this.
> 
> Did you try https://git.eclipse.org/r/49247 ? Can you argue which is better?

This gerrit ( if we move this to current code base) doesn't work for this case here
https://stackoverflow.com/questions/55087055/eclipse-call-hierarchy-lambda
Also it has couple of issues mentioned earlier on this bug ( didnt try them yet)

Even this is a "workaround" as of now. I am investigating further. If I have a reviewable patch, I will post as a gerrit.
Comment 15 Corneliud Dirmeier CLA 2020-11-03 12:17:04 EST
I think it's an interesting fact that both (this example and the one from https://stackoverflow.com/questions/55087055/eclipse-call-hierarchy-lambda) work correctly when I convert the lambda into an anonymous class. Is it possible to handle lambdas in call hierarchy similar to anonymous types?
Comment 16 Henrik Hegardt CLA 2020-12-01 03:14:09 EST
Any progress on this? In async heavy code this bug is causing so much trouble and renders the call hierarchy feature unusable.
Comment 17 Andrey Loskutov CLA 2022-04-13 12:03:37 EDT
Fixed via 533524.

*** This bug has been marked as a duplicate of bug 533524 ***