Eclipse Code Formatter Xml 文档

问题描述

我正在寻找有关 Eclipse 代码格式化程序中不同参数的良好文档来源。我找到了一些关于堆栈溢出的特定参数的好例子,但找不到任何全面的参数列表或不同间距选项的列表。例如,Google formatter file 中的一项设置是

<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_parameter" value="1040"/>

我已经看到了 16、48、80、81、1040 和 1585 的各种事物的对齐值,但似乎找不到任何具体的例子,其中每一个都试图做什么。我知道 16 试图将所有内容都放在一行上,而 80 也是如此,但如果发生换行符,它会将所有参数移动到自己的行中。

这里的任何帮助将不胜感激。

解决方法

目前,vscode-java 使用 Eclipse Formatter 样式,如您提到的 Google Formatter

尽管您已经知道为参数对齐分配特定值的设置。还有另一种设置来控制参数是在一行中包装还是在不同的行中:

<setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="1" />
<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="false"/>

详细信息请查看Java formatting: Keep lines but fix indentation

您可以尝试更改机器上的 google_style.xml 以找到您想要的内容。