使用Scala IDE在Scala中使用线包装长久的函数定义 [英] Line wrapping long curried function definitions in Scala with Scala IDE

查看:130
本文介绍了使用Scala IDE在Scala中使用线包装长久的函数定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个简单的问题,但是我很好奇在Scala中绕线的函数的正确方式。例如,假设我有一个较长的行(如果不够长,你可以假装有更多的参数):

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.

第二,最合理的包装线的方法似乎是在包装线的自动重新加入我在eclipse中格式化,我设置eclipse不会在java中加入包装线,并且在scala IDE格式化部分似乎没有相关设置,我可以找到,所以我不知道如何防止格式命令

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.

推荐答案

Eclipse基于 scalariform ,到目前为止它没有这个选项。但是,它可以在相同的参数列表中分割参数,因此您可以尝试将其格式化为:

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] = {
// ...
}

这篇关于使用Scala IDE在Scala中使用线包装长久的函数定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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