More intelligent auto completion [message #1806007] |
Tue, 30 April 2019 06:58  |
Eclipse User |
|
|
|
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 #1807542 is a reply to message #1807435] |
Sun, 02 June 2019 14:54  |
Eclipse User |
|
|
|
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.
|
|
|
Powered by
FUDForum. Page generated in 0.07607 seconds