该类型的方法从不在本地使用非私有方法警告 [英] The method from the type is never used locally warning for non-private methods

查看:300
本文介绍了该类型的方法从不在本地使用非私有方法警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有很多次私人方法的警告。如何使Eclipse为公共,默认和受保护的方法显示相同(或类似的)警告?

I got this warning a lot of times for private methods. How to make Eclipse show the same (or similar) warning for public, default and protected methods?

推荐答案

很容易,因为搜索方法的使用范围是有限的(只有类本身),并且因为警告是有道理的:由于它是私有的,外部的人没有可以调用该方法,并且由于它没有从项目中调用,该方法可能是无用的,因此是警告。

Doing it for private methods is easy because the scope to search for usage of the method is limited (only the class itself), and because the warning makes sense: since it's private, nobody from the outside can call the method, and since it's not called from inside the project, the method is probably useless, hence the warning.

可以执行默认方法。

但是,对于公共和受保护的方法来说,大部分时间都会产生反效果,因为公共和受保护的方法是您的类的公共接口的一部分,可以由其他类使用,不在当前eclipse项目的范围之内

But doing it for public and protected methods would be counter-productive most of the time, because public and protected methods are part of the public interface of your classes, which could be used by other classes, out of the scope of the current eclipse project.

AFAIK,eclipse没有这样的工具。但 UCDetector 插件可以在项目中找到未使用的代码。谨慎使用!

AFAIK, eclipse doesn't come with such a tool. But the UCDetector plugin can find unused code in your project. Use with caution!

这篇关于该类型的方法从不在本地使用非私有方法警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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