Summary: | [call hierarchy] call hierarchy should show lambdas | ||||||
---|---|---|---|---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Sam Davis <sam.davis> | ||||
Component: | UI | Assignee: | Zsombor G <gzsombor> | ||||
Status: | RESOLVED FIXED | QA Contact: | |||||
Severity: | enhancement | ||||||
Priority: | P3 | CC: | arend, daniel_megert, gzsombor, javaeecoding, jfrantzius, loskutov, max.bureck, noopur_gupta, stephan.herrmann, steve | ||||
Version: | 4.8 | Keywords: | noteworthy | ||||
Target Milestone: | 4.22 M2 | ||||||
Hardware: | All | ||||||
OS: | All | ||||||
See Also: |
https://bugs.eclipse.org/bugs/show_bug.cgi?id=498498 https://git.eclipse.org/r/c/jdt/eclipse.jdt.ui/+/185428 https://bugs.eclipse.org/bugs/show_bug.cgi?id=576619 https://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=9063fc899516a5f3d27eb495c9b19b03ac20e325 https://git.eclipse.org/r/c/www.eclipse.org/eclipse/news/+/186625 https://git.eclipse.org/c/www.eclipse.org/eclipse/news.git/commit/?id=4b8a232a8db07c57b4b5196dbacd68cfeb629444 |
||||||
Whiteboard: | |||||||
Attachments: |
|
Description
Sam Davis
2018-04-12 16:25:56 EDT
One issue is: how do we name that node? In the other bug I mentioned constructor invocations (for anonymous) as an analogy, but obviously, a lambda has no constructor. If a lambda is defined within a method, then s.t. like "declaring method" could perhaps be used. Lambdas in (field,instance,static) initializers have no interesting incoming flow in this regard, do they? As a downside, all lambda expressions would have two intermediate nodes with little information added: () -> {} + [declaring method] foo() + [callers] Just saying. I contend that in at least 90% of cases the user is only interested in the [declaring method] node and not the callers of the lambda. Lambda's are normally used for interfaces like Function which have thousands of implementations and are used all over the place, so seeing the list of all callers is not useful at all.
> If a lambda is defined within a method, then s.t. like "declaring method" could
> perhaps be used. Lambdas in (field,instance,static) initializers have no
> interesting incoming flow in this regard, do they?
That's right. It would very useful if the call hierarchy could show relationships other than just method calls, e.g. if a lambda (or just a method call) is used in an instance or field initializer, it could show calls to the declaring class's constructor, but that is out of scope of this bug.
*** Bug 575985 has been marked as a duplicate of this bug. *** Created attachment 287293 [details] Slightly modified patch shows [declaration] matches for lambdas Screenshot for slightly changed patch: https://git.eclipse.org/r/c/jdt/eclipse.jdt.ui/+/185428 Instead of "[declaring method]" use [declaration], to avoid confusion on fields etc? WDYT? Beside this, I found this patch very useful, I would like to merge that ASAP :-). (In reply to Andrey Loskutov from comment #4) > Created attachment 287293 [details] Here is the corresponding snippet to try: import java.util.List; import java.util.function.Function; public class Snippet { static Function<? super String, ? extends String> mapper1 = y -> transform(y); Function<? super String, ? extends String> mapper2 = y -> transform(y); static { mapper1 = y -> transform(y); } public Snippet() { mapper2 = y -> transform(y); } public static void main(String[] args) { mapper1 = y -> transform(y); } Object[] funcCall() { return List.of("aaa").stream().map(y -> transform(y)).toArray(); } static String transform(String s) { return s.toUpperCase(); } } Anyone has any objections for merge? With no feedback here or on the patch I plan to merge proposed patch today evening CET. Thanks, Zsombor and Andrey for the patch. Looks good and can be merged for further feedback. Gerrit change https://git.eclipse.org/r/c/jdt/eclipse.jdt.ui/+/185428 was merged to [master]. Commit: http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=9063fc899516a5f3d27eb495c9b19b03ac20e325 Build I20211014-1800 contains the patch, I've verified it works as proposed. Please test & provide feedback, ideally before next week M2. See https://download.eclipse.org/eclipse/downloads/drops4/I20211014-1800/ @Zsombor: would you please prepare N&N entry? Repo is https://git.eclipse.org/r/www.eclipse.org/eclipse/news.git (In reply to Andrey Loskutov from comment #9) > @Zsombor: would you please prepare N&N entry? ping. I hope, this makes sense: https://git.eclipse.org/r/c/www.eclipse.org/eclipse/news/+/186625/1 Gerrit change https://git.eclipse.org/r/c/www.eclipse.org/eclipse/news/+/186625 was merged to [master]. Commit: http://git.eclipse.org/c/www.eclipse.org/eclipse/news.git/commit/?id=4b8a232a8db07c57b4b5196dbacd68cfeb629444 (In reply to Zsombor from comment #11) > I hope, this makes sense: > https://git.eclipse.org/r/c/www.eclipse.org/eclipse/news/+/186625/1 Yes, it does :-) Many thanks! *** Bug 468561 has been marked as a duplicate of this bug. *** |