在 Eclipse 中自动完成类名时,例如如果你输入:
ListI
Tab
会出现一个弹出菜单,为您提供匹配的类名称以供完成(您可以使用鼠标或箭头键选择:
在这个例子中,我几乎肯定想要 java.util.ListIterator
而我几乎从不想要 com.sun.xml.internal.bind.v2.runtime.reflect.ListIterator
(或该包中的任何其他内容)。
这个特定的类会经常出现在列表中(每次我声明一个ListIterator
)。我希望能够从自动完成搜索中排除包,以便 java.util.ListIterator
自动完成而不需要弹出菜单。
这可能吗?
最佳答案
Window
> Preferences
> Java
> 外观
> 类型过滤器
你应该可以在那里指定你不想看到的包。
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 (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.Lxxx
类都不感兴趣,你可以添加
java.awt.L*
java.awt
中的所有其他类仍将用于内容辅助。
对于最近的 Eclipse(我现在有一个 Eclipse 3.6Mx,但这也适用于 3.5.x),您不仅限于类型过滤器中的 package 模式。
关于java - Eclipse:自动完成类名时排除特定包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2073913/