Eclipse content assist auto appends type for variable

隐身守侯 提交于 2020-07-02 17:27:07

问题


I just started to use Juno for a couple of days, the content assist mechanism seems different from what it behaves before.

For example, if I try to declare a variable

Boolean isVisible

The content assist of Juno will give you a drop-down list with the variable name

isVisibleBoolean

as hint.

And the very annoying thing is that no matter what I typed in(; or SPACE), the "isVisibleBoolean" will be selected.

Does anybody know how can I disable the auto-variable-type-appending thing?

Much appreciated.

I'm using Mac OS X 10.8.1 currently, haven't tested it yet in windows.


回答1:


Based on the discussion for Eclipse Bug 412992, check your Content Assist Auto Activation settings: Window->Preferences->Java->Editor->Content Assist

If, for example, characters a-z are listed as "Auto activation triggers for Java", you can remove them and the type name will not be auto-appended to a new variable name when you hit ' ' or ';'. It's up to you to determine the best configuration/tradeoffs for your style based on the available options.




回答2:


It seems that it is not possible. See answers to Eclipse Bug 378588: https://bugs.eclipse.org/bugs/show_bug.cgi?id=378588




回答3:


Not a perfect solution:

Window->Preference->Java->Editor->Content Assist->Auto activation Triggers for Java: .ABCDEFGHIJKLMNOPQRSTUVWXYZ

In this way, only classes and types will be popped up for proposals.

Just a suggestion, the choice is up to you.




回答4:


This is still a problem in Eclipse 2018-12 and it 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 (Windows).

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.




回答5:


What you see there is name completion for object types. And this may often make sense, e.g. pressing Ctrl-Space after List book will complete that to List bookList. For primitive types this is not done, so int count will not get any completion when pressing Ctrl-Space. This would be a (not really good) solution to your problem by declaring the variable as primitve boolean.

What I really recommend as solution is to change your style of writing variable declarations. For your example, write isVisible = false instead, have the editor complain about the missing type declaration, hit Ctrl-1 (from wherever your cursor might be placed), Enter.



来源:https://stackoverflow.com/questions/12433900/eclipse-content-assist-auto-appends-type-for-variable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!