有没有办法让Java Eclipse格式化程序不对@param描述进行对齐?

4

我想更改Eclipse格式化程序的设置,使其不对param标签描述的缩进进行对齐。

这是我想要实现的效果:

/**
 * Creates a new CTScanData object holding the data from the given file path.
 *
 * @param dataFilePath Path to the file containing the CT scan data.
 * @param width Width of the scan data (left to right).
 * @param depth Depth of the scan data (front to back).
 * @param height Height of the scan data (top to bottom).
 */

以下是此格式化程序目前所执行的操作:

/**
 * Creates a new CTScanData object holding the data from the given file path.
 *
 * @param dataFilePath Path to the file containing the CT scan data.
 * @param width        Width of the scan data (left to right).
 * @param depth        Depth of the scan data (front to back).
 * @param height       Height of the scan data (top to bottom).
 */

我已经尝试了几种设置,但都没有成功。

  1. 在Eclipse格式化程序编辑器中,我禁用了“@param后缩进描述”和“缩进Javadoc标记”。
  2. 在导出的XML文件中,我发现org.eclipse.jdt.core.formatter.comment.indent_parameter_description被设置为false。我也尝试将其设置为true,但没有任何影响。

注意:我正在使用Visual Studio Code中的格式化程序,但我认为与在Eclipse中使用它没有任何区别?每次更改后,我都重新启动了Visual Studio Code以确保更改得到应用。


我正在使用Visual Studio Code中的格式化程序,但我认为与在Eclipse中使用它相比不应该有任何区别。 Visual Studio Code != Eclipse IDE,那么当你使用由Microsoft开发的Visual Studio Code时,为什么要问关于由Eclipse Foundation开发的Eclipse呢? - Andreas
在Eclipse(2020-12)中,在“对齐Javadoc标记为列”组合框中,选择“将描述与标记宽度对齐”或选择“不对齐”。 - Andreas
3
@Andreas,VS Code 中对 Java 语言的支持是通过 LSP 实现的无界面 Eclipse(顺便说一下,Microsoft 是 Eclipse Foundation 的成员)。因此它使用的是 Eclipse 格式化程序,但没有格式化配置对话框。这也就是提出这个问题的原因。 - howlger
2
@Andreas 在 VS Code 中,你还没有相应的用户界面。你需要直接编辑 org.eclipse.jdt.core.prefs 文件或使用 Eclipse IDE 来编辑该文件。请参见 https://dev59.com/GLDla4cB1Zd3GeqP3Bs7#53510327。 - howlger
1个回答

4

请确保在.settings/org.eclipse.jdt.core.prefs中包含以下内容:

org.eclipse.jdt.core.formatter.comment.align_tags_descriptions_grouped=false

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接