KT-9815 Import insertion (on Alt-Enter) does not work in Evaluate Expression
#KT-9815 Fixed
This commit is contained in:
@@ -103,6 +103,10 @@ public abstract class KtCodeFragment(
|
|||||||
override fun addImportsFromString(imports: String?) {
|
override fun addImportsFromString(imports: String?) {
|
||||||
if (imports == null || imports.isEmpty()) return
|
if (imports == null || imports.isEmpty()) return
|
||||||
myImports.addAll(imports.split(IMPORT_SEPARATOR))
|
myImports.addAll(imports.split(IMPORT_SEPARATOR))
|
||||||
|
|
||||||
|
// we need this code to force re-highlighting, otherwise it does not work by some reason
|
||||||
|
val tempElement = KtPsiFactory(project).createColon()
|
||||||
|
add(tempElement).delete()
|
||||||
}
|
}
|
||||||
|
|
||||||
public fun importsAsImportList(): KtImportList? {
|
public fun importsAsImportList(): KtImportList? {
|
||||||
|
|||||||
+2
-2
@@ -30,7 +30,7 @@ import org.jetbrains.kotlin.idea.completion.test.ExpectedCompletionUtils
|
|||||||
import org.jetbrains.kotlin.idea.completion.test.handlers.AbstractCompletionHandlerTest
|
import org.jetbrains.kotlin.idea.completion.test.handlers.AbstractCompletionHandlerTest
|
||||||
import org.jetbrains.kotlin.idea.test.JetWithJdkAndRuntimeLightProjectDescriptor
|
import org.jetbrains.kotlin.idea.test.JetWithJdkAndRuntimeLightProjectDescriptor
|
||||||
import org.jetbrains.kotlin.idea.util.ImportInsertHelper
|
import org.jetbrains.kotlin.idea.util.ImportInsertHelper
|
||||||
import org.jetbrains.kotlin.idea.util.application.runWriteAction
|
import org.jetbrains.kotlin.idea.util.application.executeWriteCommand
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext
|
import org.jetbrains.kotlin.resolve.BindingContext
|
||||||
@@ -49,7 +49,7 @@ public abstract class AbstractCodeFragmentHighlightingTest : AbstractJetPsiCheck
|
|||||||
fun doTestWithImport(filePath: String) {
|
fun doTestWithImport(filePath: String) {
|
||||||
myFixture.configureByCodeFragment(filePath)
|
myFixture.configureByCodeFragment(filePath)
|
||||||
|
|
||||||
runWriteAction {
|
project.executeWriteCommand("Imports insertion") {
|
||||||
val fileText = FileUtil.loadFile(File(filePath), true)
|
val fileText = FileUtil.loadFile(File(filePath), true)
|
||||||
val file = myFixture.getFile() as KtFile
|
val file = myFixture.getFile() as KtFile
|
||||||
InTextDirectivesUtils.findListWithPrefixes(fileText, "// IMPORT: ").forEach {
|
InTextDirectivesUtils.findListWithPrefixes(fileText, "// IMPORT: ").forEach {
|
||||||
|
|||||||
Reference in New Issue
Block a user