问题描述
在intellij IDEA中,如果方法未使用,则该方法以灰色显示。但在某些情况下,IDEA不会使方法变灰,但当我使用alt + F7检查这些方法的引用时,IDEA表示该方法未使用。
In intellij IDEA, if a method is unused, the method is shown in a gray color. But in some cases, IDEA doesn't grey out the method, but when I check the references of those methods using alt + F7, IDEA says that the method is unused.
这是一个IDEA错误,还是有任何理由说IDEA不会使这些特定方法变灰?如果它是一个错误,是否有一些解决方法使IDEA识别该方法未使用?
Is this a IDEA bug or is there any reason why IDEA wouldn't grey out these specific methods? If it is a bug, is there some workaround to make IDEA identify that method is unused?
推荐答案
很可能它不是一个bug ,这是出于性能原因的限制。跳过搜索用法可能需要很长时间的方法。
Most likely it's not a bug, it's a limitation for performance reasons. Methods likely to take a long time when searching for usages are skipped.
解决方法是通过Analyze |在所有项目中显式运行未使用的声明检查。检查代码或分析|按名称运行检查。那需要一些时间。您也可以设置TeamCity服务器,以便每晚自动为您完成。
A workaround is to run Unused Declaration inspection explicitly in all your project via Analyze | Inspect Code or Analyze | Run Inspection by Name. That'll take some time. You can also set up TeamCity server to do it for you automatically every night.
这篇关于Intellij IDEA不会使一些未使用的方法变灰的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!