简体   繁体   English

使用Scala IDE在Scala中包装长咖喱函数定义

[英]Line wrapping long curried function definitions in Scala with Scala IDE

This is a simple question, but I'm curious about the "right" way to line-wrap curried functions in Scala. 这是一个简单的问题,但我很好奇在Scala中用线条包装curried函数的“正确”方法。 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. 其次,当我在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. 我设置eclipse永远不会在java中加入包装行,并且scala IDE格式化部分中似乎没有相关设置,所以我不知道如何阻止format命令加入这些包装行。

Eclipse is based on scalariform , and so far it doesn't have this option. Eclipse基于标量 ,到目前为止它没有这个选项。 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] = { //... }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM