Community
Participate
Working Groups
When trying to use chain proposals for method arguments which are inside lambda expressions the chains proposals are not shown. In the below example the cursor positions are denoted by | character. Example: package test.module; import java.util.Collections; import java.util.Iterator; import java.util.List; public class TestApp { private X x; private <E> void print(Iterator<E> iterator) { // doesn't shows chain proposals iterator.forEachRemaining(e -> System.out.println(|)); this.load(|); // shows chain proposals System.out.println(|); // shows chain proposals List<String> strings = |; // shows chain proposals } public List<String> findAll() { return load(Collections.EMPTY_LIST); } public List<String> load(List<Long> ids) { return null; } private class X { public List<String> names; public List<Long> ids; public String message; } }
Hi Gayan. Thanks for the extensive test class. That is really helpful. However, using Photon M4 (to make sure I use the latest version of Eclipse JDT), I cannot get chain proposals in even the simple, non-lambda System.out.println(|); case: > System.out.println(|); // shows chain proposals This doesn't work for me. Debugging shows that Eclipse's JavaContentAssistInvocationContext.getExpectedType() returns null, i.e., JDT doesn't know what type is expected in this case. That being said, if I change the lambda to iterator.forEachRemaining(e -> this.load(|)); then I don't get chain proposals either, even though I get them for the this.load(|) call outside the lambda. Looks like a JDT problem to me. Will report this upstream.
(In reply to Andreas Sewe from comment #1) > Looks like a JDT problem to me. Will report this upstream. Spoke too soon. While IRecommendersCompletionContext.getExpectedType() indeed finds nothing for System.out.println(|); IRecommendersCompletionContext.getExpectedTypeNames() finds int, boolean, Object, etc. And that is indeed different between the inside-lambda (getExpectedTypeNames() returns null) and outside-lambda cases. @Gayan: What call chains do you see for System.out.println(|)?
(In reply to Andreas Sewe from comment #2) > Spoke too soon. While IRecommendersCompletionContext.getExpectedType() > indeed finds nothing for System.out.println(|); > IRecommendersCompletionContext.getExpectedTypeNames() finds int, boolean, > Object, etc. And that is indeed different between the inside-lambda > (getExpectedTypeNames() returns null) and outside-lambda cases. In the outside-lambda case System.out.println(|); is a CompletionOnMessageSend (as our ExpectedTypeNamesContextFunction.isArgumentCompletion(ASTNode) exepcts). But in the inside-lambda case, iterator.forEachRemaining(e -> System.out.println(|)); it is a CompletionOnSingleNameReference, which we don't recognize as argument completion.
@Gayan: Reducing severity to normal. Critical would mean that Code Recommenders becomes almost unusable. Not having chain completion in a few places is far from that.
(In reply to Andreas Sewe from comment #4) > @Gayan: Reducing severity to normal. Critical would mean that Code > Recommenders becomes almost unusable. Not having chain completion in a few > places is far from that. Yes thats ok with me, I looked a bit inside the code and found the same findings you did. I will debug photon and see why its not working for normal scenario as well.
(In reply to Gayan Perera from comment #5) > (In reply to Andreas Sewe from comment #4) > > @Gayan: Reducing severity to normal. Critical would mean that Code > > Recommenders becomes almost unusable. Not having chain completion in a few > > places is far from that. > > Yes thats ok with me, I looked a bit inside the code and found the same > findings you did. I will debug photon and see why its not working for normal > scenario as well. Thanks for the help. If you need any help with building and debugging Code Recommenders beyond [1], please let us know on the recommenders-dev mailing list [2]. [1] <https://git.eclipse.org/c/recommenders/org.eclipse.recommenders.git/about/> [2] <https://accounts.eclipse.org/mailing-list/recommenders-dev>