Eclipse 在这方面很聪明; IntelliJ 还没有。当然,如果一个函数未被使用(并且未经测试,我想我应该为此感到难过——即使它只是返回一个简单的变量,或者实现其他人的接口(interface))但是公开的,它可以在其他地方使用。在“检查”下查看并搜索“未使用”,我没有看到可见性设置。这种粒度存在吗?
最佳答案
If you want to highlight unused public methods, please enable the "Settings|Inspections|Declaration redundancy|Unused declaration" global inspection.
If you want to highlight unused private methods, please enable the "Settings|Inspections|Declaration redundancy|Unused symbol" local inspection.
So, if you want to highlight unused private members, but do not highlight unused public members, turn off "Unused declaration" and turn on "Unused symbol".
我刚刚使用 IDEA 13.1.4 对其进行了测试,它完全按照描述工作。
关于java - 关闭 IntelliJ 中公共(public)函数的未使用代码警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23923696/