diff --git a/idea/resources/inspectionDescriptions/OldStdlibApi.html b/idea/resources/inspectionDescriptions/OldStdlibApi.html deleted file mode 100644 index 6ad0f3fba94..00000000000 --- a/idea/resources/inspectionDescriptions/OldStdlibApi.html +++ /dev/null @@ -1,5 +0,0 @@ - - -This inspection located pre-1.0 usages of the Kotlin standard library APIs from Java code and replaces them with up-to-date APIs. - - diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml index e53a772908a..506969f042d 100644 --- a/idea/src/META-INF/plugin.xml +++ b/idea/src/META-INF/plugin.xml @@ -1354,13 +1354,6 @@ enabledByDefault="true" level="WARNING"/> - - (false) - if (importStatement != null) return - - for (reference in element.references) { - checkReference(reference)?.let { - holder.registerProblem(element, "Usage of the Kotlin standard library through a deprecated qualified name", - ProblemHighlightType.LIKE_DEPRECATED, it) - - } - } - } - } - } - - private fun checkReference(reference: PsiReference): LocalQuickFix? { - val resolveResult = reference.resolve() - if (resolveResult is PsiClass) { - val fqName = resolveResult.qualifiedName - val newFqName = StdlibMigrationMap.classMap[fqName] - if (newFqName != null) { - return OldStdlibApiFix { project, scope -> - JavaPsiFacade.getInstance(project).findClass(newFqName, scope) - } - } - } - else if (resolveResult is PsiMethod) { - val containingClass = resolveResult.containingClass ?: return null - val fqName = MethodFQName(containingClass.qualifiedName ?: return null, resolveResult.name) - val newFqName = StdlibMigrationMap.methodMap[fqName] - if (newFqName != null) { - return OldStdlibApiFix { project, scope -> - JavaPsiFacade.getInstance(project).findClass(newFqName.className, scope) - ?.findMethodsByName(newFqName.methodName, false) - ?.singleOrNull() - } - } - } - return null - } -} - -class OldStdlibApiFix(val newElementCallback: (Project, GlobalSearchScope) -> PsiElement?) : LocalQuickFix { - override fun getName(): String = "Replace with new qualified name" - override fun getFamilyName(): String = name - - override fun applyFix(project: Project, descriptor: ProblemDescriptor) { - val element = descriptor.psiElement - val reference = element.reference ?: return - val module = ModuleUtil.findModuleForPsiElement(element) - val scope = module?.moduleWithLibrariesScope ?: project.allScope() - - val newElement = newElementCallback(project, scope) ?: return - val newReference = reference.bindToElement(newElement) - - val javaFile = newReference.containingFile as? PsiJavaFile - if (javaFile != null) { - JavaCodeStyleManager.getInstance(project).removeRedundantImports(javaFile) - } - - JavaCodeStyleManager.getInstance(project).shortenClassReferences(newReference) - } -} diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/StdlibMigrationMap.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/StdlibMigrationMap.kt deleted file mode 100644 index 18da5683134..00000000000 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/StdlibMigrationMap.kt +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.idea.inspections - -data class MethodFQName(val className: String, val methodName: String) - -object StdlibMigrationMap { - val methodMap = hashMapOf( - MethodFQName("kotlin.jvm.ClassMapping", "getKotlin") to MethodFQName("kotlin.jvm.JvmClassMappingKt", "getKotlinClass"), - MethodFQName("kotlin.jvm.ClassMapping", "getJava") to MethodFQName("kotlin.jvm.JvmClassMappingKt", "getJavaClass") - ) - - val classMap = hashMapOf( - "kotlin.ArraysKt" to "kotlin.collections.ArraysKt", - "kotlin.CharsKt" to "kotlin.text.CharsKt", - "kotlin.CollectionsKt" to "kotlin.collections.CollectionsKt", - "kotlin.MapsKt" to "kotlin.collections.MapsKt", - "kotlin.RangesKt" to "kotlin.ranges.RangesKt", - "kotlin.SequencesKt" to "kotlin.sequences.SequencesKt", - "kotlin.SetsKt" to "kotlin.collections.SetsKt", - "kotlin.StringsKt" to "kotlin.text.StringsKt", - "kotlin.support.AbstractIterator" to "kotlin.collections.AbstractIterator" - ) -} diff --git a/idea/testData/quickfix/migration/stdlib/.inspection b/idea/testData/quickfix/migration/stdlib/.inspection deleted file mode 100644 index b4534997f49..00000000000 --- a/idea/testData/quickfix/migration/stdlib/.inspection +++ /dev/null @@ -1 +0,0 @@ -org.jetbrains.kotlin.idea.inspections.OldStdlibApiInspection \ No newline at end of file diff --git a/idea/testData/quickfix/migration/stdlib/basic.after.java b/idea/testData/quickfix/migration/stdlib/basic.after.java deleted file mode 100644 index b27da5cee60..00000000000 --- a/idea/testData/quickfix/migration/stdlib/basic.after.java +++ /dev/null @@ -1,10 +0,0 @@ -// "Replace with new qualified name" "true" -// WITH_RUNTIME - -import kotlin.collections.ArraysKt; - -class C { - public void foo(byte[] bytes) { - ArraysKt.component1(bytes); - } -} \ No newline at end of file diff --git a/idea/testData/quickfix/migration/stdlib/basic.before.Main.java b/idea/testData/quickfix/migration/stdlib/basic.before.Main.java deleted file mode 100644 index 4191a1c4e45..00000000000 --- a/idea/testData/quickfix/migration/stdlib/basic.before.Main.java +++ /dev/null @@ -1,10 +0,0 @@ -// "Replace with new qualified name" "true" -// WITH_RUNTIME - -import kotlin.ArraysKt; - -class C { - public void foo(byte[] bytes) { - ArraysKt.component1(bytes); - } -} \ No newline at end of file diff --git a/idea/testData/quickfix/migration/stdlib/importStatic.after.java b/idea/testData/quickfix/migration/stdlib/importStatic.after.java deleted file mode 100644 index cc134c14b3b..00000000000 --- a/idea/testData/quickfix/migration/stdlib/importStatic.after.java +++ /dev/null @@ -1,10 +0,0 @@ -// "Replace with new qualified name" "true" -// WITH_RUNTIME - -import static kotlin.collections.ArraysKt.component1; - -class C { - public void foo(byte[] bytes) { - component1(bytes); - } -} \ No newline at end of file diff --git a/idea/testData/quickfix/migration/stdlib/importStatic.before.Main.java b/idea/testData/quickfix/migration/stdlib/importStatic.before.Main.java deleted file mode 100644 index 5162e175ba6..00000000000 --- a/idea/testData/quickfix/migration/stdlib/importStatic.before.Main.java +++ /dev/null @@ -1,10 +0,0 @@ -// "Replace with new qualified name" "true" -// WITH_RUNTIME - -import static kotlin.ArraysKt.component1; - -class C { - public void foo(byte[] bytes) { - component1(bytes); - } -} \ No newline at end of file diff --git a/idea/testData/quickfix/migration/stdlib/method.after.java b/idea/testData/quickfix/migration/stdlib/method.after.java deleted file mode 100644 index cbe2298b0e4..00000000000 --- a/idea/testData/quickfix/migration/stdlib/method.after.java +++ /dev/null @@ -1,10 +0,0 @@ -// "Replace with new qualified name" "true" -// WITH_RUNTIME - -import kotlin.jvm.JvmClassMappingKt; - -class C { - public void foo(Class cls) { - JvmClassMappingKt.getKotlinClass(cls); - } -} \ No newline at end of file diff --git a/idea/testData/quickfix/migration/stdlib/method.before.Main.java b/idea/testData/quickfix/migration/stdlib/method.before.Main.java deleted file mode 100644 index 566e1d2490b..00000000000 --- a/idea/testData/quickfix/migration/stdlib/method.before.Main.java +++ /dev/null @@ -1,10 +0,0 @@ -// "Replace with new qualified name" "true" -// WITH_RUNTIME - -import kotlin.jvm.ClassMapping; - -class C { - public void foo(Class cls) { - ClassMapping.getKotlin(cls); - } -} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiFileTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiFileTestGenerated.java index ab496090d2d..923989c7b7d 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiFileTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiFileTestGenerated.java @@ -1303,33 +1303,6 @@ public class QuickFixMultiFileTestGenerated extends AbstractQuickFixMultiFileTes } } - @TestMetadata("idea/testData/quickfix/migration/stdlib") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Stdlib extends AbstractQuickFixMultiFileTest { - public void testAllFilesPresentInStdlib() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/quickfix/migration/stdlib"), Pattern.compile("^(\\w+)\\.((before\\.Main\\.\\w+)|(test))$"), true); - } - - @TestMetadata("basic.before.Main.java") - public void testBasic() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/migration/stdlib/basic.before.Main.java"); - doTestWithExtraFile(fileName); - } - - @TestMetadata("importStatic.before.Main.java") - public void testImportStatic() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/migration/stdlib/importStatic.before.Main.java"); - doTestWithExtraFile(fileName); - } - - @TestMetadata("method.before.Main.java") - public void testMethod() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/migration/stdlib/method.before.Main.java"); - doTestWithExtraFile(fileName); - } - } - } @TestMetadata("idea/testData/quickfix/modifiers")