Reputation: 1155
I use Map a lot in Java with eclipse. e.g.
Map<String, String> map = new HashMap<>();
then when I am ready to add something with put:
String key = null;
String value = null;
// somewhere before the put, key and value get populated with Strings
map.put(key, value);
the problem is, every time I type "map.put", Eclipse autocomplete changes it to "map.compute()" so I have to edit and remove the "com" and the "e".
I looked at Window -> preferences -> Java -> Editor -> Content Assist but nothing was apparent. I could, I suppose, turn off all content assist, but that would be like "throwing the baby out with the bath water". There are a lot of useful things in the content assist.
My Eclipse:
Eclipse IDE for Enterprise Java Developers. Version: 2018-12 (4.10.0) Build id: 20181214-0600 OS: Windows 10, v.10.0, x86_64 / win32 Java version: 1.8.0_144
How can I fix eclipse so it will make the correct suggestions like it did in previous versions?
Upvotes: 5
Views: 2514
Reputation: 376
None of the proposed solutions worked for me. What fixed it was to disable "Show substring matches" (in Preferences -> Java -> Editor -> Content Assist
).
It should be considered that this will break the functionality to just type a random part of the desired reference, e.g. typing "PreparedStatement" no longer leads to OraclePreparedStatement
. A feature that I don't care about, but this is obviously a matter of personal preference.
In my opinion, the name of that option is a slight misnomer since the substring aspect only applies to leading and not to trailing content.
Update: In Eclipse 2020-06, there is no longer an option "Show substring matches". In its place there is "Show subword matches", but even when disabled, suggestions for typing map.put
still include compute
. At least when sorted by relevance rather than alphabetically, put
is listed in the suggestions before compute
.
Upvotes: 4
Reputation: 31
Window->Preferences Java->Editor->Content Assist->Advanced
Unchecking "Java Proposals (Task-Focused)" and instead checking regular "Java Type Proposals" fixed the problem for me. I'm using Eclipse for Enterprise Java Developers 2019-03 on Windows 10.
Upvotes: 3
Reputation: 756
This appears to be due to the unfortunate decision to remove 'Code Recommenders' going forward from 2018-12
"... Code Recommenders will unfortunately not make it into 2018-12."
The solution currently is to add it manually from the marketplace.
Help -> Eclipse Marketplace -> Search for 'Code Recommenders'
There are no guarantees it will work for Java 11+.
Once installed, you'll have to:
Finally attempt autocomplete again, this time it should work as expected
Update: It appears Code Recommenders has been archived due to lack of maintainers. When you try to download it, you will get a 404. Hopefully this is temporary.
Upvotes: 1