Community
Participate
Working Groups
Steps to reproduce: - call CA at private void test(String s, int i) { if (i > 2) { System.out.println("a"); } else { s.| // <-- System.out.println("b"); } Eclispe returns "No Default Proposals". The issue can't be reproduced in Eclipse <= 4.20M1. Original issue: https://github.com/eclipse/eclipse.jdt.ls/issues/1800
Which exact Eclipse build was used? Can it be a duplicate of bug 573632?
I was able to reproduce this issue since Eclipse 2021-06 M3 (I20210519-1800) but not with M1. Reproduces even with RC2a though.
(In reply to Andrey Loskutov from comment #1) > Which exact Eclipse build was used? Can it be a duplicate of bug 573632? - https://download.eclipse.org/eclipse/updates/4.20-I-builds/I20210611-1600/ - Eclipse 4.20.RC2 - Eclipse 4.20RC1 - Eclipse 4.20M3 Eclipse 4.20M1 works fine.
Thanks, I see it on 4.21 master too :-( The problem disappears if the line is terminated with semicolon - but of course this is not a valid workaround :-) public class Snippet { private void test(String s, int i) { if (i > 2) { System.out.println("a"); } else { s.| ; // <-- with semicolon works, without: nada! System.out.println("b"); } } } Stephan: could you please check?
(In reply to Andrey Loskutov from comment #4) > Thanks, I see it on 4.21 master too :-( > > The problem disappears if the line is terminated with semicolon - but of > course this is not a valid workaround :-) > > public class Snippet { > private void test(String s, int i) { > if (i > 2) { > System.out.println("a"); > } else { > s.| ; // <-- with semicolon works, without: nada! > System.out.println("b"); > } > } > } > > Stephan: could you please check? This seems to be happening as a result of commit https://bugs.eclipse.org/bugs/show_bug.cgi?id=539685#c41 Stephan, can you please look at this?
Similar to bug 573632 indeed. The fix from bug 573632 does not trigger, because the connection between the element on the expression stack ("i > 2") and the if-else statement can no longer be established. The 'if' statement is removed from the element stack as soon as '}' terminates the then-block. I could try to add sophistication to the fix of bug 573632, but that would introduce some complexity while fixing issues only if no lambda is "in sight". As long as there is no help along the lines of bug 573632 we don't set a synthetic EOF, hence the code is parsed as: private void test(String s, int i) { { <CompleteOnType:s.> System; } } There is a strange bias towards interpreting a "stray" identifier as the beginning of a variable declaration. I believe this is where the parser needs more smarts.
New Gerrit change created: https://git.eclipse.org/r/c/jdt/eclipse.jdt.core/+/182070
Stephan, Assigning this to you as you are working on this one.
(In reply to Sravan Kumar Lakkimsetti from comment #8) > Stephan, > > Assigning this to you as you are working on this one. Sure. (In reply to Eclipse Genie from comment #7) > New Gerrit change created: > https://git.eclipse.org/r/c/jdt/eclipse.jdt.core/+/182070 I decided that the parser is already jumping through hoops more than desirable, it doesn't really have the means to decide if "s." should refer to a type or a variable. Ergo I moved on to letting the CompletionEngine try more things: If "s" actually resolves to a variable, offer all available members of the variable's type. But don't try this within method signatures (see testBug574215_type_not_field()). There may be more situations that I haven't checked for the theoretical chance to propose things of the wrong kind, but I doubt that those cases - if existent - would be relevant in practice. As an advantage of moving this work into the engine (at a point where the AST is already resolved) we are now able to support this kind of completion even inside lambdas (as opposed to the emergency fix in bug 573632 that only restored old, pre-lambda behavior).
Gerrit change https://git.eclipse.org/r/c/jdt/eclipse.jdt.core/+/182070 was merged to [master]. Commit: http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=dcdb41213d2a0c255037b790a64514a84fade08e
(In reply to Eclipse Genie from comment #10) > Gerrit change https://git.eclipse.org/r/c/jdt/eclipse.jdt.core/+/182070 was > merged to [master]. > Commit: > http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/ > ?id=dcdb41213d2a0c255037b790a64514a84fade08e Released for 4.21 M1
I still see missing content assist with the following snippet in Version: 2021-09 (4.21) Build id: I20210617-1800 public class Snippet { private boolean flag; private void test(List<String> c) { if (flag) { | // content assist here List<String> scs = c.subList(0, 1); } } String test() { return null; } } Content assist only offers the type Snippet, not test() or c. Is that related to this issue or separate?
reopening to be sure, I think the mailing failed for my previous comment
Yeah I confirmed this is still borked (we picked the latest I-Build in jdt.ls) public void name(String fooo) { if (fooo != null) { fo| <-fooo is not proposed here System.err.println("Done"); } }
I don't see an 'else' in either comment 12 nor comment 14, so it definitely is not the same bug :) Also this bug and it's predecessor bug 573632 were about completing after a dot. Since no dot is in the picture in your examples either, please file a new bug.
Verified for 4.21 M1 using build I20210706-1800
For posterity: this fix was superseded by part of the fix in bug 575631 (4.22 M2).