diff --git a/plugins/kotlin/fir/tests/test/org/jetbrains/kotlin/idea/fir/imports/AbstractK2OptimizeImportsTest.kt b/plugins/kotlin/fir/tests/test/org/jetbrains/kotlin/idea/fir/imports/AbstractK2OptimizeImportsTest.kt index 7f0c8d173a5a..036a566e1dde 100644 --- a/plugins/kotlin/fir/tests/test/org/jetbrains/kotlin/idea/fir/imports/AbstractK2OptimizeImportsTest.kt +++ b/plugins/kotlin/fir/tests/test/org/jetbrains/kotlin/idea/fir/imports/AbstractK2OptimizeImportsTest.kt @@ -40,6 +40,10 @@ abstract class AbstractK2OptimizeImportsTest : AbstractImportsTest() { override val nameCountToUseStarImportDefault: Int get() = Integer.MAX_VALUE + + override fun registerClassImportFilterExtensions(classImportFilterVetoRegexRules: MutableList) { + // Not supported in K2 Mode + } } abstract class AbstractK2JvmOptimizeImportsTest : AbstractK2OptimizeImportsTest() { diff --git a/plugins/kotlin/fir/tests/test/org/jetbrains/kotlin/idea/fir/shortenRefs/AbstractFirShortenRefsTest.kt b/plugins/kotlin/fir/tests/test/org/jetbrains/kotlin/idea/fir/shortenRefs/AbstractFirShortenRefsTest.kt index f217a112b3f2..cc9ff8499aa1 100644 --- a/plugins/kotlin/fir/tests/test/org/jetbrains/kotlin/idea/fir/shortenRefs/AbstractFirShortenRefsTest.kt +++ b/plugins/kotlin/fir/tests/test/org/jetbrains/kotlin/idea/fir/shortenRefs/AbstractFirShortenRefsTest.kt @@ -97,6 +97,10 @@ abstract class AbstractFirShortenRefsTest : AbstractImportsTest() { override val nameCountToUseStarImportDefault: Int get() = Integer.MAX_VALUE + override fun registerClassImportFilterExtensions(classImportFilterVetoRegexRules: MutableList) { + // Not supported in K2 Mode + } + private fun getShorteningResultFile(): File = dataFile().withExtension("txt") private fun findDeclarationsToShorten(file: PsiFile): List { diff --git a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/AbstractImportsTest.kt b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/AbstractImportsTest.kt index 702ac5e794fd..1cff3080427a 100644 --- a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/AbstractImportsTest.kt +++ b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/AbstractImportsTest.kt @@ -11,7 +11,6 @@ import org.jetbrains.kotlin.idea.base.test.InTextDirectivesUtils import org.jetbrains.kotlin.idea.core.formatter.KotlinPackageEntry import org.jetbrains.kotlin.idea.formatter.kotlinCustomSettings import org.jetbrains.kotlin.idea.test.* -import org.jetbrains.kotlin.idea.util.ClassImportFilter import org.jetbrains.kotlin.idea.util.application.executeWriteCommand import org.jetbrains.kotlin.psi.KtFile import java.io.File @@ -80,11 +79,7 @@ abstract class AbstractImportsTest : KotlinLightCodeInsightFixtureTestCase() { codeStyleSettings.PACKAGES_TO_USE_STAR_IMPORTS.addEntry(KotlinPackageEntry(it.trim(), true)) } - InTextDirectivesUtils.findLinesWithPrefixesRemoved(fileText, "// CLASS_IMPORT_FILTER_VETO_REGEX:").forEach { - val regex = Regex(".*${it.trim()}.*") - val filterExtension = ClassImportFilter { classInfo, _ -> !classInfo.fqName.asString().matches(regex) } - ClassImportFilter.EP_NAME.point.registerExtension(filterExtension, testRootDisposable) - } + registerClassImportFilterExtensions(InTextDirectivesUtils.findLinesWithPrefixesRemoved(fileText, "// CLASS_IMPORT_FILTER_VETO_REGEX:")) val log = if (runTestInWriteCommand) { project.executeWriteCommand("") { doTest(file) } @@ -118,6 +113,8 @@ abstract class AbstractImportsTest : KotlinLightCodeInsightFixtureTestCase() { protected open fun updateScriptDependencies(psiFile: KtFile) {} + protected abstract fun registerClassImportFilterExtensions(classImportFilterVetoRegexRules: MutableList) + // returns test log protected abstract fun doTest(file: KtFile): String? diff --git a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/AbstractK1ImportsTest.kt b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/AbstractK1ImportsTest.kt index 0da2f36012b7..66320729f6b1 100644 --- a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/AbstractK1ImportsTest.kt +++ b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/AbstractK1ImportsTest.kt @@ -2,10 +2,20 @@ package org.jetbrains.kotlin import org.jetbrains.kotlin.idea.core.script.k1.ScriptConfigurationManager +import org.jetbrains.kotlin.idea.util.ClassImportFilter import org.jetbrains.kotlin.psi.KtFile +import kotlin.text.trim abstract class AbstractK1ImportsTest : AbstractImportsTest() { override fun updateScriptDependencies(psiFile: KtFile) { ScriptConfigurationManager.updateScriptDependenciesSynchronously(psiFile) } + + override fun registerClassImportFilterExtensions(classImportFilterVetoRegexRules: MutableList) { + classImportFilterVetoRegexRules.forEach { + val regex = Regex(".*${it.trim()}.*") + val filterExtension = ClassImportFilter { classInfo, _ -> !classInfo.fqName.asString().matches(regex) } + ClassImportFilter.EP_NAME.point.registerExtension(filterExtension, testRootDisposable) + } + } } \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/imports/AbstractK1OptimizeImportsTest.kt b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/imports/AbstractK1OptimizeImportsTest.kt index 117d525da359..2c9e48374d3f 100644 --- a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/imports/AbstractK1OptimizeImportsTest.kt +++ b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/imports/AbstractK1OptimizeImportsTest.kt @@ -34,6 +34,10 @@ abstract class AbstractK1OptimizeImportsTest : AbstractImportsTest() { override val nameCountToUseStarImportDefault: Int get() = Integer.MAX_VALUE + + override fun registerClassImportFilterExtensions(classImportFilterVetoRegexRules: MutableList) { + // Not supported in K2 Mode + } } abstract class AbstractK1JvmOptimizeImportsTest : AbstractK1OptimizeImportsTest() {