eclipse中有一个工具,eclipse的插件还是可以自动限制访问修饰符的外部程序? [英] Is there a tool in eclipse, a plugin for eclipse, or an external program that can automatically limit access modifiers?

查看:167
本文介绍了eclipse中有一个工具,eclipse的插件还是可以自动限制访问修饰符的外部程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以前在限制访问我的变量/方法/类时非常糟糕,当我不应该使用public时,我更倾向于使用public / p>

我只是想知道是否有任何工具 - 插件,外部或其他 - 可以搜索您的源代码,找到调用您的变量/方法/ classes 并更改可见性(如果它太高)。



所以例如,如果我有一个公共变量,那个类别之外什么都没有那么这个工具就可以减少对私有的访问权限。



主要是需要这样一些旧的项目,它们有许多公共变量。当我回到这些项目再次工作的时候,我希望筛选所有这些都是非常烦人/无效率的,因为我们很长时间。

解决方案

查看 UCDetector:不必要的代码检测器 Eclipse插件。它将为以下问题创建标记(出现在Eclipse问题视图中):




  • 不必要的(死)代码

  • 可见度可以更改为受保护的默认值或
    私人

  • 字段方法,可以是最终的



它还支持Eclipse QuickFixes自动调整会员可见性


I used to be incredibly bad at limiting access of my variables/methods/classes, I tended to use public a hell of a lot when I shouldn't.

I was just wondering if there was any tool - plugin, external or otherwise - that can search your source code, find what calls your variables/methods/classes and changes the visibility if it's too high.

So for example, if I had a public variable and nothing outside that class called it, then the tool would reduce its access to private.

Mainly I need this for some of my older projects that have to many public variables. It would take far to long for me to sift through all of them and would be extremely annoying/inefficient to leave them public, when I come back to these projects to work on them again.

解决方案

Take a look at the UCDetector: Unnecessary Code Detector Eclipse plugin. It will create markers for the following problems (which appear in the Eclipse problem view):

  • Unnecessary (dead) code
  • Code where the visibility could be changed to protected, default or private
  • Methods of fields, which can be final

It also has support for Eclipse QuickFixes to automatically adjust member visibility

这篇关于eclipse中有一个工具,eclipse的插件还是可以自动限制访问修饰符的外部程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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