Eclipse的组织导入(ctrl + shift + o)命令的静态导入的处理是否可以修改? [英] Can Eclipse the Organize Import (ctrl+shift+o) command's handling of static imports be modified?

查看:107
本文介绍了Eclipse的组织导入(ctrl + shift + o)命令的静态导入的处理是否可以修改?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Eclipse键盘快捷键 Ctrl + Shift + O 所有的时间(整理导入)。

I use the Eclipse keyboard shortcut Ctrl + Shift + O all the time (Organize Imports).

但是,它有一个特别烦人的行为:

However, it has one particularly annoying behavior:

如果我有任何静态导入,如:

If I have any static imports like:

import static java.lang.Math.*;

组织导入将有帮助将其替换为仅实际使用的字段和方法的静态导入。例如:

Organize Imports will "helpfully" replace it with static imports of only the fields and methods I am actually using. For example:

import static java.lang.Math.PI;
import static java.lang.Math.cos;

有没有办法从组织导入中删除这种行为?

Is there any way to remove just this behavior from Organize Imports?

推荐答案

确定:窗口 - >首选项 - > Java - >代码样式 - >组织导入

Sure: Window -> Preferences -> Java -> Code Style -> Organize Imports

的值。*为1所需的静态导入数,它将始终使用*。当然,这并不是说只要静态导入,但希望是你想要的。

Adjust the value for "Number of static imports needed for .*" to 1, and it will always use .*. Of course, that's not quite the same as saying, "Just leave static imports alone" but hopefully it's what you want.

基本上这个数字表示如果我导入这么多项目,请使用此导入的所有方法或字段因此,如果数字为2,则只有在使用两个或多个导入时,才会添加星号。这将解决您在回复中说的问题。

Basically, this number says "Use all of the methods or fields of this import if I'm importing this many items" So if the number is 2, it will add the asterisk only if you use two or more imports. That will fix the problem you said in the response.

这篇关于Eclipse的组织导入(ctrl + shift + o)命令的静态导入的处理是否可以修改?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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