eclipse中方法参数中的final
当我尝试将 Final 放入方法参数时,Eclipse 没有帮助。知道如何让它发挥作用吗?
When I try to put final in method parameter eclipse doesn't help. Any idea how to get this to work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这可能是您所能达到的最接近的结果。对每个关键字都执行此操作需要大量工作,但由于关键字的数量有限,因此这是可能的。您可能可以更进一步,为您的方法编写一个模板。
偏好设置>爪哇>编辑>模板
新建>名称(别名)
模式:“final”
This probably will be as close as you can get to it. It would be a lot of work to do this for every keyword, but since there is only so many of them it's possible. You could probably take it a step further and just write a template for your methods.
Preferences > Java > Editor > Templates
New > Name (alias)
Pattern: "final "
我认为这是不可能的。
与此最接近的是设置一个“保存操作”,当您保存文件时,它会自动将最终修饰符添加到方法参数中。
I don't think this is possible.
The closest thing to this is to set a "save action" which will automatically add final modifiers to method parameters when you save the file.
假设您抱怨 Eclipse Java 编辑器的完成行为,我认为您对此无能为力。
如果您确实担心,请创建有关相关 Eclipse 组件的错误报告。更好的是,创建并提交修复问题的补丁。
编辑
我对 Eclipse JDT 未解决的错误/问题进行了搜索,在各种上下文中存在与
final
相关的各种问题,尽管不是专门针对这个问题(据我所知)可以看到)。还值得注意的是,存在大量开放的 JDT 问题……因此具有可行补丁的问题更有可能受到关注。Assuming that you are complaining about the Eclipse Java editor's completion behavior, I don't think there's anything you can do about it.
If it really worries you, create a bug report on the relevant Eclipse component. Better still, create and submit a patch that fixes the problem.
EDIT
I had a trawl through the Eclipse JDT open bugs/issues, and there are various issues related to
final
in various contexts, though not specifically this one (as far as I can see). It is also worth noting that there are a LOT of open JDT issues ... so an issue with a viable patch is much more likely to receive attention.Java 制作参数的副本,在这种情况下,最终参数不会执行任何操作,它不会帮助您通过内部/匿名类访问它。你有想要它的理由吗?
Java makes a copy of the parameters, the final parameter in this case doesn't do anything, it doesn't help you access it through an inner/anonymous class. Is there a reason you want it?