IntelliJ Idea:对Scala案例类成员进行冒号调整? [英] IntelliJ Idea: Align on Colon for Scala Case Class Members?

查看:460
本文介绍了IntelliJ Idea:对Scala案例类成员进行冒号调整?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法阻止Idea重新格式化多行案例类成员?

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
)

我花了一些时间在Scala的代码样式设置中,并坚持使用这样的代码样式:

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
)

我没事使用 @formatter:off 将代码混乱,但如果有更好的方法,它会很棒。

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

推荐答案

就像Madoc评论的那样,这些格式在添加新行时可能会导致巨大的变化。此外,虽然在小的情况下,它不会扩展,似乎我们在表中编程......

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...

这篇关于IntelliJ Idea:对Scala案例类成员进行冒号调整?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆