Eclipse:自动完成类名时排除特定包

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2073913/
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 14:18:36  来源:igfitidea点击:

Eclipse: Exclude specific packages when autocompleting a class name

javaeclipseautocomplete

提问by finnw

When auto-completing a class name in Eclipse, e.g. if you type:

在 Eclipse 中自动完成类名时,例如,如果您键入:

ListITab

ListITab

A pop-up menu appears offering you matching class names for completion (which you can select with the mouse or by using the arrow keys:

出现一个弹出菜单,为您提供匹配的类名以供完成(您可以使用鼠标或使用箭头键选择:

In this example, I almost certainly want java.util.ListIteratorand I almost never want com.sun.xml.internal.bind.v2.runtime.reflect.ListIterator(or anything else from that package).

在这个例子中,我几乎肯定想要java.util.ListIterator而且我几乎从不想要com.sun.xml.internal.bind.v2.runtime.reflect.ListIterator(或该包中的任何其他东西)。

This particular class will appear in the list frequently (every time I declare a ListIterator). I would like to be able to exclude packages from autocomplete searches, so that java.util.ListIteratoris auto-completed without the need for a pop-up menu.

这个特定的类会经常出现在列表中(每次我声明 a 时ListIterator)。我希望能够从自动完成搜索中排除包,以便java.util.ListIterator在不需要弹出菜单的情况下自动完成。

Is this possible?

这可能吗?

回答by VonC

  Window->Preferences->Java->Appearance->Type Filters

You should be able to specify there the packages you do not want to see.

您应该能够在那里指定您不想看到的包。

http://help.eclipse.org/galileo/topic/org.eclipse.jdt.doc.user/tips/images/type-filter.png

http://help.eclipse.org/galileo/topic/org.eclipse.jdt.doc.user/tips/images/type-filter.png

See Java Tips and Tricks

请参阅Java 提示和技巧

To exclude certain types from appearing in content assist, use the type filter feature configured on the Java > Appearance > Type Filterspreference page.
Types matching one of these filter patterns will not appear in the Open Type dialog and will not be available to content assist, quick fix and organize imports.
These filter patterns do not affect the Package Explorer and Hierarchy views.

要排除某些类型出现在内容辅助中,请使用Java > Appearance > Type Filters首选项页面上配置的类型过滤器功能。
与这些过滤器模式之一匹配的类型将不会出现在“打开类型”对话框中,并且无法用于内容辅助、快速修复和组织导入。
这些过滤器模式不会影响 Package Explorer 和 Hierarchy 视图。



finnw(the OP) adds in the comments:

finnw(OP)在评论中补充道:

Now how do you add a single class to this list? I'm not interested in java.awt.List but occasionally I want java.awt.Window or java.awt.Dimension. –

现在如何将单个类添加到此列表中?我对 java.awt.List 不感兴趣,但偶尔我想要 java.awt.Window 或 java.awt.Dimension。——

"Type filter" is actually based on class pattern matching, meaning if you add:

“类型过滤器”实际上是基于类模式匹配,意思是如果你添加:

 java.awt.List

that class will disappear from the content assist propositions.
If you know all java.awt.Lxxxclasses are of no interest, you could add

该类将从内容辅助命题中消失。
如果您知道所有java.awt.Lxxx课程都不感兴趣,您可以添加

 java.awt.L*

All other classes from java.awtwould still be there for the content assist.
With a recent eclipse (I have right now a eclipse 3.6Mx, but this should work for 3.5.x as well), you are not limited to packagepattern only in the Type Filter.

来自的所有其他类java.awt仍将用于内容辅助。
使用最近的 eclipse(我现在有一个 eclipse 3.6Mx,但这也适用于 3.5.x),您不仅限于类型过滤器中的模式。

回答by Jonathan Feinberg

Window->Preferences->Java->Appearance->Type Filters