Eclipse content assist fails in loops after upgrade to 2021-06 (4.20.0)
Asked Answered
L

1

6

A similar question was asked here, with no answer yet and less of a code sample. I found and tried the deletion solution for a similar problem, but to no avail.

After recently upgrading Eclipse to version 2021-06 (4.20.0), I noticed the content assist feature (ctrl-space) not working properly in many instances.

import java.util.HashSet;
import java.util.Set;

public class ContentAssist {

    public static void main(final String[] args) {
        final Set<String> storedSet = new HashSet<String>();
        for (int i = 0; i < 500; i++) {

            System.out.println(i);
        }
    }
}

If we now would like to access the storedSet, beginning by typing 's' we see that the out shows up as a compile error:

compilation error

Content Assist comes up short:

Content Assist fail 1

Also when providing more characters:

Content Assist fail 2

Comment out the System.out part and Content Assist once again works:

Content Assist works

Bug in or in front of the PC?

Edit: I just tested this for a fresh install of Eclipse 2021-06 (4.20.0) Build id 20210612-2011 on Windows x86_64, using Eclipse Installer 2021-06 R. Created a new Java project with the code above and the same behaviour occurred.

Luciferin answered 5/7, 2021 at 14:58 Comment(0)
V
8

Unfortunately, that is indeed an issue of Eclipse 2021-06 (4.20) that has already been fixed in Eclipse 2021-09 (4.21) (released on September 15, 2021):

Eclipse bug 574338 - [content assist] [regression] no content assist for variables in conditional blocks

Please note, there is a similar bug that has not yet been fixed. As workaround you can add a ; after the location where to use the content assist.

Victualage answered 6/7, 2021 at 7:1 Comment(7)
Typing "sysou" and hitting ctrl+space is so second nature to me that this not getting fixed until September is quite annoying.Hann
@GregNoe I therefore switched to the first milestone of 2021-06 which looks stable to me: eclipse.org/downloads/packages/release/2021-09/m1Victualage
unfortunately 2021-09 still has this bug. eclipse pushes itself into irrelevance more and more...Stateroom
@Stateroom This bug has been fixed in Eclipse 2021-09 (4.21) for sure. You can be verify this with the example given in this question. For known content assist issues of Eclipse 4.21 see here. Parts of Eclipse are used in many other software, including all other Java IDEs.Victualage
@Victualage I've made a comment to the bug with a screenshot clearly showing that it is not fixed: please have a look.Stateroom
@Stateroom You talking about a different bug that is not yet fixed. In 4.20 a major change has made how to handle incomplete code. Unfortunately, this has caused some bugs. Most of these issues (including the one this question is about) have been fixed in 4.21, but there are still some left. Do you have the skills to provide a patch for one of those?Victualage
@Victualage as I mentioned in the bug comments, from user perspective these 2 issues are the same: you write a loop and inside the loop code-completion does not work. Both of them also happens to match the name of this question "content assist fails in loops". Let's continue the discussion on eclipse bugzilla as it stops to be relevant to SO :)Stateroom

© 2022 - 2024 — McMap. All rights reserved.