diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/replaceWith/DeprecatedSymbolUsageInWholeProjectFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/replaceWith/DeprecatedSymbolUsageInWholeProjectFix.kt index 6fd2a04ed26..6f24208b8a1 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/replaceWith/DeprecatedSymbolUsageInWholeProjectFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/replaceWith/DeprecatedSymbolUsageInWholeProjectFix.kt @@ -21,10 +21,10 @@ import com.intellij.openapi.editor.Editor import com.intellij.openapi.project.Project import com.intellij.psi.PsiFile import org.jetbrains.kotlin.diagnostics.Diagnostic -import org.jetbrains.kotlin.idea.quickfix.KotlinSingleIntentionActionFactory -import org.jetbrains.kotlin.idea.references.mainReference import org.jetbrains.kotlin.idea.codeInliner.UsageReplacementStrategy import org.jetbrains.kotlin.idea.codeInliner.replaceUsagesInWholeProject +import org.jetbrains.kotlin.idea.quickfix.KotlinSingleIntentionActionFactory +import org.jetbrains.kotlin.idea.references.mainReference import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.renderer.ClassifierNamePolicy import org.jetbrains.kotlin.renderer.DescriptorRenderer @@ -57,6 +57,7 @@ class DeprecatedSymbolUsageInWholeProjectFix( return when (referenceTarget) { is KtNamedFunction -> referenceTarget is KtProperty -> referenceTarget + is KtTypeAlias -> referenceTarget is KtConstructor<*> -> referenceTarget.getContainingClassOrObject() //TODO: constructor can be deprecated itself else -> null } diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/typeAliases/conflictOnTypeAndAlias.kt b/idea/testData/quickfix/deprecatedSymbolUsage/typeAliases/conflictOnTypeAndAlias.kt index ed4b5fa5b1d..56d283abd56 100644 --- a/idea/testData/quickfix/deprecatedSymbolUsage/typeAliases/conflictOnTypeAndAlias.kt +++ b/idea/testData/quickfix/deprecatedSymbolUsage/typeAliases/conflictOnTypeAndAlias.kt @@ -1,5 +1,6 @@ // "Replace with 'NewClass'" "false" // ACTION: Introduce local variable +// ACTION: Replace usages of 'typealias Old = OldClass' in whole project // ACTION: Replace with 'New' diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/typeAliases/constructorUsageWithConflict.kt b/idea/testData/quickfix/deprecatedSymbolUsage/typeAliases/constructorUsageWithConflict.kt index fa9006d7c0b..968e562b8a4 100644 --- a/idea/testData/quickfix/deprecatedSymbolUsage/typeAliases/constructorUsageWithConflict.kt +++ b/idea/testData/quickfix/deprecatedSymbolUsage/typeAliases/constructorUsageWithConflict.kt @@ -1,6 +1,7 @@ // "Replace with 'New'" "false" // ACTION: Convert to block body // ACTION: Introduce local variable +// ACTION: Replace usages of '(): Old /* = OldClass */' in whole project // ACTION: Replace with 'NewClass(12)' @Deprecated("Use NewClass", replaceWith = ReplaceWith("NewClass")) diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/typeAliases/wholeProject/typealias.after.Declaration.kt b/idea/testData/quickfix/deprecatedSymbolUsage/typeAliases/wholeProject/typealias.after.Declaration.kt new file mode 100644 index 00000000000..787b223fa04 --- /dev/null +++ b/idea/testData/quickfix/deprecatedSymbolUsage/typeAliases/wholeProject/typealias.after.Declaration.kt @@ -0,0 +1,9 @@ +package dependency.d + +class A + +@Deprecated("", ReplaceWith("A", "dependency.d.A")) +typealias OldAlias = A + + +val usage: A? = null \ No newline at end of file diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/typeAliases/wholeProject/typealias.after.kt b/idea/testData/quickfix/deprecatedSymbolUsage/typeAliases/wholeProject/typealias.after.kt new file mode 100644 index 00000000000..658e31ce25f --- /dev/null +++ b/idea/testData/quickfix/deprecatedSymbolUsage/typeAliases/wholeProject/typealias.after.kt @@ -0,0 +1,9 @@ +// "Replace usages of 'typealias OldAlias = A' in whole project" "true" + +package test + +import dependency.d.A + +fun foo(a: A): A? = null + +val usage: A = A() diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/typeAliases/wholeProject/typealias.before.Declaration.kt b/idea/testData/quickfix/deprecatedSymbolUsage/typeAliases/wholeProject/typealias.before.Declaration.kt new file mode 100644 index 00000000000..72d12b4ffb4 --- /dev/null +++ b/idea/testData/quickfix/deprecatedSymbolUsage/typeAliases/wholeProject/typealias.before.Declaration.kt @@ -0,0 +1,9 @@ +package dependency.d + +class A + +@Deprecated("", ReplaceWith("A", "dependency.d.A")) +typealias OldAlias = A + + +val usage: OldAlias? = null \ No newline at end of file diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/typeAliases/wholeProject/typealias.before.Main.kt b/idea/testData/quickfix/deprecatedSymbolUsage/typeAliases/wholeProject/typealias.before.Main.kt new file mode 100644 index 00000000000..28675835f52 --- /dev/null +++ b/idea/testData/quickfix/deprecatedSymbolUsage/typeAliases/wholeProject/typealias.before.Main.kt @@ -0,0 +1,9 @@ +// "Replace usages of 'typealias OldAlias = A' in whole project" "true" + +package test + +import dependency.d.OldAlias + +fun foo(a: OldAlias): OldAlias? = null + +val usage: OldAlias = OldAlias() diff --git a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiFileTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiFileTestGenerated.java index 0ff0a70397c..9b923a7dfff 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiFileTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiFileTestGenerated.java @@ -1601,6 +1601,30 @@ public class QuickFixMultiFileTestGenerated extends AbstractQuickFixMultiFileTes } } + @TestMetadata("idea/testData/quickfix/deprecatedSymbolUsage/typeAliases") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TypeAliases extends AbstractQuickFixMultiFileTest { + public void testAllFilesPresentInTypeAliases() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/quickfix/deprecatedSymbolUsage/typeAliases"), Pattern.compile("^(\\w+)\\.((before\\.Main\\.\\w+)|(test))$"), TargetBackend.ANY, true); + } + + @TestMetadata("idea/testData/quickfix/deprecatedSymbolUsage/typeAliases/wholeProject") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class WholeProject extends AbstractQuickFixMultiFileTest { + public void testAllFilesPresentInWholeProject() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/quickfix/deprecatedSymbolUsage/typeAliases/wholeProject"), Pattern.compile("^(\\w+)\\.((before\\.Main\\.\\w+)|(test))$"), TargetBackend.ANY, true); + } + + @TestMetadata("typealias.before.Main.kt") + public void testTypealias() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/deprecatedSymbolUsage/typeAliases/wholeProject/typealias.before.Main.kt"); + doTestWithExtraFile(fileName); + } + } + } + @TestMetadata("idea/testData/quickfix/deprecatedSymbolUsage/typeArguments") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class)