简体   繁体   English

IntelliJ中的Scala快速修复

[英]Quick fixes for Scala in IntelliJ

I have the following code: 我有以下代码:

    var i = sqrt (30)

To use the sqrt function in Scala I have to import scala.math.sqrt 要在Scala中使用sqrt函数,我必须导入scala.math.sqrt
I am using IntelliJ and I am new in it and Scala. 我正在使用IntelliJ,并且在它和Scala中都是新手。 In Eclipse when programming java, when I use a function where the package is not imported in the source, Eclipse recommends the package and I can insert it by a simple mouse click. 在Eclipse中,当对Java进行编程时,当我使用未在源中导入包的函数时,Eclipse建议使用该包,然后单击鼠标即可插入它。
Is something similar possible in IntelliJ when programming Scala? 在对Scala进行编程时,IntelliJ中是否可能有类似的东西?

Yeah, Intellij supports this kind of feature. 是的,Intellij支持这种功能。 Usually when an import is available, you can just press Alt+Enter and it will be autocompleted. 通常,当导入可用时,您只需按Alt + Enter,它将自动完成。

https://www.jetbrains.com/help/idea/2016.2/auto-import.html https://www.jetbrains.com/help/idea/2016.2/auto-import.html

With that specific class it may fail for some reason, this system is not perfect, but when there are no implicits or ambiguity, it should work really well. 对于那个特定的类,它可能由于某种原因而失败,该系统不是完美的,但是当没有隐式或歧义时,它应该确实运行良好。

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

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