Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse Content Assist is Appending Class Name to Variable Suggestions

Tags:

java

eclipse

Content Assist in Eclipse Juno is appending the Class name of variables to suggestions. For example, if I start to type:

private String firstName

and hit Return, Eclipse changes this to:

private String firstNameString;

I don't know if this is specific to Juno or if I accidentally turned this 'feature' on, but it is really annoying. Any idea how to get rid of this?

like image 221
Paul Croarkin Avatar asked Sep 23 '13 13:09

Paul Croarkin


People also ask

How do I turn off suggestions in eclipse?

Java > Editor > Content assist > Advanced Uncheck all and hit apply.

How do I change Content assist in Eclipse?

Step 1: Open your Eclipse or Spring Tool Suite, then go to the Window > Preferences as shown in the below image. Step 2: In the next screen go to the Java > Editor > Content Assist > Auto activation triggers for Java as shown in the below image.

How do I use Content assist in Eclipse?

Using Content AssistThe context assist can be invoked by clicking Ctrl + Space. To select an item from the list just highlight the item using the up or down arrow keys and press enter. If you type some characters and then press Ctrl + space the dialog box will show only items that start with the characters typed in.


2 Answers

I don't know how to resolve the problem when you hit Return (because i can't reproduce the issue), but here is the solution to tell eclipse to not modify the variable name automatically when you hit ctrl + space:

In eclipse: Select Window -> Preferences -> Java -> Editor -> Content Assist

uncheck "Insert single prposals automatically".

enter image description here

like image 153
M. Abbas Avatar answered Jan 09 '23 11:01

M. Abbas


This problem only seems to occur if you changed the Auto activation triggers for Java setting to e.g. ._abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ, which'll make the Content Assist (almost) always pop up, even without pressing Ctrl+Space.

As nitind mentioned, typing a variable name should always end in a comma, semi-colon or space but pressing Enter should be okay. There's a new setting that was added in Eclipse 2018-12 and makes it a bit less annoying (mentioned in the comments below the bug report):

In Window - Preferences - Java - Editor - Content Assist tick the Disable insertion triggers except 'Enter' box.

With this setting enabled, Content Assist is still going to trigger (depending on the other settings) but you have to press Enter to accept a suggestion.

like image 41
Neph Avatar answered Jan 09 '23 12:01

Neph