在IntelliJ中添加最喜欢的静态导入方法? [英] Add favorite methods to static import in IntelliJ?

查看:2553
本文介绍了在IntelliJ中添加最喜欢的静态导入方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Eclipse中,可以配置某些最喜欢的类,当调用代码完成时,将查找这些类以查看是否可以为方法添加静态导入(这在首选项> Java>编辑器>下内容辅助>收藏夹)。

In Eclipse it is possible to configure certain "favorite" classes which will be looked up when code completetion is invoked to see if a static import can be added for a method (this is under Preferences > Java > Editor > Content Assist > Favorites).

例如,我可以开始输入 assertT 和Eclipse会询问我是否要添加静态导入 org.junit.Assert.assertTrue;

For example, I can begin to type assertT, and Eclipse will ask if I want to add a static import of org.junit.Assert.assertTrue;.

是否可以在IntelliJ中执行相同的操作?

Is it possible to do the same thing in IntelliJ?

此问题详述的方法将为该类型添加 * 导入(静态导入org.junit.Assert。* ),但我这样做不想添加星级导入。我更愿意只导入我正在使用的方法。

The method detailed in this question will add a * import for the type (static import org.junit.Assert.*), but I do not want to add star-imports. I'd prefer to import just the methods I am using.

推荐答案

我认为你可以: -

I think you can:-

文件 - > 设置 - > 代码风格 - > Java - >的进口即可。然后,在包使用导入时添加导入语句,使用'*'表。

File -> Settings -> Code Style -> Java -> Imports. Then, add your import statements under Packages to Use Import with '*' table.

这篇关于在IntelliJ中添加最喜欢的静态导入方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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