用于对齐方法参数的 vscode eclipse 格式化程序设置

问题描述

vscode 中哪个 eclipse-formatter 设置会完成下面的格式化,特别关注参数对齐?

当前

    public ResponseEntity retrieveAgreement(final String one,final Long someId,final Long anotherId,final Long otherParam) {
        // Omitted
    }

需要

    public ResponseEntity retrieveAgreement(final String one,final Long otherParam) {
        // Omitted
    }

解决方法

关于Java Formatting,可以参考Formatting and Linting

下载 GoogleStyle.xml 并编辑以下设置:

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

然后在 vscode settings.json 中,设置

"java.format.settings.url": "<local path to java-google-style.xml>",

您可以保留所需的格式样式,而不是将参数格式化为一行: enter image description here