DeprecatedSymbolUsageFix - fixed bug with usage in derived class
This commit is contained in:
@@ -24,6 +24,7 @@ import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiFile
|
||||
import com.intellij.psi.PsiRecursiveElementVisitor
|
||||
import org.jetbrains.kotlin.analyzer.analyzeInContext
|
||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
|
||||
@@ -102,8 +103,13 @@ public class DeprecatedSymbolUsageFix(
|
||||
explicitReceiver?.putCopyableUserData(FROM_THIS_KEY, Unit)
|
||||
//TODO: infix and operator calls
|
||||
|
||||
val originalDescriptor = (if (descriptor is CallableMemberDescriptor)
|
||||
DescriptorUtils.unwrapFakeOverride(descriptor)
|
||||
else
|
||||
descriptor).getOriginal()
|
||||
|
||||
var (expression, imports, parameterUsages) = ReplaceWithAnnotationAnalyzer.analyze(
|
||||
replaceWith, descriptor.getOriginal(), element.getResolutionFacade(), file, project)
|
||||
replaceWith, originalDescriptor, element.getResolutionFacade(), file, project)
|
||||
|
||||
//TODO: implicit receiver is not always "this"
|
||||
//TODO: this@
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
// "Replace with 'newFun(s)'" "true"
|
||||
|
||||
open class Base {
|
||||
@deprecated("", ReplaceWith("newFun(s)"))
|
||||
fun oldFun(s: String){}
|
||||
|
||||
fun newFun(s: String){}
|
||||
}
|
||||
|
||||
class Derived : Base() {
|
||||
fun foo() {
|
||||
<caret>oldFun("a")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// "Replace with 'newFun(s)'" "true"
|
||||
|
||||
open class Base {
|
||||
@deprecated("", ReplaceWith("newFun(s)"))
|
||||
fun oldFun(s: String){}
|
||||
|
||||
fun newFun(s: String){}
|
||||
}
|
||||
|
||||
class Derived : Base() {
|
||||
fun foo() {
|
||||
<caret>newFun("a")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// "Replace with 'newFun(t, k)'" "true"
|
||||
|
||||
open class Base<T> {
|
||||
@deprecated("", ReplaceWith("newFun(t, k)"))
|
||||
fun <K> oldFun(t: T, k: K) = k
|
||||
|
||||
fun <K> newFun(t: T, k: K) = k
|
||||
}
|
||||
|
||||
class Derived : Base<String>() {
|
||||
fun foo() {
|
||||
<caret>oldFun("a", 1)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// "Replace with 'newFun(t, k)'" "true"
|
||||
|
||||
open class Base<T> {
|
||||
@deprecated("", ReplaceWith("newFun(t, k)"))
|
||||
fun <K> oldFun(t: T, k: K) = k
|
||||
|
||||
fun <K> newFun(t: T, k: K) = k
|
||||
}
|
||||
|
||||
class Derived : Base<String>() {
|
||||
fun foo() {
|
||||
<caret>newFun("a", 1)
|
||||
}
|
||||
}
|
||||
@@ -3093,6 +3093,18 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/deprecatedSymbolUsage/twoValuesCombined.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("usageInDerivedClass.kt")
|
||||
public void testUsageInDerivedClass() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/deprecatedSymbolUsage/usageInDerivedClass.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("usageInDerivedClassGeneric.kt")
|
||||
public void testUsageInDerivedClassGeneric() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/deprecatedSymbolUsage/usageInDerivedClassGeneric.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/quickfix/expressions")
|
||||
|
||||
Reference in New Issue
Block a user