Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » More intelligent auto completion(How to get eclipse to suggest meaningful auto completions)
More intelligent auto completion [message #1806007] Tue, 30 April 2019 10:58 Go to next message
Michael Berg is currently offline Michael BergFriend
Messages: 6
Registered: April 2019
Junior Member
Using eclipse 2018.12 4.10.0 on Ubuntu.

I have altered the hotkeys for auto complete so that basically pressing any letter of the alphabet (upper or lower case) or a dot activates auto completion automatically.

This works kind of fine, except it always seems to want to suggest packages, types, variables, method names etc, before suggesting java language tokens.

For example:

switch (x) {
   cas(here the autocompletion comes up)


What is suggested here is not "case" but "CaseInsensitiveTreeMap". From a non-contextual point of view this could be a useful suggestion but when you look at where the cursor is, the suggestion does not make sense. Putting that type name in there produces syntactically incorrect java code and based on that eclipse really should be able to understand that this is not what I want and exclude that suggestion.

I imagine this should be possible as the built in compiler knows what tokens are expected at any given position given the previous tokens.

I'm wondering if there are any improvements along those lines planned for future versions. Or if anyone can suggest a plugin that might improve the quality of the auto complete suggestions?
Re: More intelligent auto completion [message #1806322 is a reply to message #1806007] Tue, 07 May 2019 17:52 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33218
Registered: July 2009
Senior Member
No, I doubt there are any behavior changes planned and I doubt there exist plug-ins with richer functionality than JDT itself already does.

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: More intelligent auto completion [message #1807383 is a reply to message #1806322] Wed, 29 May 2019 05:03 Go to previous messageGo to next message
Jay Arthanareeswaran is currently offline Jay ArthanareeswaranFriend
Messages: 134
Registered: July 2009
Senior Member
JDT has the idea of relevance and all the computed proposals have a certain relevance value, which decides the order of the proposals. There is no way to configure the relevance like this and it may have to be handled case by case. If you are convinced this should be corrected, please raise a bug or an enhancement.
Re: More intelligent auto completion [message #1807428 is a reply to message #1807383] Wed, 29 May 2019 20:25 Go to previous messageGo to next message
Michael Berg is currently offline Michael BergFriend
Messages: 6
Registered: April 2019
Junior Member
I think it should be an improvement and I have to say I can't see why eclipse would have such a hard time discarding suggestions that if accepted would produce syntactically incorrect code. If you are in a switch statement and have completed one case, then the only valid construct to follow that is a label or the word "case". Every other suggestion is useless.
Re: More intelligent auto completion [message #1807435 is a reply to message #1807428] Thu, 30 May 2019 05:30 Go to previous messageGo to next message
Jay Arthanareeswaran is currently offline Jay ArthanareeswaranFriend
Messages: 134
Registered: July 2009
Senior Member
I would suggest raising a bug and take it up with the JDT development team.
Re: More intelligent auto completion [message #1807542 is a reply to message #1807435] Sun, 02 June 2019 18:54 Go to previous message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Just for some technical background: one of the hardest issues in implementing code completion is the fact that most of the time completion is invoked, the current file is *not* syntactically correct. Some parsers would then simply give up and say "syntax error". The JDT parser is packed with heuristics how to recover some parts of the program, while discarding elements which - hopefully - should have no relevance for code completion. IOW, JDT already does all the things you are expecting it to do, just in some cases these heuristics pick an 'unfortunate' choice, leading to a different set of proposals than what the smart human reader would expect. Of course, one should try to constantly improve those heuristics, it just ain't as easy as it may look.
Previous Topic:How to get ASTNode of constant which is returned by Expression.resolveConstantExpressionValue()?
Next Topic:Why isn't SpringUtilities part of the core Java library?
Goto Forum:
  


Current Time: Wed Sep 25 08:43:29 GMT 2024

Powered by FUDForum. Page generated in 0.02582 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top