简体   繁体   English

Eclipse:有没有办法在组织导入中强制导入以解决歧义?

[英]Eclipse: Is there a way to force an import in Organize Import to solve an ambiguity?

I'm using Eclipse on an android project.我在 android 项目上使用 Eclipse。 I updated to Lion and problems began to appear... Trying stuff for hours, no results.我更新到 Lion 并开始出现问题......尝试了几个小时,没有结果。

Here is the problem:这是问题所在:

I have dozens of files com.stuff.morestuff in my project.我的项目中有几十个文件com.stuff.morestuff I would like to crtl+shift+O my project so every import are resolved.我想 crtl+shift+O 我的项目,以便解决每个导入。 But, on each file, eclipse ask me to resolve ambiguities.但是,在每个文件上,eclipse 要求我解决歧义。

Therefore, I would like to impose to eclipse to choose the first choice.因此,我想强加给 eclipse 来选择首选。

Some clues一些线索

1 - I tried to make rules in the build path, but it's to powerful. 1 - 我试图在构建路径中制定规则,但它太强大了。 Ex: If i exclude android.R from the build path, then it doesn't appear in the choices but I cannot use it explicitly in my code...例如:如果我从构建路径中排除 android.R,那么它不会出现在选项中,但我不能在我的代码中明确使用它......

2 - Do it manually —> to long 2 - 手动执行 -> 长

3 - I tried to configure the Organize Import tool, but didn't succeed. 3 - 我尝试配置组织导入工具,但没有成功。

Thank for your answers!感谢您的回答!

You can use 'Preferences > Java > Appearance > Type Filters'.您可以使用“首选项 > Java > 外观 > 类型过滤器”。 Create filters for types that you don't want to use.为您不想使用的类型创建过滤器。 Eg If you are not interested in types from java.awt package, you can create a filter for the entire package, or you can filter out individual types.例如,如果您对 java.awt package 中的类型不感兴趣,您可以为整个 package 创建一个过滤器,或者您可以过滤掉单个类型。

The filtered types are then hidden from the UI, ie they are not used in Organize imports or shown in Open Type dialog etc. Note that the types are still visible to the compiler, this is different from fiddling with the build path which will hide the types from the compiler.过滤后的类型然后从 UI 中隐藏,即它们不用于组织导入或显示在“打开类型”对话框等中。请注意,编译器仍然可以看到这些类型,这与摆弄构建路径不同,后者将隐藏来自编译器的类型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM