Bug 560268 - autocomplete prefer inexact matches over exact one
Summary: autocomplete prefer inexact matches over exact one
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.13   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords: needinfo
Depends on:
Blocks:
 
Reported: 2020-02-18 06:11 EST by Luis Castro CLA
Modified: 2024-02-01 04:14 EST (History)
4 users (show)

See Also:


Attachments
after typing testmap.put, compute is the first option showed (149.68 KB, image/png)
2020-02-18 06:11 EST, Luis Castro CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Luis Castro CLA 2020-02-18 06:11:11 EST
Created attachment 281847 [details]
after typing testmap.put, compute is the first option showed

This is maybe some kind of regression, the last version working fine is Eclipse Photon.

Having this line:
Map testmap = HashMap();

If I type "testmap." the autocomplete box shows up and list:
 * clear
 * compute
 * computeIfAbsent
 * ...

If I continue typing "testmap.put" it list:
 * compute
 * computeIfAbsent
 * computeIfPresent
 * put
 * putAll
 * ...
(see the screenshot)

I expect "Map.put" to be at first place, as it is an exact match.

If I continue typing "testmap.put(" the "(" triggers selection so the text ends as "testmap.compute("

The only way to avoid it is type "testmap.put", then going down with arrow keys and pick ".put", then continue typing.
It is almost impossible to work that way so I stayed in Eclipse Photon.

I tested it in the following versions for Linux 64
- Oxygen
- Photon
- 2019-3
- 2019-6
- 2019-9

Oxygen and Photon are OK.

But starting on 2019-3 the issue appears.

The latest version tested is :
Version: 2019-09 R (4.13.0)
Build id: 20190917-1200

Strangely all the 2019-x series works fine just one time the very first time the IDE is used.

The procedure is the following
1- download eclipse-java-2019-09-R-linux-gtk-x86_64.tar.gz
2- extract it to some folder
3- execute ./eclipse
4- at startup the IDE ask for a workspace
   complete it with a new folder name
5- create a new project a new class and use the example of Map
   Map testmap = HashMap();
   then write "testmap.put"  
   Autocomplete works fine at this point. "map.put" is the first option showed
   Complete the line with "testmap.put("somekey","somevalue");
6- Type in a new line "testmap.put", autocomplete is not working well now. "map.compute" is the first option showed.

Additionally deleting .metadata folder from workspace makes autocomplete work fine just one time.
1- close the IDE
2- delete .metadata folder
3- start the IDE, open the test project
4- type testmap.put works fine the first time
5- type a second line with testmap.put, autocomplete is wrong now
Comment 1 Stephan Herrmann CLA 2020-02-18 07:51:04 EST
We've had variants of this (admittedly annoying) problem before. To check if it is already fixed also for you please:

- Update to 2019-12, or even better to 2020-03 M2

- Check what proposal kinds you have selected in 
    Preferences > Java > Editor > Content Assist > Advanced
  If anything checked in the upper list mentions code recommenders, mylyn or 
  "Task focused", please disable that option and try again.
Comment 2 Luis Castro CLA 2020-02-18 08:56:05 EST
Thanks Stephan,

Checking the "Java Proposals" in the section you said fixed the issue.


I'm using it with the defaults that came with installation.

In Photon, this options came checked by default:
- Adaptative Template Proposals (Code Recommenders)
- Chain Proposals (Code Recommenders)
- Java Proposals
- Java Proposals (Code Recommenders)
- Java Proposals (Task-Focused)
- SWT Template Proposals
- Template Proposals

After that version only this options are checked by default:
- Java Proposals (Task-Focused)
- SWT Template Proposals
- Template Proposals

Checking "Java Proposals" without unchecking anything else solves the issue.

I just tested also on Windows 64:

Version: 2019-12 (4.14.0)
Build id: 20191212-1212

I don't know where to look for the 2020-03 M2 build, but I can check too if you point me how.

Although I solved my case it would be very convenient to change the defaults to include "Java Proposals".

What do you think about?
Comment 3 Stephan Herrmann CLA 2020-02-18 09:55:41 EST
(In reply to Luis Castro from comment #2)
> Checking the "Java Proposals" in the section you said fixed the issue.

thanks for the update.

> I just tested also on Windows 64:
> 
> Version: 2019-12 (4.14.0)
> Build id: 20191212-1212

what result? I mean, can you still reproduce the original problem with your original preferences?


> I don't know where to look for the 2020-03 M2 build, but I can check too if
> you point me how.

https://www.eclipse.org/downloads/packages/release/2020-03/m2


> Although I solved my case it would be very convenient to change the defaults
> to include "Java Proposals".
> 
> What do you think about?

"Java Proposals" is what JDT provides and JDT naturally enables it by default. If additional Mylyn is installed and changes the preference to "Java Proposals (Task-focused)" then this is beyond our control. More specifically, this is (AFAIK) controlled by the maintainer of package "Eclipse IDE for Java Developers".

On the long run, no combination of preferences should trigger the bug.
Comment 4 Andrey Loskutov CLA 2020-02-18 15:14:46 EST
Is this related to bug 560278?
Comment 5 Julian Honnen CLA 2020-02-19 03:10:08 EST
(In reply to Andrey Loskutov from comment #4)
> Is this related to bug 560278?
No. AFAICT, 4.15 was not tested.
Comment 6 Luis Castro CLA 2020-02-19 07:11:04 EST
I tested it on:

Version: 2020-03 M2 (4.15.0M2)
Build id: 20200206-1540

packages:
- Eclipse IDE for Enterprise Java Developers.
  eclipse-jee-2020-03-M2-linux-gtk-x86_64.tar.gz
- Eclipse IDE for Java Developers
  eclipse-java-2020-03-M2-linux-gtk-x86_64.tar.gz

It's still present.

"Java proposals" is unchecked by default, but enabling it solves the issue.

I'm not sure if it is related to bug 560278, it seems not.

I couldn't fully understand the steps to reproduce that bug, not sure if they are talking about type "Demo.getName" or "Demo.name".

I tried the code example provided and it works fine for my expectations in several versions, that's all I can say.
Comment 7 Eclipse Genie CLA 2022-02-10 09:18:53 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 8 Eclipse Genie CLA 2024-02-01 04:14:31 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.