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

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

ListITab

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

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

这个特定的类将经常出现在列表中(每次我声明 ListIterator时)。我希望能够排除软件包自动完成搜索,以便 java.util.ListIterator是自动完成,而不需要一个弹出式菜单。

这可能吗?

16001 次浏览

Window > Preferences > Java > Appearance > Type Filters

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

See Java Tips and Tricks

To exclude certain types from appearing in content assist, use the type filter feature configured on the Java > Appearance > Type Filters preference 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.


finnw (the OP) adds in the comments:

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. –

"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.Lxxx classes are of no interest, you could add

 java.awt.L*

All other classes from java.awt would 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 package pattern only in the Type Filter.