简体   繁体   English

vscode eclipse formatter设置对齐方法参数

[英]Vscode eclipse formatter setting to align method parameters

Which eclipse-formatter setting in vscode will accomplish the following formatting, focusing specifically on the parameter alignment? vscode中哪个eclipse-formatter设置会完成下面的格式化,特别关注参数alignment?

Current当前的

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

Desired想要的

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

This setting helped achieve the desired alignment format.此设置有助于实现所需的 alignment 格式。

<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="18"/>

<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="18"/>

<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="18"/>

<setting id="org.eclipse.jdt.core.formatter.alignment_for_record_components" value="18"/>

This is taken after changing up the settings in an Eclipse IDE.这是在更改 Eclipse IDE 中的设置后拍摄的。 在此处输入图像描述

About Java Formatting, you can refer to Formatting and Linting .关于 Java Formatting,可以参考Formatting and Linting

Download GoogleStyle.xml and edit the following settings:下载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"/>

Then in vscode settings.json , set然后在 vscode settings.json 中,设置

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

You can keep the formatting style that you want instead of parameters being formatted to one line:您可以保留所需的格式样式,而不是将参数格式化为一行: 在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM