Community
Participate
Working Groups
Created attachment 263316 [details] call hierarchy import java.util.Arrays; import java.util.List; public class EclipseLambdaProblem { private void bar() { System.out.println(this); } public static void main(String[] args) { List<EclipseLambdaProblem> problems = Arrays.asList(new EclipseLambdaProblem()); problems.forEach(p -> p.bar()); } } Call hierarchy on bar method correctly shows usage in accept, and for accept there is no usage shown. This issue was already present in mars.
Thanks, I can reproduce. Interestingly, when placing the cursor on the arrow (->) Call Hierarchy correctly shows lots of callers of accept(). From this it seems not to be a search issue per se, but a matter of what seed you use for search. Moving to JDT/UI for investigation / comments.
org.eclipse.jdt.internal.corext.callhierarchy.CallerMethodWrapper.findChildren(IProgressMonitor progressMonitor) invokes SearchEngine to find the children of the current IMember. In case of comment #0, the IMember is LambdaMethod: accept(EclipseLambdaProblem) (not open) [in <lambda #1> [in main(String[]) [in EclipseLambdaProblem... The case where call hierarchy is invoked on "->" (comment #1) is different, where the IMember is ResolvedBinaryMethod (obtained from text selection via ICodeAssist.codeSelect): void accept(T) {key=Ljava/util/function/Consumer<LEclipseLambdaProblem;>;.accept(LEclipseLambdaProblem;)V} [in Consumer [in Consumer.class... Seeding with LambdaMethod, which is obtained as the caller of #bar in the first step from SearchMatch.getElement() in MethodReferencesSearchRequestor, looks fine. The SearchEngine does not return any result for accept(EclipseLambdaProblem) when LambdaMethod is used. The problem could be with the details in LambdaMethod (compared to ResolvedBinaryMethod), or while creating the SearchPattern with LambdaMethod in SearchPattern#createPattern, or later in SearchEngine#search while using that SearchPattern. Moving back to JDT/Core for further comments.
I'm more concerned with the fact that there's no way to get from bar to main in the call hierarchy. When dealing with lambdas I almost always want to know who calls the method that contains the lambda (just like anonymous classes), not what other callers of the lambda exist.
(In reply to Sam Davis from comment #3) > I'm more concerned with the fact that there's no way to get from bar to main > in the call hierarchy. When dealing with lambdas I almost always want to > know who calls the method that contains the lambda (just like anonymous > classes), not what other callers of the lambda exist. That would be a separate request. "containing" a lambda expression doesn't count as a call, strictly speaking. What you are looking for seems to be an analogy to the constructor invocations node of an anonymous class.
Yes, that is what I want. Since lambdas are basically just syntactic sugar for anonymous classes I expected this would work. Not having this makes the call hierarchy much less useful for Java 8 code. Should I open a separate bug?
(In reply to Sam Davis from comment #5) > Should I open a separate bug? I'd say so. Yes, please.
See bug 533524.
Bulk move out of 4.9
See also https://stackoverflow.com/questions/55087055/eclipse-call-hierarchy-lambda
Created attachment 288998 [details] Call hierarchy with reproduction snippet in Eclipse 4.27.
Seems to work with Eclipse 4.27.