我用的是无污点和Gradle。我已经使用配置的JDT代码格式化程序来使用它:
spotless {
groovyGradle {
greclipse("4.21.0").configFile("${rootDir}/config/spotless/eclipe_groovy_formatter.xml")
}
java {
eclipse("4.21.0").configFile("${rootDir}/config/spotless/eclipe_jdt_formatter.xml")
endWithNewline()
importOrder("", "javax", "java")
indentWithSpaces(2)
lineEndings(LineEnding.UNIX)
removeUnusedImports()
trimTrailingWhitespace()
}
}
eclipe_jdt_formatter.xml
的内容是:
<?xml version="1.0" encoding="UTF-8" ?>
<profiles version="12">
<profile kind="CodeFormatterProfile" name="Fulgore Team" version="12">
<setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation" value="80" />
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter" value="false" />
<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="100" />
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="insert" />
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="insert" />
</profile>
</profiles>
问题是,我希望在(Eclipse)文件中配置正确的设置,以便使每个enum
值都在自己的行上。
例如,它当前格式化源代码的方式如下:
public enum Type {
VALUE, OTHER, ANOTHER,
}
...but我想:
public enum Type {
VALUE,
OTHER,
ANOTHER,
}
如果有人知道我可以在XML文件中使用的设置组合来实现这一点,我将非常感激。我尝试过来自.formatter
和/或.indent
的几个组合,但没有成功。
发布于 2022-03-08 17:01:53
试试<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="49"/>
https://stackoverflow.com/questions/71316655
复制相似问题