Eclipse:有没有办法强制导入组织导入来解决歧义? [英] Eclipse: Is there a way to force an import in Organize Import to solve an ambiguity?

查看:182
本文介绍了Eclipse:有没有办法强制导入组织导入来解决歧义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Android项目中使用Eclipse。我更新到狮子,问题开始出现...尝试了几个小时,没有结果。



这是问题:



我的项目中有几十个文件 com.stuff.morestuff
我想crtl + shift + O我的项目,所以每个导入都解决了。
但是,每个文件,eclipse要求我解决歧义。



因此,我想强加给eclipse选择第一选择。



一些线索



1 - 我试图在构建路径中制定规则,但它是强大的。
例如:如果我从构建路径中排除android.R,那么它不会出现在选项中,但是我不能在我的代码中明确使用它...



2 - 手动执行 - >到长



3 - 我尝试配置组织导入工具,但没有成功。



感谢您的答案!

解决方案

您可以使用首选项> Java>外观>类型过滤器。为不想使用的类型创建过滤器。例如。如果您对java.awt包中的类型不感兴趣,可以为整个包创建一个过滤器,也可以过滤掉各个类型。



过滤的类型是然后从UI中隐藏,即它们不用于组织导入或显示在打开类型对话框等中。请注意,类型对于编译器仍然可见,这与使用将从编译器中隐藏类型的构建路径不同。


I'm using Eclipse on an android project. I updated to Lion and problems began to appear... Trying stuff for hours, no results.

Here is the problem:

I have dozens of files com.stuff.morestuff in my project. I would like to crtl+shift+O my project so every import are resolved. But, on each file, eclipse ask me to resolve ambiguities.

Therefore, I would like to impose to eclipse to choose the first choice.

Some clues

1 - I tried to make rules in the build path, but it's to powerful. 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...

2 - Do it manually —> to long

3 - I tried to configure the Organize Import tool, but didn't succeed.

Thank for your answers!

解决方案

You can use 'Preferences > Java > Appearance > Type Filters'. Create filters for types that you don't want to use. E.g. 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.

The filtered types are then hidden from the UI, i.e. 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.

这篇关于Eclipse:有没有办法强制导入组织导入来解决歧义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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