强制Eclipse自动导入具有多个选项的类 [英] Force Eclipse to automatically import a class with multiple options
问题描述
如果在Eclipse中的Java项目中使用了一个类,并且它没有被导入,并且只有一个类具有该名称,Eclipse将自动导入它。
If a class is used in a Java project in Eclipse, and it's not imported already, and there is only one class with that name, Eclipse will automatically import it.
如果有两个或更多类具有相同的简单名称,Eclipse将要求用户选择所需的类。我想避免选择一个,而不是更喜欢导入默认类。
If there are two or more classes with the same simple name, Eclipse will ask the user to select the desired one. I would like to avoid having to select one and instead prefer having a default class imported.
例如,我通常使用 List
和 ArrayList
。每次我在一个新类中使用它们,我必须选择 java.util.ArrayList
和 java.util.List
从Eclipse的建议,因为有另一个类名为 List
( java.awt.List
)
For example, I commonly use List
and ArrayList
. And each time I use them in a new class, I have to select java.util.ArrayList
and java.util.List
from the suggestions of Eclipse, because there is another class with the name List
(java.awt.List
).
有没有办法设置 java.util.List
和 java.util如果
作为默认导入? List
和 ArrayList
使用的是.ArrayList
Is there some way to set java.util.List
and java.util.ArrayList
as a default import if List
and ArrayList
is used?
现在,我创建了一个Eclipse模板,它触发单词 List
。有没有其他想法或改进?
For now, I created an Eclipse template that triggers on the word List
. Are there any other ideas or improvements?
${:import(java.util.List,java.util.ArrayList)}
List<> list = new ArrayList<>();
推荐答案
如果您不在项目中使用AWT可以限制您可访问的API,如我在博客中提到的: http://blog.firdau.si/2010/07/07/limit-your-access-to-java-api-for-more-productivity/
If you don't use AWT in the project you can limit your accessible API like I mentioned in my blog: http://blog.firdau.si/2010/07/07/limit-your-access-to-java-api-for-more-productivity/
像我一样的魅力!
这篇关于强制Eclipse自动导入具有多个选项的类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!