Replace deprecated symbol usage in whole project: enable on annotation declared without parentheses #KT-12479 Fixed

This commit is contained in:
Toshiaki Kameyama
2018-11-16 14:20:47 +09:00
committed by Mikhail Glukhikh
parent fa51354ef9
commit 8089d2e9e3
8 changed files with 64 additions and 0 deletions
@@ -58,6 +58,7 @@ class DeprecatedSymbolUsageInWholeProjectFix(
is KtProperty -> referenceTarget
is KtTypeAlias -> referenceTarget
is KtConstructor<*> -> referenceTarget.getContainingClassOrObject() //TODO: constructor can be deprecated itself
is KtClass -> referenceTarget.takeIf { it.isAnnotation() }
else -> null
}
}
@@ -0,0 +1,9 @@
package dependency
@Deprecated("", ReplaceWith("dependency.NewAnnotation"))
annotation class OldAnnotation
annotation class NewAnnotation()
@NewAnnotation
class C
@@ -0,0 +1,9 @@
// "Replace with 'test.Bar'" "true"
package x
import dependency.*
annotation class A(val a: NewAnnotation)
@A(NewAnnotation()) class Y
@@ -0,0 +1,11 @@
// "Replace usages of 'OldAnnotation' in whole project" "true"
package test
import dependency.NewAnnotation
fun foo(a: NewAnnotation) {
}
@<caret>NewAnnotation
class X
@@ -0,0 +1,9 @@
package dependency
@Deprecated("", ReplaceWith("dependency.NewAnnotation"))
annotation class OldAnnotation
annotation class NewAnnotation()
@OldAnnotation
class C
@@ -0,0 +1,11 @@
// "Replace usages of 'OldAnnotation' in whole project" "true"
package test
import dependency.OldAnnotation
fun foo(a: OldAnnotation) {
}
@<caret>OldAnnotation
class X
@@ -0,0 +1,9 @@
// "Replace with 'test.Bar'" "true"
package x
import dependency.*
annotation class A(val a: OldAnnotation)
@A(OldAnnotation()) class Y
@@ -2395,6 +2395,11 @@ public class QuickFixMultiFileTestGenerated extends AbstractQuickFixMultiFileTes
public void testAnnotation() throws Exception {
runTest("idea/testData/quickfix/deprecatedSymbolUsage/classUsages/wholeProject/annotation.before.Main.kt");
}
@TestMetadata("noParenthesesAnnotation.before.Main.kt")
public void testNoParenthesesAnnotation() throws Exception {
runTest("idea/testData/quickfix/deprecatedSymbolUsage/classUsages/wholeProject/noParenthesesAnnotation.before.Main.kt");
}
}
}