[JAVA] When you get "Eh?" In Eclipse code completion-If you stumble on substring code completion-

Overview

--Eclipse's code completion feature ** unintentionally completes when completing a method name for a class! It is a measure when you think ** (Suppressing side effects of ** Substring code completion function added in Eclipse NEON Is the one)

environment

"Unintentional complementation" is a case like ↓ (it is faster to see)

If you hit a dot (**. **) with ** Arrays **, code completion will be completed. Then, if you enter ** tostring ** and press enter, ** deepToString ** will be selected.

substring_miss_before_.gif

Substring is useful when completing code,

Even if you enter only ** string ** as shown below, it will give you candidates that include ** string ** as part of the method name.

substring_ok.gif

Correction method 1: Turn off partial matching of method names

Partial matching of method names is bad, so try turning this feature off the settings.

If you select ** Window> Preference> Java> Editor> Content Assist ** from the main window of Eclipse, the item ** Show substring matches **Image.png -store.s3.ap-northeast-1.amazonaws.com/0/170905/ec003ceb-52de-271a-9cbd-83873e730029.png), so turn it off **Image.png //qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/170905/9a19cb9f-b238-e47a-79b4-e62be45a958b.png)

image.png

Try using substring off

It feels pretty good. ** deepToString ** is no longer unintentionally selected as before.

off_substring.gif

Obviously, if substring is off, you can't complete with partial match

As a trial, when I typed ** string ** after ** Arrays. **, no candidates came up.

off_substring_miss.gif

Correction method 2

First, open the setting screen with ** Window> Preference> Java> Editor> Content Assist ** as beforeImage.png .amazonaws.com/0/170905/df96a4ec-3fbb-3a5d-4e11-47f5a1e2722a.png) is checked.

This will enable partial matching for the time being.

Next, expand the settings through the [+] mark of ** Content Assist ** and select ** Advanced **.

image.png

Next, check ** Java Proposals ** as shown below.

image.png

This is OK

Try code completion

Now, try code completion again with this setting.

It seems that it is moving with the intended movement

proposals_fullmatch.gif

Try code completion with partial match

Partial match is also working properly.

proposals_partmatch.gif

Correction method 2 seems to be the more intended behavior (with partial matching, code completion is also as intended).

Summary

--I explained the phenomenon and countermeasures when I thought that "it will be unintended completion" in Eclipse code completion. --The substring code completion function is a function added in Eclipse NEON, but if the side effect results in unintended completion, you can turn off ** substring code completion ** or ** It turns out that side effects can be suppressed by taking measures to enable Java Proposals **. --For code completion, ** Intellij IDEA ** (and Android Studio) is much ahead of the game and supports ** substring code completion **, and seems to have been tuned in advance to avoid these side effects. (I didn't notice it until I encountered it in Eclipse, but the slight differences created by tuning the UI and usability like this affect productivity and quality.)

Recommended Posts

When you get "Eh?" In Eclipse code completion-If you stumble on substring code completion-
Use completion in Eclipse on mac
Enable code completion in Eclipse for Mac
When you get lost in the class name
What to do if you get a NoClassDefFoundError when trying to run eclipse on Java9
What to do if you get a JNI shared library error when trying to build in Eclipse
In Java 10, when you do gradle eclipse and JavaSE-1.10 comes out, ...
The first thing to do when you want to be happy with Heroku on GitHub with Eclipse in Java