为什么 /**[newline] 并不总是在 Eclipse 中插入包括 @param 和 @return 的 Javadoc 模板?
我正在 Eclipse 中记录代码,并一直使用 /** 后跟 Enter a lot 来插入 Javadoc 模板。然而,由于某种原因,这并不总是有效,它会创建用于编写注释的模板,但不会自动插入 @param 和 @return 文本。如果我将完全相同的方法复制到另一个类,它将插入完整的模板。
如果有人能告诉我为什么在某些情况下它不会这样做,那将是一个很大的帮助。
I'm documenting code in Eclipse and have been using the /** followed by Enter a lot to insert the Javadoc template. However this does not always work for some reason, it will create the template for writing comments but it won't automatically insert the @param and @return text. If I copy the exact same method to another class it will insert the full template.
It would be a big help if anyone could tell me why it won't do this in some situations.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
据我所知,当 Eclipse 不确定您想要记录哪种方法时,通常会发生这种情况。
更可靠的方法是选择要为其创建 JavaDoc 的方法/类等,然后按 ALT + SHIFT + J 或右键单击类大纲中的方法,然后单击“源”->“源”。生成元素注释。
As far as I know this usually happens when Eclipse doesn't know for sure which method you want to document.
A more reliable way would be to select the method/class etc. you want to create the JavaDoc for and press ALT + SHIFT + J or right click on the method in the class outline and clicking Source -> Generate element comment.
它总是对我有用,除非我尝试添加文档的方法上方有注释。下面是一些代码和未记录的方法的示例,其中它不起作用:
我的解决方法通常是临时声明一个变量,将我的方法与注释分开,以便 Eclipse 识别我在做什么...
It always works for me UNLESS there's a comment above the method I'm trying to add the documentation for. Here's an example of some code and an undocumented method where it wouldn't work:
My fix is usually to temporarily declare a variable that separates my method from the comments so the Eclipse recognises what I'm doing...
在我的最后一个版本 Mars 中,这种情况开始偶尔发生。重新启动 Eclipse 即可修复。看来我真的需要每天重新启动Eclipse才能避免这样的随机问题。
This started happening with me occasionally with the last build, Mars. Restarting Eclipse fixes it. It seems that I really need to restart Eclipse every day in order to avoid random problems like this.