如何在组织导入或自动完成期间避免名称冲突?(How can I avoid name collisions when organizing imports or during autocomplete

编程入门 行业动态 更新时间:2024-10-11 23:22:25
如何在组织导入或自动完成期间避免名称冲突?(How can I avoid name collisions when organizing imports or during autocomplete?)

当我使用Eclipse的Ctrl-Shift-o来组织导入,使用Ctrl-1进行快速修复或使用alt-space来完成引用时,我希望能够指定首选包(或者可以忽略包列表)避免命名空间冲突。 例如,我们总是想要java.util.List,但最终会过于频繁地看到以下对话框:

有什么方法可以避免这种情况吗?

When I use Eclipse's Ctrl-Shift-o to organize imports, Ctrl-1 for quick-fix, or alt-space to complete a reference, I'd like to be able to specify a preferred package (or alternately ignore a list of packages) to avoid namespace collisions. For instance, we always want java.util.List, but end up seeing the following dialog much too frequently:

Is there any way to avoid this?

最满意答案

Eclipse支持负导入过滤器。 例如,您可以过滤所有java.awt.*和javax.swing.*包,以便它们永远不会作为选项出现。 这可以在Java > Appearance > Type Filters菜单下的首选项中完成。

顺便说一下,这非常尴尬,这导致我提交增强请求 ,以便更简单地过滤未使用的类型。

Eclipse supports negative import filters. For example, you can filter all java.awt.* and javax.swing.* packages so that they never come up as an option. This can be done in the preferences under the Java > Appearance > Type Filters menu.

Incidentally, this is quite awkward, which lead me to file an enhancement request to make it much simpler to filter unused types.

更多推荐

本文发布于:2023-07-27 15:23:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1292374.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自动完成   冲突   名称   组织   如何在

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!