【问题标题】:IntelliJ Idea changes pasted codeIntelliJ Idea 更改粘贴的代码
【发布时间】:2018-04-20 07:18:17
【问题描述】:

当使用“静态”导入从另一个类粘贴 Kotlin 代码时,例如:

@SpringBootTest(webEnvironment = RANDOM_PORT)

我希望 IDE 像这样添加导入

import org.springframework.boot.test.context.SpringBootTest.WebEnvironment.*

但不是那个 IntelliJ Idea(版本 2018.1.1)将粘贴的代码更改为

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)

并添加

import org.springframework.boot.test.context.SpringBootTest

这是错误或功能,我可以更改吗?

【问题讨论】:

  • Settings->General->Auto Import 中,您会发现Insert imports on paste 具有可能的值All/Ask/None。但是我认为没有办法告诉 IntelliJ 默认使用静态导入

标签: intellij-idea kotlin static-import


【解决方案1】:

这是 Kotlin 插件当前版本的一个缺点。我已提交an issue 以改进未来版本中的行为。

【讨论】:

    猜你喜欢
    • 2017-11-30
    • 2020-07-10
    • 2017-06-27
    • 1970-01-01
    • 2020-09-27
    • 1970-01-01
    • 1970-01-01
    • 2010-12-15
    • 2014-08-01
    相关资源
    最近更新 更多