I think 5 years has passed since Lambda has been released for Java.
public static void main(String[] args) {
go();
}
private static void go() {
Set<String> set = new HashSet<>();
set.stream().forEach((s) -> {
inner(s);
});
}
private static void inner(String s) {
inner1(s);
}
private static void inner1(String s) {
}
When I press CTRL-ALT-H - (open call hierarchy) on inner1
method, I expect to see a whole stack trace from in inner1
to main
method. Instead, my staktrace is trimmed on inner
method. I've just downloaded the newest Eclipse, I think it 2018-12, previously I was using Mars.
Intellij can show me the expected call-hierarchy, and I don't really understand why Eclipse still can't do it. Not sure if anyone else is using Eclipse in 2019, but maybe you can advise a plugin or something.
Switching to Intellij is not an option, I tried couple of times, but the habit is hard to overcome.
UPDATE
There is similar - SO question
At run time, evaluation of a lambda expression is similar to evaluation of a class instance creation expression, insofar as normal completion produces a reference to an object. Evaluation of a lambda expression is distinct from execution of the lambda body.
and
Just note, that for lambdas implementing library types like Consumer, the number of callers into accept(T) in a workspace may easily become unmanageable, similar to any call hierarchy through, e.g, Runnable.run() - but that doesn't question the general usefulness of call hierarchies through lambdas.
I don't really care about lambda internals, somehow other IDE is able to show expected stacktrace
There's an existing old bug for eclipse, reported in 2016, still in NEW status
Bug 498498 - [1.8][search][call hierarchy] No usage for lambdas
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.
There are 3 votes to fix it, you can vote too
From your edit's links there's another relevant old bug in NEW status
Bug 468561 - [search]Call Hierarchy stops searching in doubly-nested lambda chain
with 3 votes too...
Eclipse 4.22 (Q4 2021) should help:
Improved lambda support in the Call Hierarchy view
The Call Hierarchy view is enhanced with showing not only the callers of the lambda function, but the callers of the declaring function too.
For the following code:
Checking the callers of the function() will show this:
The
[declaration]
node in the tree is the new addition, which shows the callers of thedefiner()
function, in this case, only themain()
function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With