更改 Eclipse 自动完成(内容辅助)的行为

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11590849/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 18:38:42  来源:igfitidea点击:

Changing the behavior of the Eclipse auto-complete (Content Assist)

javaeclipseautocompleteautosuggestcontent-assist

提问by amiregelz

When I am programming in Eclipse, the auto-complete \ suggestions box usually opens when typing a dot (for example after typing System.or SomeObject., and stays open while typing a similar code to any of the suggested.

当我在 Eclipse 中编程时,自动完成 \ 建议框通常在键入一个点时打开(例如在键入System.或 后SomeObject.,并在键入与任何建议的类似代码时保持打开状态。

This is what I'm talking about: enter image description here

这就是我要说的: 在此处输入图片说明

I often use the auto-complete \ suggestions box to my advantage, and there are couple of changes I would like to make in order to improve my productivity while programming, if possible;

我经常使用自动完成\建议框来发挥我的优势,如果可能的话,为了提高我在编程时的生产力,我想做出一些改变;



  • Is there any way to make the suggestions box visible all the time, showing suggestions in real-time (and showing a blank box when there are no available suggestions) ?

  • Is there any way to add permanent custom suggestions to the suggestions box (e.g. a switch case template or a line of code like public String toString()) ?

  • Is there any way to re-order the suggestions box (e.g. class private variables before general functions or System.out.println()before System.out.print()) ?

  • Is there any way to re-design the suggestions box - i.e changing its text color, background color, re-sizing the suggestions box window and removing the yellow java-doc pop-up?

  • 有没有办法让建议框始终可见,实时显示建议(并在没有可用建议时显示一个空白框)?

  • 有什么方法可以向建议框添加永久的自定义建议(例如 switch case 模板或一行代码public String toString())?

  • 有没有办法对建议框重新排序(例如在通用函数System.out.println()之前或之前的类私有变量System.out.print())?

  • 有没有办法重新设计建议框 - 即更改其文本颜色、背景颜色、重新调整建议框窗口的大小并删除黄色的 java-doc 弹出窗口?

回答by E-Riz

FYI, in Eclipse terminology this feature is called Content Assist.

仅供参考,在 Eclipse 术语中,此功能称为Content Assist

Is there any way to make the suggestions box visible all the time, showing suggestions in real-time (and showing a blank box when there are no available suggestions) ?

有没有办法让建议框始终可见,实时显示建议(并在没有可用建议时显示一个空白框)?

No, that's not possible. You can invoke it any time you want via Ctrl+Space(Command+Spaceon Mac)

不,那不可能。您可以通过调用它任何时候你想要Ctrl+ SpaceCommand+ SpaceMac上)

Is there any way to add permanent custom suggestions to the suggestions box (e.g. a switch case template or a line of code like public String toString()) ?

有什么方法可以向建议框添加永久的自定义建议(例如 switch case 模板或像 public String toString() 这样的一行代码)?

Yes, you can add your own templates via Preferences> Java> Editor> Templates

是的,您可以通过Preferences> Java> Editor> Templates添加自己的模板

Is there any way to re-order the suggestions box (e.g. class private variables before general functions or System.out.println() before System.out.print()) ?

有没有办法重新排序建议框(例如,通用函数之前的类私有变量或 System.out.print() 之前的 System.out.println())?

Not really. There is some control of the order for "cycling" through proposal types via Preferences> Java> Content Assist> Advanced, but it's not really what you're looking for. The order of proposals is, I think, based on the current context of when Content Assist is invoked.

并不真地。通过Preferences> Java> Content Assist> Advanced 可以对“循环”提案类型的顺序进行一些控制,但这并不是您真正想要的。我认为,提案的顺序基于调用 Content Assist 的当前上下文。

Is there any way to re-design the suggestions box - i.e changing its text color, background color, re-sizing the suggestions box window and removing the yellow java-doc pop-up?

有没有办法重新设计建议框 - 即更改其文本颜色、背景颜色、重新调整建议框窗口的大小并删除黄色的 java-doc 弹出窗口?

All of the customization option are available under Preferences> Java> Content Assist; color options are available under Preferences> General> Appearance> Color and Fonts, but I think the colors for that pop-up might come from your operating system color settings.

所有自定义选项都在Preferences> Java> Content Assist下可用;颜色选项在Preferences> General> Appearance> Color and Fonts下可用,但我认为该弹出窗口的颜色可能来自您的操作系统颜色设置。

If you're using (or willing to use) Eclipse Juno (4.2) then there is a new project call Code Recommendersthat you might find interesting.

如果您正在使用(或愿意使用)Eclipse Juno (4.2),那么您可能会发现一个名为Code Recommenders的新项目。

回答by FearlessHyena

E-Riz already answered all your other questions but for getting content assist in real-time there is a workaround

E-Riz 已经回答了您的所有其他问题,但为了实时获得内容帮助,有一个解决方法

Under Preferences > Java > Editor > Content Assistthere is an option for "Auto activation triggers for Java". By default it's set to ".". You can append to that all the alphabets (ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz) and then it should work.

“首选项”>“Java”>“编辑器”>“内容辅助”下,有一个“Java 自动激活触发器”选项。默认情况下,它设置为“.”。您可以将所有字母 (ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz) 附加到其上,然后它应该可以工作。

回答by mantri

Is there any way to re-design the suggestions box - i.e changing its text color, background color, re-sizing the suggestions box window and removing the yellow java-doc pop-up?

有没有办法重新设计建议框 - 即更改其文本颜色、背景颜色、重新调整建议框窗口的大小并删除黄色的 java-doc 弹出窗口?

Just when the auto-suggestion box pops up, if you hover your mouse pointer to its botton-right corner, you'll be able to see mouse pointer turn into resize pointer. Resize it the way you like and next time when it pops up, it will be of the same size. Hope this helps. :-)

就在自动建议框弹出时,如果您将鼠标指针悬停在其右下角,您将能够看到鼠标指针变为调整大小指针。按照您喜欢的方式调整它的大小,下次弹出时,它的大小将相同。希望这可以帮助。:-)