Content assist cannot find proposals in "loop" if there is code below

198 Views Asked by At

I had some problems with content assist this morning and decided to update eclipse. Unfortunately, that did not fix the issue, but I eventually managed to fix it. After some time though, another issue arose and I decided to completely reinstall eclipse this time, but to no avail.

Now, whenever I'm in a loop (doesn't matter which), I cannot use content assist if more code follows below. Let me give you an example.

If I use ctrl-space after this sysout, it will work,

while (true) {
    sysout
}

but if I use ctrl-space for this sysout, it will tell me that no proposals were found.

while (true) {
    sysout
    (Some code) //Can be a sysout, a mathematical expression or pretty much anything else. It will only work if the following code is another loop, an if statement or a variable declaration.
}

I've even used another workspace on this clean version of eclipse and it still doesn't work. Any help would be greatly appreciated!

Edit: The same issue appears in an if statement as well. It looks like anything that has a condition breaks my content assist

2

There are 2 best solutions below

1
howlger On BEST ANSWER

Unfortunately, that is indeed an issue of Eclipse 2021-06 (4.20) that happens inside conditions and loops when there is trailing code not separated by a semicolon ; (similar but not the same as in this question).

Example:

class Sample {
    void sample(String foo) {
        if (foo != null) {
            sys // content assist here
            System.out.println();
        }
    }
}

I created the minimal reproducible example above and reported it here for you:

Eclipse bug 574267 - [content assist] [regression] No content assist for templates in conditional blocks

As workaround you can add a ; after the location where to use the content assist.

Update:

After less than 4 hours after reporting a reproducible example, the issue has been fixed. So, as an alternative to the above mentioned workaround, you can wait for the upcoming release Eclipse 2021-09 (4.21) on September 15, 2021 or at least for the first milestone build of it on July 16, 2021.

2
ramundsen On

Could it be the same as here?

(would have added comment, but too little rep)