Eclipse javadoc 注释中的错误换行
我认为 Eclipse 内置的 Java 格式化程序中有一个小但烦人的错误。我有一个 Javadoc 注释,如下所示:
/**
* - - - stuff - - - {@code mTasksBelow}.
*/
结尾处的句点位于第 81 列中。格式化程序设置为在第 80 行包装 Javadoc 注释。不幸的是,当我格式化代码时,它会这样做:
/**
* - - - stuff - - - {@code mTasksBelow}
* .
*/
这会在文本和生成的输出中的句点,因此,例如,以 HTML 形式呈现 Javadoc 的浏览器也会认为可以在此处中断。
除非句点跟在 Javadoc 标记后面,否则这似乎不会发生。 (例如,如果该行以右括号和第 81 列中的句点结尾,则它会在最后一个单词之前正确中断。)
我可以移动换行列,但这只会移动问题。我不想转身 脱机换行符,因为我希望 Javadoc 源代码与生成的输出一样可读。我是否缺少某些设置或者这实际上是一个错误?
There's a minor but annoying bug, I think, in the Eclipse built-in Java formatter. I have a Javadoc comment that looks like this:
/**
* - - - stuff - - - {@code mTasksBelow}.
*/
where period at the end is in column 81. The formatter is set to wrap Javadoc comments at line 80. Unfortunately, when I format the code, it does this:
/**
* - - - stuff - - - {@code mTasksBelow}
* .
*/
This puts white space between the text and the period in the generated output, so a browser rendering the Javadoc in HTML, for instance, will also think it's okay to break there.
This doesn't seem to happen unless the period follows a Javadoc tag. (For instance, if the line ended with a closing parenthesis and a period in column 81, it would correctly break before the last word.)
I could move the wrap column, but that would just move the problem. I don't want to turn
off line breaks, because I like my Javadoc source to be as readable as the generated output. Is there some setting I'm missing or is this actually a bug?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对此,有一个不太有趣的解决方法。要解决此问题,请尝试在 Eclipse 格式化程序中启用“关闭/打开标签”。
窗口->首选项-> Java->格式化程序->编辑->关/开标签 ->启用关闭/打开标签
然后您需要用这些标签包围您的注释,以便格式化程序不会触及它(请注意,这些标签需要位于单独的注释块中,否则 Eclipse 将忽略它们)。例如:
Presto...格式化程序不会碰它。在 Fedora 17 上的 Juno 上进行了测试。希望有帮助。
Well there is a less than fun work around for this. To work around it try enabling Off/On Tags in the Eclipse formatter.
Window -> Preferences -> Java -> Formatter -> Edit -> Off/On Tags -> Enable Off/On tags
Then you need to surround your comment with these tags so the formatter does not touch it (Note that the tags need to be in separate comment blocks else Eclipse will ignore them). In example:
Presto... formatter won't touch it. Tested on Juno on Fedora 17. Hope that helps.
好吧,它现在是一个新的 Eclipse bug。显然它仍然存在于最初的 Indigo 版本中。
Well, it is now a new Eclipse bug. It will evidently still be present in the initial Indigo release.