如何使用IntelliJ IDEA查找所有未使用的代码? [英] How to use IntelliJ IDEA to find all unused code?
问题描述
当我在.java文件中时,未使用的代码通常会变灰或者有一个绿色下划线表示此代码可能(可能是因为一些奇怪的JNI / Reflection极端情况)未被使用。但我有这个项目有成千上万的Java文件,我想找到这些可能未使用的代码的所有实例。我怎么能在IntelliJ IDEA中做到这一点?
When I am in a .java file the unused code is usually grayed out or has a green underline saying this code will probably (probably because of some weird JNI/Reflection corner cases) be unused. But I have this project with thousands of Java files and I want to find ALL INSTANCES of such probable-unused codes. How can I do that in IntelliJ IDEA?
推荐答案
只需使用分析|检查代码
并启用适当的检查(声明冗余组下的未使用的声明)。
Just use Analyze | Inspect Code
with appropriate inspection enabled (Unused declaration under Declaration redundancy group).
使用IntelliJ 11 CE,您现在可以分析|按名称运行检查... |未使用的声明
Using IntelliJ 11 CE you can now "Analyze | Run Inspection by Name ... | Unused declaration"
这篇关于如何使用IntelliJ IDEA查找所有未使用的代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!