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

2

1

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

Mundy answered 30/6, 2021 at 17:57 Comment(10)
What version of eclipse are you using? It works fine for me with 2019-06 (4.12.0)Impulsion
I'm using the 2021-06. I've just downloaded it from their website.Mundy
I sometimes see this if there are errors in the 'some code', otherwise it works.Heliacal
It unfortunately doesn't change anything if there are errors or not.Mundy
I have 2021-06 too but couldn't reproduce the issue. May be there's something specific to the code after the sysout. Try to add info to your question so it's a MCVE.Beauteous
It only works if the code following the sysout is a variable declaration or the start of an other loop or if statment. If there is sysout, a mathematical expression or anything else, it stops working.Mundy
Unable to reproduce it here with 2021-06. However, much may depend on where the cursor is exactly when pressing ctrl-space. I've been placing the cursor right after the sysout on the same line. It offers 2 suggestions, first is useless does nothing, second says sysout - print to standard out. Placing it inside the sysout characters prompts even more suggestions. Where is your cursor? Do you see the second suggestion about standard out?Nutria
@Mundy Do you get "no proposals" or "sysout - print to standard out"?Nutria
Wherever I put my cursor, it says: "no proposal found". imgur.com/a/AGeHxvqMundy
And even though the line under has no mistakes, it tells me this: Multiple markers at this line - Syntax error on token ".", ; expected - out cannot be resolvedMundy
L
2

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.

Leg answered 6/7, 2021 at 8:6 Comment(1)
Oh wow! sorry for the excessively late reply, but thank you so very much!Mundy
F
0

Could it be the same as here?

(would have added comment, but too little rep)

Fagoting answered 6/7, 2021 at 7:26 Comment(2)
Similar but not the same and not yet fixed. See my answer.Leg
Now, it has also been fixed. See my updated answer.Leg

© 2022 - 2024 — McMap. All rights reserved.