I am concerned that some of the classes in my app have methods that are defined but not called anywhere in the app.
In Eclipse is there a way to find these methods?
I am concerned that some of the classes in my app have methods that are defined but not called anywhere in the app.
In Eclipse is there a way to find these methods?
You can use Findbugs for this, but there's also a plugin dedicated to this: UCDetector.
查找单个方法用法的最快方法是突出显示该方法,右键单击并转到“参考”,从那里您可以选择搜索位置,如工作区、项目等。
显然,这不是查找项目中所有未使用的方法的好方法,但如果您只是查看一种看起来很奇怪但无法弄清楚为什么需要的方法,那么它可能值得使用。
这是一个相关的问题和答案以及其他一些有用的链接;
在 Java Eclipse 项目中查找未使用的类 如何在 Java 项目中查找未使用/死代码 http://www.velocityreviews.com/forums/t389551-identify-unused-methods.html
http://pmd.sourceforge.net/eclipse/
希望有帮助。