【问题标题】:Is there a way to make the java eclipse formatter not align the @param descriptions?有没有办法让 java eclipse 格式化程序不对齐@param 描述?
【发布时间】:2021-05-10 20:22:25
【问题描述】:

我正在尝试更改 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。我也尝试过实现这一点,但没有任何区别。

注意:我在 Visual Studio Code 中使用格式化程序,但我认为它与在 Eclipse 中使用它相比应该没有什么区别?每次更改后,我都会重新启动 Visual Studio Code 以确保应用更改。

【问题讨论】:

  • “我在 Visual Studio Code 中使用格式化程序,但与在 Eclipse 中使用相比,我认为它没有任何区别” --- @987654321 @ != Eclipse IDE,那么当您使用 Visual Studio Code (由 Microsoft 开发) 时,为什么要询问 Eclipse (由 Eclipse Foundation 开发)?跨度>
  • Eclipse (2020-12) 的 Align Javadoc tags in columns 组合框中,选择 Align descriptions to tag width 或选择 Don't align
  • @Andreas VS Code 中的 Java 语言支持是通过 LSP 实现的无头 Eclipse(顺便说一下,微软是 Eclipse 基金会的成员)。所以它是 Eclipse 格式化程序,但没有格式化程序配置文件对话框。因此提出了这个问题。
  • @Andreas 在 VS Code 中,您还没有相应的 UI。您必须直接编辑org.eclipse.jdt.core.prefs 文件或使用Eclipse IDE 编辑该文件。见stackoverflow.com/a/53510327/6505250

标签: java eclipse javadoc code-formatting


【解决方案1】:

确保您在.settings/org.eclipse.jdt.core.prefs 中有以下内容:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-12-30
    • 2013-01-13
    • 1970-01-01
    • 2013-05-20
    • 1970-01-01
    • 2012-01-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多