IntelliJ 组织导入 [英] IntelliJ Organize Imports
问题描述
IntelliJ 是否具有类似于 Eclipse 中的组织导入功能?我拥有的是一个 Java 文件,其中包含多个缺少导入的类.示例:
Does IntelliJ have an Organize Imports feature similar to that in Eclipse? What I have is a Java file with multiple classes missing their imports. Example:
package com.test;
public class Foo {
public Map map;
public JTable table;
}
在 Eclipse 中,我可以使用 Organize Imports,它会自动导入 java.util.Map
和 javax.swing.JTable
.在 IntelliJ 中,我必须单独转到每个类,选择它,然后按 Alt-Enter.有一个优化导入功能,但它似乎所做的只是对现有导入进行排序和扩展.
In Eclipse I could use Organize Imports and it would automatically import both java.util.Map
and javax.swing.JTable
. In IntelliJ I have to individually go to each class, select it, then press Alt-Enter. There is an Optimize Imports feature but all it seems to do is sort and expand the existing imports.
我使用的是 IntelliJ 10.5.
I'm using IntelliJ 10.5.
推荐答案
2015 年 7 月 - 我得出结论,IntelliJ 不支持使用单个函数自动解析导入.组织导入"只是删除未使用的导入,它不会解析未导入的类型.Control-Space 解析单个未导入的类型.不存在解决所有类型导入的单一操作.
July 2015 - I have concluded that IntelliJ does not support automatically resolving imports with a single function. "Organize imports" simply removes unused imports, it does not resolve unimported types. Control-Space resolves a single unimported type. There does not exist a single action to resolve all types' imports.
这篇关于IntelliJ 组织导入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!