Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 768
ramundsen Avatar asked Jul 05 '21 14:07

ramundsen


People also ask

How do I fix Content Assist in Eclipse?

Solution. Go to Window -> Preferences -> Editor -> Content Assist -> Advanced and enable Parsing-based Proposals. Click Apply. Content assist should start working immediately.

How do I enable Content Assist in Eclipse?

To enable the Content Assist window to open automatically, go to the Content Assist Preferences page, accessed from Window | Preferences | PHP | Editor | Content Assist and mark the 'Enable auto-activation' checkbox.

How do I automatically update eclipse?

Always enable major upgradesEnable the Latest Eclipse release https://download.eclipse.org/releases/latest repository by ticking the checkbox. Apply and Close. Check for updates.


1 Answers

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.

like image 172
howlger Avatar answered Oct 08 '22 16:10

howlger