Eclipse:自动完成类名时排除特定包 [英] Eclipse: Exclude specific packages when autocompleting a class name

查看:35
本文介绍了Eclipse:自动完成类名时排除特定包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Eclipse 中自动补全类名时,例如如果您输入:

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

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:

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

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

这个特定的类会经常出现在列表中(每次我声明一个ListIterator).我希望能够从自动完成搜索中排除包,以便 java.util.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.ListIterator is auto-completed without the need for a pop-up menu.

这可能吗?

推荐答案

Window >首选项 >Java >外观 >类型过滤器

Window > Preferences > Java > Appearance > Type Filters

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

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

Java 提示和技巧

要排除某些类型出现在内容辅助中,请使用 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)在评论中补充:


finnw (the OP) adds in the comments:

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

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

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

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*

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

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.

这篇关于Eclipse:自动完成类名时排除特定包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆