Line wrapping long curried function definitions in Scala with Scala IDE

两盒软妹~` 提交于 2019-12-11 19:48:44

问题


This is a simple question, but I'm curious about the "right" way to line-wrap curried functions in Scala. For example, suppose I have the moderately long line (if it's not long enough, you can pretend there are more parameters):

  def executeFooBarCommand(ce: CommandExecutor)(implicit ec: ExecutionContext): Future[FooBar] = {
    //...
  }

I have two problems regarding wrapping the long definition:

First, I'm not sure what the accepted best practice is for wrapping such lines (or even longer ones.

Second, most reasonable ways of wrapping the line seem to result and in "auto-rejoin" of the wrapped lines when I format in eclipse. I set eclipse never to join wrapped lines in java, and there doesn't seem to be a relevant setting in the scala IDE formatting section that I can find, so I'm not sure how to prevent the format command from joining these wrapped lines.


回答1:


Eclipse is based on scalariform, and so far it doesn't have this option. However, it can split parameters in the same parameter list, so you could try formatting it as:

def executeFooBarCommand( ce: CommandExecutor)(implicit ec: ExecutionContext): Future[FooBar] = { //... }



来源:https://stackoverflow.com/questions/23839804/line-wrapping-long-curried-function-definitions-in-scala-with-scala-ide

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