DEV Community

riversun
riversun

Posted on

1 1

When you get unintended results in Eclipse's code completion that might be the side effect of substring code completion.

Overview

  • When you want to complete the method name of a class,sometimes eclipse will complete an unintended method name.
  • I want to explain the measures in such a case.
  • It's probably a side effect of the new feature "Substring code completion" added in Eclipse NEON

Environment

  • Eclipse IDE 2019‑06

"Unintended completion" is as follows.Take a look first.

After entering "Arrays", enter a dot(.) To start code completion.
Next, if you enter "tostring" and press the enter key, "deepToString" is selected as a problem.

substring_miss_before_.gif

"Substring code completion" is a useful feature,you know.

Even if only "string" is typed, those that include "string" as part of the method name will be suggested as candidates.

substring_ok.gif

Solution-1: Turn off substring completion

Select Window>Preference>Java>Editor>Content Assist ,then you can find Show substring matches setting image.png.And then turn it off image.png

image.png

Try to use "substring completion off"

It feels pretty good.
Unintentional "deepToString" is no longer complemented.

off_substring.gif

However, if "substring completion" is off, substring completion can not be completed naturally.

I tried typing "string" after "Arrays." and there were no more candidates.

off_substring_miss.gif

Solution-2

Reopen settings window as before Window>Preference>Java>Editor>Content Assist and turn "substring completion" on image.png

Next, click the [+] "plus" mark on "Content Assist", then expand the settings and select "Advanced".

image.png

Check Java Proposals like as follows.

image.png

Try code completion

Look at this.

It seems that it moves by the intended action

proposals_fullmatch.gif

Try Code Completion with Substring Match

The substring completion is also working properly.

proposals_partmatch.gif

Solution-2 seems to work more as intended.

Impression

As for code completion, I think, "Intellij IDEA" (or Android Studio) is much more advanced and corresponds to "substring code completion" and seems to be pre-tuned to have no such side effects.

(I didn't notice it until I encountered it in Eclipse, but the slight differences improved by the tuning of the feeling of use affect productivity and quality, etc.)

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more