微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

有没有快速的方法来显示Scala控制台中声明的方法的代码?

在我实际将其写入项目之前,我经常使用 Scala控制台来评估和测试代码.如果我想知道变量的内容,我可以输入它并且scala对它进行求值.但是还有一种方法可以显示我输入的方法代码吗?

我知道有UP键显示单行,但我要搜索的是立即显示整个代码.

解决方法

您的主目录中有一个名为.scala_history的文件,其中包含您最近的所有REPL历史记录.我经常将此文件中的代码复制并粘贴到项目源文件中.它与显示REPL中各个方法代码并不完全相同,但它可能有助于您实现相同的目标.

有关REPL中某些相关功能的讨论(历史中的分组语句),请参阅Paul Phillips在this issue中的评论

At some point I implemented the logic for this,but the real obstacle
is jline. It has enough trouble figuring out where the cursor is under
the simplest conditions. Start throwing big multiline blocks into the
history and it breaks down in tears. Would love to see this and
SI-2547 addressed by the community.

I expect to fix this soon too,but it depends on how well the recent
jline work goes. I implemented it long ago,and display issues are the
impediment.

这两个评论都超过两年了,所以我不会屏住呼吸.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐