IntelliJ Idea: Align on Colon for Scala Case Class Members?

元气小坏坏 提交于 2019-12-13 06:45:53

问题


Is there a way to prevent Idea from reformatting multiline case class members?

Intended result
(position of the colon is not so important, but the alignment of the type annotations would be great)

case class ApiError(
  timestamp : LocalDateTime,
  status    : Int,
  code      : Option[String],
  message   : String
)

I've spent some time in the Code Styling settings for Scala and am stuck with code styling like this:

case class ApiError(
  timestamp: LocalDateTime,
  status: Int,
  code: Option[String],
  message: String
)

I am okay with cluttering the code with @formatter:off, but it would be awesome if there was a better way.


回答1:


Just like Madoc commented, those kind of formats may lead to huge changes when adding a new line. Also, while pretty in small cases, it doesn't scale, and it seems we are programming in tables...



来源:https://stackoverflow.com/questions/35993120/intellij-idea-align-on-colon-for-scala-case-class-members

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!