How can I get Eclipse to populate autocomplete when I enter an opening parenthesis ('(')?

So, on Eclipse Luna I often come across a situation when I type the name of a method, but the first sentence of autocompletion is not the method that I am looking for, but something equivalent, but longer, as in this example

Unhelpful autocomplete suggestions

In this example, I just need the element(String name) method, so instead of pressing Return, I type ( . The result, rather annoyingly, is this:

After accidentally triggering autocomplete

This is clearly not what I was looking for. Is there a way to prevent Eclipse from automatically populating when I press an open bracket ( ( )?

These are my content settings settings (apparently, I have no recommendations for setting up the code at all in this eclipse installation): Content assist settingsenter image description here

+6
source share
4 answers

The hack for this is to change the way you sort Eclipse sentences.

You can go to the Preferences menu and then go to the section for which you want to edit the sort. Then to the Editor and Content Assist . For example, for a Java editor, this would be Preferences > Java > Editor > Content Assist .

There you will see the Sorting and filtering section more or less in the middle of the window. Inside there is an option called Sort proposals , which you can change from by relevance to alphabetically . Save the closure.

With this, you will get a list of suggestions in alphabetical order, and element() will be in front of other methods, starting with element .

EDIT: Tested on Eclipse Luna running on Ubuntu 14.04 and it works. You will still get the code when writing ( but it will be supplemented with a shorter option available in the list of sentences. If you want to use a different method, you can continue to write a few letters and the shortest option will disappear from the sentences, because it does not correspond to what are you writing.

+2
source

The function you're fighting with is the new Intelligent Code Completion, which orders methods based on average usage. Do not ask me where they get the data. See also here: http://www.eclipse.org/recommenders/manual/#intelligent-code-completion

To disable the function, go to the settings page. Code compliance guidelines. Run and uncheck the box next to Enable smart code completion.

+1
source

I think your problem is substring matching.

Go to Window-> Preferences β†’ Java-> Editor> Content Assistant.

In the Sort sentences section, clear the Show substring matches check box.

By relevance, I found it more useful than alphabetically. I usually checked hidden Hide offers that weren’t visible in the call target, and Hide also outdated links.

I hope this helps.

0
source

In Eclipse 4.11 (2019-03) and, possibly, earlier, the answer to this question is in the section "Preferences" β†’ "Java" β†’ "Editor" β†’ "Content Assistant" β†’ "Disable Insert Triggers", except for "Enter". After I checked this box, editing became much less annoying.

I have no idea why Eclipse does not do this by default. Who types map.put( and wants autocomplete to map.compute() ?

0
source

Source: https://habr.com/ru/post/973376/


All Articles