首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >使用Eclipse代码格式化程序在自己的行上配置枚举常量

使用Eclipse代码格式化程序在自己的行上配置枚举常量
EN

Stack Overflow用户
提问于 2022-03-02 02:05:47
回答 1查看 196关注 0票数 1

我用的是无污点和Gradle。我已经使用配置的JDT代码格式化程序来使用它:

代码语言:javascript
运行
复制
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的内容是:

代码语言:javascript
运行
复制
<?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值都在自己的行上。

例如,它当前格式化源代码的方式如下:

代码语言:javascript
运行
复制
public enum Type {
  VALUE, OTHER, ANOTHER,
}

...but我想:

代码语言:javascript
运行
复制
public enum Type {
  VALUE,
  OTHER,
  ANOTHER,
}

如果有人知道我可以在XML文件中使用的设置组合来实现这一点,我将非常感激。我尝试过来自.formatter和/或.indent的几个组合,但没有成功。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-03-08 17:01:53

试试<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="49"/>

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71316655

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档