From 09b58403b98e9e31ddd0cefff7b88e0703e27e37 Mon Sep 17 00:00:00 2001 From: Dmitry Gridin Date: Thu, 28 Mar 2019 17:33:26 +0700 Subject: [PATCH] Improve "ReplaceWith" for class with generic parameter #KT-27089 Fixed --- .../ClassUsageReplacementStrategy.kt | 29 ++++++++-- .../replaceWith/DeprecatedSymbolUsageFix.kt | 2 +- .../DeprecatedSymbolUsageFixBase.kt | 55 ++++++++++++++++--- .../kotlin/idea/util/expressionExt.kt | 18 ++++++ .../constructorUsageWithTypeArgument.kt | 2 +- .../constructorUsageWithTypeArgument.kt.after | 2 +- .../constructorUsageWithTypeArgument4.kt | 9 +++ ...constructorUsageWithTypeArgument4.kt.after | 9 +++ .../constructorUsageWithTypeArgument5.kt | 9 +++ ...constructorUsageWithTypeArgument5.kt.after | 9 +++ .../constructorUsageWithTypeArgument6.kt | 15 +++++ ...constructorUsageWithTypeArgument6.kt.after | 15 +++++ .../constructorUsageWithTypeArgument7.kt | 14 +++++ ...constructorUsageWithTypeArgument7.kt.after | 14 +++++ ...UsageWithTypeArgumentWithoutSpecifyType.kt | 9 +++ ...ithTypeArgumentWithoutSpecifyType.kt.after | 9 +++ .../typeArguments/emptyVarargRuntime.kt | 2 +- .../typeArguments/emptyVarargRuntime.kt.after | 2 +- .../explicitInPatternImplicitInUsage.kt | 2 +- .../explicitInPatternImplicitInUsage.kt.after | 2 +- .../typeArguments/explicitTypeArg.kt | 2 +- .../typeArguments/explicitTypeArg.kt.after | 2 +- .../typeArguments/keepOriginalIfQualified.kt | 2 +- .../keepOriginalIfQualified.kt.after | 4 +- .../idea/quickfix/QuickFixTestGenerated.java | 25 +++++++++ 25 files changed, 238 insertions(+), 25 deletions(-) create mode 100644 idea/src/org/jetbrains/kotlin/idea/util/expressionExt.kt create mode 100644 idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgument4.kt create mode 100644 idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgument4.kt.after create mode 100644 idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgument5.kt create mode 100644 idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgument5.kt.after create mode 100644 idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgument6.kt create mode 100644 idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgument6.kt.after create mode 100644 idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgument7.kt create mode 100644 idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgument7.kt.after create mode 100644 idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgumentWithoutSpecifyType.kt create mode 100644 idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgumentWithoutSpecifyType.kt.after diff --git a/idea/src/org/jetbrains/kotlin/idea/codeInliner/ClassUsageReplacementStrategy.kt b/idea/src/org/jetbrains/kotlin/idea/codeInliner/ClassUsageReplacementStrategy.kt index a81d781fdea..9e1eb77c322 100644 --- a/idea/src/org/jetbrains/kotlin/idea/codeInliner/ClassUsageReplacementStrategy.kt +++ b/idea/src/org/jetbrains/kotlin/idea/codeInliner/ClassUsageReplacementStrategy.kt @@ -17,10 +17,15 @@ package org.jetbrains.kotlin.idea.codeInliner import com.intellij.openapi.project.Project +import org.jetbrains.kotlin.descriptors.impl.TypeAliasConstructorDescriptor +import org.jetbrains.kotlin.idea.caches.resolve.resolveToCall import org.jetbrains.kotlin.idea.core.ShortenReferences import org.jetbrains.kotlin.idea.core.replaced import org.jetbrains.kotlin.idea.references.KtSimpleNameReference import org.jetbrains.kotlin.idea.references.mainReference +import org.jetbrains.kotlin.idea.stubindex.KotlinClassShortNameIndex +import org.jetbrains.kotlin.idea.util.replaceOrCreateTypeArgumentList +import org.jetbrains.kotlin.ir.expressions.typeParametersCount import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.getQualifiedExpressionForSelectorOrThis @@ -87,15 +92,29 @@ class ClassUsageReplacementStrategy( private fun replaceConstructorCallWithOtherTypeConstruction(callExpression: KtCallExpression): KtElement { val referenceExpression = typeReplacement?.referenceExpression ?: error("Couldn't find referenceExpression") - callExpression.calleeExpression?.replace(referenceExpression) + val classFromReplacement = KotlinClassShortNameIndex + .getInstance()[referenceExpression.text, callExpression.project, callExpression.resolveScope] + .firstOrNull() + + val replacementTypeArgumentList = typeReplacement.typeArgumentList + val replacementTypeArgumentCount = classFromReplacement?.typeParameters?.size + ?: replacementTypeArgumentList?.arguments?.size val typeArgumentList = callExpression.typeArgumentList - if (typeArgumentList != null && typeReplacement.typeArguments.size != typeArgumentList.arguments.size) { - val newTypeArgumentList = typeReplacement.typeArgumentList - if (newTypeArgumentList != null) typeArgumentList.replace(newTypeArgumentList.copy()) - else typeArgumentList.delete() + val callDescriptor = callExpression.resolveToCall() + ?.resultingDescriptor + ?.let { if (it is TypeAliasConstructorDescriptor) it.underlyingConstructorDescriptor else it } + val typeArgumentCount = callDescriptor?.typeParametersCount ?: typeArgumentList?.arguments?.size + + if (typeArgumentCount != replacementTypeArgumentCount) { + if (replacementTypeArgumentList == null) typeArgumentList?.delete() + else callExpression.replaceOrCreateTypeArgumentList( + replacementTypeArgumentList.copy() as KtTypeArgumentList + ) } + callExpression.calleeExpression?.replace(referenceExpression) + val expressionToReplace = callExpression.getQualifiedExpressionForSelectorOrThis() val newExpression = if (typeReplacementQualifierAsExpression != null) factory.createExpressionByPattern("$0.$1", typeReplacementQualifierAsExpression, callExpression) diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/replaceWith/DeprecatedSymbolUsageFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/replaceWith/DeprecatedSymbolUsageFix.kt index fa45c333f79..2a0283e39fa 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/replaceWith/DeprecatedSymbolUsageFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/replaceWith/DeprecatedSymbolUsageFix.kt @@ -61,7 +61,7 @@ class DeprecatedSymbolUsageFix( if (targetDescriptors.isEmpty()) return false return targetDescriptors.all { - fetchReplaceWithPattern(it, import.project) != null + fetchReplaceWithPattern(it, import.project, null) != null } } } diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/replaceWith/DeprecatedSymbolUsageFixBase.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/replaceWith/DeprecatedSymbolUsageFixBase.kt index dcf133521fa..e75107d8056 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/replaceWith/DeprecatedSymbolUsageFixBase.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/replaceWith/DeprecatedSymbolUsageFixBase.kt @@ -28,6 +28,7 @@ import org.jetbrains.kotlin.descriptors.impl.TypeAliasConstructorDescriptor import org.jetbrains.kotlin.diagnostics.Diagnostic import org.jetbrains.kotlin.diagnostics.DiagnosticFactory import org.jetbrains.kotlin.diagnostics.Errors +import org.jetbrains.kotlin.idea.caches.KotlinShortNamesCache import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade import org.jetbrains.kotlin.idea.codeInliner.CallableUsageReplacementStrategy import org.jetbrains.kotlin.idea.codeInliner.ClassUsageReplacementStrategy @@ -37,9 +38,12 @@ import org.jetbrains.kotlin.idea.quickfix.KotlinQuickFixAction import org.jetbrains.kotlin.idea.references.mainReference import org.jetbrains.kotlin.idea.references.resolveMainReferenceToDescriptors import org.jetbrains.kotlin.idea.search.restrictToKotlinSources +import org.jetbrains.kotlin.idea.util.replaceOrCreateTypeArgumentList +import org.jetbrains.kotlin.ir.expressions.typeParametersCount import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType import org.jetbrains.kotlin.psi.psiUtil.isCallee +import org.jetbrains.kotlin.psi.psiUtil.referenceExpression import org.jetbrains.kotlin.renderer.DescriptorRenderer import org.jetbrains.kotlin.resolve.annotations.argumentValue import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall @@ -76,7 +80,11 @@ abstract class DeprecatedSymbolUsageFixBase( protected abstract fun invoke(replacementStrategy: UsageReplacementStrategy, project: Project, editor: Editor?) companion object { - fun fetchReplaceWithPattern(descriptor: DeclarationDescriptor, project: Project): ReplaceWith? { + fun fetchReplaceWithPattern( + descriptor: DeclarationDescriptor, + project: Project, + contextElement: KtSimpleNameExpression? + ): ReplaceWith? { val annotation = descriptor.annotations.findAnnotation(KotlinBuiltIns.FQ_NAMES.deprecated) ?: return null val replaceWithValue = annotation.argumentValue(kotlin.Deprecated::replaceWith.name)?.safeAs()?.value ?: return null @@ -92,7 +100,35 @@ abstract class DeprecatedSymbolUsageFixBase( } ) return null - return ReplaceWith(pattern, imports) + return ReplaceWith(pattern.applyContextElement(contextElement, descriptor), imports) + } + + private fun String.applyContextElement( + element: KtSimpleNameExpression?, + descriptor: DeclarationDescriptor + ): String { + if (element == null) return this + val expressionFromPattern = KtPsiFactory(element).createExpressionIfPossible(this) as? KtCallExpression ?: return this + val methodFromPattern = expressionFromPattern.referenceExpression()?.let { name -> + KotlinShortNamesCache(element.project).getMethodsByName( + name.text, + element.resolveScope + ).firstOrNull() + } + + val patternTypeArgumentList = expressionFromPattern.typeArgumentList + val patternTypeArgumentCount = methodFromPattern?.typeParameterList?.typeParameters?.size + ?: patternTypeArgumentList?.arguments?.size + ?: return this + + val typeArgumentList = (element.parent as? KtCallExpression)?.typeArgumentList + return if (descriptor is CallableDescriptor && descriptor.typeParametersCount == patternTypeArgumentCount || + patternTypeArgumentCount == typeArgumentList?.arguments?.size + ) { + if (typeArgumentList != null) expressionFromPattern.replaceOrCreateTypeArgumentList(typeArgumentList.copy() as KtTypeArgumentList) + else patternTypeArgumentList?.delete() + expressionFromPattern.text + } else this } data class Data( @@ -120,7 +156,7 @@ abstract class DeprecatedSymbolUsageFixBase( else -> throw IllegalStateException("Bad QuickFixRegistrar configuration") } - val replacement = fetchReplaceWithPattern(descriptor, nameExpression.project) ?: return null + val replacement = fetchReplaceWithPattern(descriptor, nameExpression.project, nameExpression) ?: return null return Data(nameExpression, replacement, descriptor) } @@ -135,10 +171,10 @@ abstract class DeprecatedSymbolUsageFixBase( val bindingContext = resolutionFacade.analyze(element, BodyResolveMode.PARTIAL) var target = element.mainReference.resolveToDescriptors(bindingContext).singleOrNull() ?: return null - var replacePatternFromSymbol = fetchReplaceWithPattern(target, resolutionFacade.project) + var replacePatternFromSymbol = fetchReplaceWithPattern(target, resolutionFacade.project, element) if (replacePatternFromSymbol == null && target is ConstructorDescriptor) { target = target.containingDeclaration - replacePatternFromSymbol = fetchReplaceWithPattern(target, resolutionFacade.project) + replacePatternFromSymbol = fetchReplaceWithPattern(target, resolutionFacade.project, element) } // check that ReplaceWith hasn't changed @@ -165,7 +201,7 @@ abstract class DeprecatedSymbolUsageFixBase( ?.getStrictParentOfType() if (typeAlias != null) { val usedConstructorWithOwnReplaceWith = usedConstructorsWithOwnReplaceWith( - element.project, target, typeAlias + element.project, target, typeAlias, element ) if (usedConstructorWithOwnReplaceWith != null) { @@ -204,10 +240,13 @@ abstract class DeprecatedSymbolUsageFixBase( } private fun usedConstructorsWithOwnReplaceWith( - project: Project, classifier: ClassifierDescriptorWithTypeParameters, typeAlias: PsiElement + project: Project, + classifier: ClassifierDescriptorWithTypeParameters, + typeAlias: PsiElement, + contextElement: KtSimpleNameExpression ): ConstructorDescriptor? { val specialReplaceWithForConstructor = classifier.constructors.filter { - fetchReplaceWithPattern(it, project) != null + fetchReplaceWithPattern(it, project, contextElement) != null }.toSet() if (specialReplaceWithForConstructor.isEmpty()) { diff --git a/idea/src/org/jetbrains/kotlin/idea/util/expressionExt.kt b/idea/src/org/jetbrains/kotlin/idea/util/expressionExt.kt new file mode 100644 index 00000000000..6b23d193426 --- /dev/null +++ b/idea/src/org/jetbrains/kotlin/idea/util/expressionExt.kt @@ -0,0 +1,18 @@ +/* + * Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.idea.util + +import org.jetbrains.kotlin.psi.KtCallExpression +import org.jetbrains.kotlin.psi.KtTypeArgumentList + + +fun KtCallExpression.replaceOrCreateTypeArgumentList(newTypeArgumentList: KtTypeArgumentList) { + if (typeArgumentList != null) typeArgumentList?.replace(newTypeArgumentList) + else addAfter( + newTypeArgumentList, + calleeExpression + ) +} \ No newline at end of file diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgument.kt b/idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgument.kt index 5d85509d3c8..2eb9a1a8b45 100644 --- a/idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgument.kt +++ b/idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgument.kt @@ -1,4 +1,4 @@ -// "Replace with 'NewClass'" "true" +// "Replace with 'NewClass'" "true" package ppp @Deprecated("renamed", ReplaceWith("NewClass")) diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgument.kt.after b/idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgument.kt.after index b0eb3677902..6131a360e85 100644 --- a/idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgument.kt.after +++ b/idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgument.kt.after @@ -1,4 +1,4 @@ -// "Replace with 'NewClass'" "true" +// "Replace with 'NewClass'" "true" package ppp @Deprecated("renamed", ReplaceWith("NewClass")) diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgument4.kt b/idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgument4.kt new file mode 100644 index 00000000000..69e417aee7e --- /dev/null +++ b/idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgument4.kt @@ -0,0 +1,9 @@ +// "Replace with 'Factory()'" "true" +// WITH_RUNTIME + +class Foo @Deprecated("", ReplaceWith("Factory()")) constructor() +fun Factory(): Foo = TODO() + +fun baz() { + val foo = Foo() +} \ No newline at end of file diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgument4.kt.after b/idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgument4.kt.after new file mode 100644 index 00000000000..39fd5447235 --- /dev/null +++ b/idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgument4.kt.after @@ -0,0 +1,9 @@ +// "Replace with 'Factory()'" "true" +// WITH_RUNTIME + +class Foo @Deprecated("", ReplaceWith("Factory()")) constructor() +fun Factory(): Foo = TODO() + +fun baz() { + val foo = Factory() +} \ No newline at end of file diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgument5.kt b/idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgument5.kt new file mode 100644 index 00000000000..e9236c2f460 --- /dev/null +++ b/idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgument5.kt @@ -0,0 +1,9 @@ +// "Replace with 'Factory()'" "true" +// WITH_RUNTIME + +class Foo @Deprecated("", ReplaceWith("Factory()")) constructor() +fun Factory(): Foo = TODO() + +fun baz() { + val foo = Foo() +} \ No newline at end of file diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgument5.kt.after b/idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgument5.kt.after new file mode 100644 index 00000000000..7405c8aec96 --- /dev/null +++ b/idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgument5.kt.after @@ -0,0 +1,9 @@ +// "Replace with 'Factory()'" "true" +// WITH_RUNTIME + +class Foo @Deprecated("", ReplaceWith("Factory()")) constructor() +fun Factory(): Foo = TODO() + +fun baz() { + val foo = Factory() +} \ No newline at end of file diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgument6.kt b/idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgument6.kt new file mode 100644 index 00000000000..701df8867d8 --- /dev/null +++ b/idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgument6.kt @@ -0,0 +1,15 @@ +// "Replace with 'test.New'" "true" +// WITH_RUNTIME + +package test + +abstract class Main + +@Deprecated("", ReplaceWith("test.New")) +class Old : Main() + +class New : Main() + +fun test() { + val main = Old() +} \ No newline at end of file diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgument6.kt.after b/idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgument6.kt.after new file mode 100644 index 00000000000..5c4b67405b9 --- /dev/null +++ b/idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgument6.kt.after @@ -0,0 +1,15 @@ +// "Replace with 'test.New'" "true" +// WITH_RUNTIME + +package test + +abstract class Main + +@Deprecated("", ReplaceWith("test.New")) +class Old : Main() + +class New : Main() + +fun test() { + val main = New() +} \ No newline at end of file diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgument7.kt b/idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgument7.kt new file mode 100644 index 00000000000..80b659be2a3 --- /dev/null +++ b/idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgument7.kt @@ -0,0 +1,14 @@ +// "Replace with 'New'" "true" +// WITH_RUNTIME +// ERROR: Type inference failed: Not enough information to infer parameter T in constructor New()
Please specify it explicitly.
+ +abstract class Main + +@Deprecated("", ReplaceWith("New")) +class Old : Main() + +class New : Main() + +fun test() { + val main = Old() +} \ No newline at end of file diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgument7.kt.after b/idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgument7.kt.after new file mode 100644 index 00000000000..7819790d5f2 --- /dev/null +++ b/idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgument7.kt.after @@ -0,0 +1,14 @@ +// "Replace with 'New'" "true" +// WITH_RUNTIME +// ERROR: Type inference failed: Not enough information to infer parameter T in constructor New()
Please specify it explicitly.
+ +abstract class Main + +@Deprecated("", ReplaceWith("New")) +class Old : Main() + +class New : Main() + +fun test() { + val main = New() +} \ No newline at end of file diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgumentWithoutSpecifyType.kt b/idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgumentWithoutSpecifyType.kt new file mode 100644 index 00000000000..f1fbfe08cef --- /dev/null +++ b/idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgumentWithoutSpecifyType.kt @@ -0,0 +1,9 @@ +// "Replace with 'Factory()'" "true" +// WITH_RUNTIME + +class Foo @Deprecated("", ReplaceWith("Factory()")) constructor() +fun Factory(): Foo = TODO() + +fun baz() { + val foo: Foo = Foo() +} \ No newline at end of file diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgumentWithoutSpecifyType.kt.after b/idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgumentWithoutSpecifyType.kt.after new file mode 100644 index 00000000000..cf6209d60e0 --- /dev/null +++ b/idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgumentWithoutSpecifyType.kt.after @@ -0,0 +1,9 @@ +// "Replace with 'Factory()'" "true" +// WITH_RUNTIME + +class Foo @Deprecated("", ReplaceWith("Factory()")) constructor() +fun Factory(): Foo = TODO() + +fun baz() { + val foo: Foo = Factory() +} \ No newline at end of file diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/typeArguments/emptyVarargRuntime.kt b/idea/testData/quickfix/deprecatedSymbolUsage/typeArguments/emptyVarargRuntime.kt index 8c446dbf3b4..59bd40861e3 100644 --- a/idea/testData/quickfix/deprecatedSymbolUsage/typeArguments/emptyVarargRuntime.kt +++ b/idea/testData/quickfix/deprecatedSymbolUsage/typeArguments/emptyVarargRuntime.kt @@ -1,4 +1,4 @@ -// "Replace with 'newFun(*elements)'" "true" +// "Replace with 'newFun(*elements)'" "true" // WITH_RUNTIME @Deprecated("", ReplaceWith("newFun(*elements)")) diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/typeArguments/emptyVarargRuntime.kt.after b/idea/testData/quickfix/deprecatedSymbolUsage/typeArguments/emptyVarargRuntime.kt.after index fdc4273857b..3e954626823 100644 --- a/idea/testData/quickfix/deprecatedSymbolUsage/typeArguments/emptyVarargRuntime.kt.after +++ b/idea/testData/quickfix/deprecatedSymbolUsage/typeArguments/emptyVarargRuntime.kt.after @@ -1,4 +1,4 @@ -// "Replace with 'newFun(*elements)'" "true" +// "Replace with 'newFun(*elements)'" "true" // WITH_RUNTIME @Deprecated("", ReplaceWith("newFun(*elements)")) diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/typeArguments/explicitInPatternImplicitInUsage.kt b/idea/testData/quickfix/deprecatedSymbolUsage/typeArguments/explicitInPatternImplicitInUsage.kt index 9d5b6d65730..bdadd225806 100644 --- a/idea/testData/quickfix/deprecatedSymbolUsage/typeArguments/explicitInPatternImplicitInUsage.kt +++ b/idea/testData/quickfix/deprecatedSymbolUsage/typeArguments/explicitInPatternImplicitInUsage.kt @@ -1,4 +1,4 @@ -// "Replace with 'newFun()'" "true" +// "Replace with 'newFun()'" "true" @Deprecated("", ReplaceWith("newFun()")) fun oldFun(): T? { diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/typeArguments/explicitInPatternImplicitInUsage.kt.after b/idea/testData/quickfix/deprecatedSymbolUsage/typeArguments/explicitInPatternImplicitInUsage.kt.after index 3f20bd7b1d7..c81ba2fc616 100644 --- a/idea/testData/quickfix/deprecatedSymbolUsage/typeArguments/explicitInPatternImplicitInUsage.kt.after +++ b/idea/testData/quickfix/deprecatedSymbolUsage/typeArguments/explicitInPatternImplicitInUsage.kt.after @@ -1,4 +1,4 @@ -// "Replace with 'newFun()'" "true" +// "Replace with 'newFun()'" "true" @Deprecated("", ReplaceWith("newFun()")) fun oldFun(): T? { diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/typeArguments/explicitTypeArg.kt b/idea/testData/quickfix/deprecatedSymbolUsage/typeArguments/explicitTypeArg.kt index 0fefbcd15d8..2250fc2e245 100644 --- a/idea/testData/quickfix/deprecatedSymbolUsage/typeArguments/explicitTypeArg.kt +++ b/idea/testData/quickfix/deprecatedSymbolUsage/typeArguments/explicitTypeArg.kt @@ -1,4 +1,4 @@ -// "Replace with 'newFun()'" "true" +// "Replace with 'newFun()'" "true" @Deprecated("", ReplaceWith("newFun()")) fun oldFun() { diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/typeArguments/explicitTypeArg.kt.after b/idea/testData/quickfix/deprecatedSymbolUsage/typeArguments/explicitTypeArg.kt.after index f3eb074dad6..55bbe22e460 100644 --- a/idea/testData/quickfix/deprecatedSymbolUsage/typeArguments/explicitTypeArg.kt.after +++ b/idea/testData/quickfix/deprecatedSymbolUsage/typeArguments/explicitTypeArg.kt.after @@ -1,4 +1,4 @@ -// "Replace with 'newFun()'" "true" +// "Replace with 'newFun()'" "true" @Deprecated("", ReplaceWith("newFun()")) fun oldFun() { diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/typeArguments/keepOriginalIfQualified.kt b/idea/testData/quickfix/deprecatedSymbolUsage/typeArguments/keepOriginalIfQualified.kt index 2d1bc62bacb..16f83397790 100644 --- a/idea/testData/quickfix/deprecatedSymbolUsage/typeArguments/keepOriginalIfQualified.kt +++ b/idea/testData/quickfix/deprecatedSymbolUsage/typeArguments/keepOriginalIfQualified.kt @@ -1,4 +1,4 @@ -// "Replace with 'newFun()'" "true" +// "Replace with 'newFun()'" "true" @Deprecated("", ReplaceWith("newFun()")) fun oldFun() { diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/typeArguments/keepOriginalIfQualified.kt.after b/idea/testData/quickfix/deprecatedSymbolUsage/typeArguments/keepOriginalIfQualified.kt.after index 4b57b3fb9fb..a198a0095d2 100644 --- a/idea/testData/quickfix/deprecatedSymbolUsage/typeArguments/keepOriginalIfQualified.kt.after +++ b/idea/testData/quickfix/deprecatedSymbolUsage/typeArguments/keepOriginalIfQualified.kt.after @@ -1,4 +1,4 @@ -// "Replace with 'newFun()'" "true" +// "Replace with 'newFun()'" "true" @Deprecated("", ReplaceWith("newFun()")) fun oldFun() { @@ -8,5 +8,5 @@ fun oldFun() { fun newFun(){} fun foo() { - newFun() + newFun() } diff --git a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java index adcf43dfaf1..bf4eb5ce510 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java @@ -6056,6 +6056,31 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest { runTest("idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgument3.kt"); } + @TestMetadata("constructorUsageWithTypeArgument4.kt") + public void testConstructorUsageWithTypeArgument4() throws Exception { + runTest("idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgument4.kt"); + } + + @TestMetadata("constructorUsageWithTypeArgument5.kt") + public void testConstructorUsageWithTypeArgument5() throws Exception { + runTest("idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgument5.kt"); + } + + @TestMetadata("constructorUsageWithTypeArgument6.kt") + public void testConstructorUsageWithTypeArgument6() throws Exception { + runTest("idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgument6.kt"); + } + + @TestMetadata("constructorUsageWithTypeArgument7.kt") + public void testConstructorUsageWithTypeArgument7() throws Exception { + runTest("idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgument7.kt"); + } + + @TestMetadata("constructorUsageWithTypeArgumentWithoutSpecifyType.kt") + public void testConstructorUsageWithTypeArgumentWithoutSpecifyType() throws Exception { + runTest("idea/testData/quickfix/deprecatedSymbolUsage/classUsages/constructorUsageWithTypeArgumentWithoutSpecifyType.kt"); + } + @TestMetadata("imports.kt") public void testImports() throws Exception { runTest("idea/testData/quickfix/deprecatedSymbolUsage/classUsages/imports.kt");