eclipse中方法参数中的final

发布于 2024-09-19 21:39:34 字数 123 浏览 8 评论 0原文

当我尝试将 Final 放入方法参数时,Eclipse 没有帮助。知道如何让它发挥作用吗?

方法参数中的final

When I try to put final in method parameter eclipse doesn't help. Any idea how to get this to work?

final in method parameter

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

↙温凉少女 2024-09-26 21:39:34

这可能是您所能达到的最接近的结果。对每个关键字都执行此操作需要大量工作,但由于关键字的数量有限,因此这是可能的。您可能可以更进一步,为您的方法编写一个模板。

  1. 偏好设置>爪哇>编辑>模板

  2. 新建>名称(别名)

  3. 模式:“final”

alt text

替代文字

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.

  1. Preferences > Java > Editor > Templates

  2. New > Name (alias)

  3. Pattern: "final "

alt text

alt text

倒数 2024-09-26 21:39:34

我认为这是不可能的。

与此最接近的是设置一个“保存操作”,当您保存文件时,它会自动将最终修饰符添加到方法参数中。

Preferences > Java > Editor > Save Actions

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.

Preferences > Java > Editor > Save Actions
独享拥抱 2024-09-26 21:39:34

假设您抱怨 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.

孤星 2024-09-26 21:39:34

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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文