我將Spotless與 Gradle 一起使用。我已將其配置為使用 Eclipse 的 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)XML 檔案中配置正確的設定,以便將enum值分別放在自己的行上。
例如,這是它當前格式化源代碼的方式:
public enum Type {
VALUE, OTHER, ANOTHER,
}
...但我想:
public enum Type {
VALUE,
OTHER,
ANOTHER,
}
如果有人知道我可以在 XML 檔案中使用的設定組合來完成此操作,我將不勝感激。我已經嘗試了幾種組合.formatter和/或.indent沒有運氣。
uj5u.com熱心網友回復:
嘗試<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="49"/>
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/444808.html
