"Code Cleanup": don't remove deprecated imports when file has @file:Suppress("DEPRECATION") annotation
#KT-33594 Fixed
This commit is contained in:
committed by
Yan Zhulanow
parent
4a328981c6
commit
cf5a6274e2
@@ -17,16 +17,16 @@ import org.jetbrains.kotlin.test.JUnit3WithIdeaConfigurationRunner
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
@RunWith(JUnit3WithIdeaConfigurationRunner::class)
|
||||
class KotlinCleanupInspectionTest() : KotlinLightCodeInsightFixtureTestCase() {
|
||||
class KotlinCleanupInspectionTest : KotlinLightCodeInsightFixtureTestCase() {
|
||||
override fun getTestDataPath(): String = PluginTestCaseBase.getTestDataPathBase() + "/inspections/cleanup"
|
||||
|
||||
override fun getProjectDescriptor(): LightProjectDescriptor = KotlinWithJdkAndRuntimeLightProjectDescriptor.INSTANCE
|
||||
|
||||
private fun doTest(result: String, vararg files: String) {
|
||||
private fun doTest(dir: String, result: String, vararg files: String) {
|
||||
myFixture.enableInspections(KotlinCleanupInspection::class.java)
|
||||
myFixture.enableInspections(SortModifiersInspection::class.java)
|
||||
myFixture.enableInspections(RedundantModalityModifierInspection::class.java)
|
||||
myFixture.configureByFiles(*files)
|
||||
myFixture.configureByFiles(*files.map { "$dir/$it" }.toTypedArray())
|
||||
|
||||
val project = myFixture.project
|
||||
val managerEx = InspectionManager.getInstance(project)
|
||||
@@ -35,10 +35,19 @@ class KotlinCleanupInspectionTest() : KotlinLightCodeInsightFixtureTestCase() {
|
||||
val profile = InspectionProjectProfileManager.getInstance(project).currentProfile
|
||||
globalContext.codeCleanup(analysisScope, profile, "Cleanup", null, true)
|
||||
|
||||
myFixture.checkResultByFile(result)
|
||||
myFixture.checkResultByFile("$dir/$result")
|
||||
}
|
||||
|
||||
fun testCleanup() {
|
||||
doTest("cleanup.kt.after", "cleanup.kt", "JavaAnn.java", "deprecatedSymbols.kt")
|
||||
fun testBasic() {
|
||||
doTest("basic", "basic.kt.after", "basic.kt", "JavaAnn.java", "deprecatedSymbols.kt")
|
||||
}
|
||||
|
||||
fun testFileWithAnnotationToSuppressDeprecation() {
|
||||
doTest(
|
||||
"fileWithAnnotationToSuppressDeprecation",
|
||||
"fileWithAnnotationToSuppressDeprecation.kt.after",
|
||||
"fileWithAnnotationToSuppressDeprecation.kt",
|
||||
"deprecatedSymbols.kt"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user