eclipse-jdt / eclipse-jdt/eclipse.jdt.core

Eclipse 2022-09 Content Assist provides wrong order for lambdas with partial function name

Open
#395 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
237
Forks
195
Avg merge
1d 10h
Merged PRs (30d)
49

Description

Today I installed Eclipse EE 2022-09 on Windows. I'm using Java 17. I have `Collectors.*` statically imported:

```java
import static java.util.stream.Collectors.*;
```
I have a `Stream>` and I'm trying to collect the map entries into a `Map`. The code would look like this:

```
Stream> foobars = …;
Map barsByFoo = foobars.collect(toMap(Map.Entry::getKey, Map.Entry::getValue));
```

The problem is with Content Assist. Let's say that my cursor is right after `toM`, shown by `|` below

> `foobars.collect(toM|);`

If I press `Ctrl+Space` to bring up Content Assist, I expect the first option to be the variations of `toMap(…)`, and in previous versions of Eclipse that was the case. Unfortunately with Eclipse 2022-09, the top selection is `() -> : R - Supplier`.

This is simply wrong: nothing about `() -> : R - Supplier` starts with "toM…" It would be one thing if I hadn't typed anything yet; it might (_maybe!_) be OK in this scenario to provide `() -> : R - Supplier` as the first option. But after I type "toM…" and bring up Content Assist, the list should only include options that begin with "toM…"—in the very least, options that begin with "toM…" should be listed first.

Having extra options that 100% do not match what I have typed so far slows down development. And to make things worse, the top option doesn't even seem to _do_ anything. If I select the `() -> : R - Supplier` item that Eclipse is trying to coax me to select, it simply moves my cursor from the end of `toM` to the beginning:

> `foobars.collect(|toM);`

That is definitely unhelpful.

How can I disable this new `() -> : R - Supplier` listing while the Content Assist order is being fixed for the next Eclipse version?

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue in Eclipse JDT with Java 17 using the Stream and statically imported Collectors example, then inspect the Content Assist implementation responsible for proposal filtering and ordering. Done means entries matching the typed `toM` prefix, especially `toMap`, appear before unrelated `Supplier` proposals and selecting a proposal does not move the cursor unexpectedly.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.