如何获得 IntelliJ IDEA 代码完成以将静态 Java 方法导入为 Kotlin 顶级函数?

How do I get IntelliJ IDEA code completion to import static Java methods as Kotlin top level functions?

IntelliJ IDEA 代码完成在编辑 Kotlin 代码时建议使用静态 Java 方法,但它导入 Java class 而不是静态方法作为顶级函数(参见 Function Scope).

例如输入 "chrome" 并按 Enter 添加 import org.openqa.selenium.remote.DesiredCapabilities 并将 "chrome" 替换为 "DesiredCapabilities.chrome()" 而不是添加 import org.openqa.selenium.remote.DesiredCapabilities.chrome 并将 "chrome" 保留为 "chrome".

我如何获得 IntelliJ IDEA 代码完成以将静态 Java 方法导入为顶级函数?

我在 IntelliJ IDEA's issue tracker, IDEA-148872, and Dmitry Jemerov (Principal Engineer at JetBrains) converted it to a feature: KT-10277 中创建了一个错误。

据我所知,这尚未实施,所以答案是您目前不能 "get IntelliJ IDEA code completion to import static Java methods as Kotlin top level functions"。

您可以 check/watch KT-10277 查看正在实施的更新。