自动Java到Scala源代码转换? [英] Automated Java to Scala source code conversion?

查看:1428
本文介绍了自动Java到Scala源代码转换?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(是的,我知道我可以从Scala调用Java代码;但这没有意义;我想删除Java代码,而不是保留它并且必须查看它并永远维护它!)

(Yes I know I can call Java code from Scala; but that is pointless; I want to DELETE the Java code, not keep it around and have to look at it and maintain it forever!)

是否有任何实用程序可以将Java源代码转换为Scala源代码?

Are there any utilities out there to convert Java source to Scala source?

我认为从理论上说应该可以实现最小的损失。

I believe theoretically it should be possible to accomplish with minimal lossage.

我找到了这个,但它似乎无效,可能有缺陷/不完整......
http://sourceforge.net/projects/java2scala/

I have found this but it seems inactive, probably buggy/incomplete... http://sourceforge.net/projects/java2scala/

任何替代方案?

推荐答案

IntelliJ有点,sorta,这样做。您需要使用Java源打开项目。然后,您可以将表达式,方法或整个类复制/粘贴到.scala文件中。这会转换为等效的Scala代码。

IntelliJ kinda, sorta, does this. You need to open a project with your Java sources. You can then copy/paste expressions, methods, or entire classes in to a .scala file. This converts to equivalent Scala code.

转换的保真度并不完美,因此,它还不支持批量转换。

The fidelity of conversion isn't perfect, and, for this reason, it doesn't support a bulk conversion yet.

我建议使用最新版本的 IntelliJ Scala插件。社区版是免费的。

I recommend using the latest version of IntelliJ and the Scala Plugin. The Community Edition is free.

除此之外,Paul Phillips曾经开始 Scalify 项目将代码从Java翻译成Scala(或者,可能是您喜欢的语言),甚至在此过程中改进它!他在此视频中解释了这一概念。然而,这种努力停滞不前,大概是因为他把注意力转向直接贡献给Scala编译器和标准库。

Aside from this, Paul Phillips once started the Scalify project to translate code from Java to Scala (or, potentially, your favourite language), and even improve it in the process! He explains the concept in this video. However this effort was stalled, presumably because he turned his attention to directly contributing to the Scala compiler and standard library.

这篇关于自动Java到Scala源代码转换?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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