intellij-ideakotlinstatic-import

IntelliJ Idea changes pasted code


When pasting Kotlin code from another class with "static" imports, e.g.:

@SpringBootTest(webEnvironment = RANDOM_PORT)

I would like IDE to add import like this

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

But instead of that IntelliJ Idea (version 2018.1.1) changes the pasted code to

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)

and adds

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

Is that bug or feature and can I change it?


Solution

  • This is a shortcoming of the current version of the Kotlin plugin. I've filed an issue to improve the behavior in future versions.