KT-9928 Replacement not offered for a usage of symbol deprecated with DeprecationLevel.ERROR
#KT-9928 Fixed
This commit is contained in:
@@ -89,6 +89,7 @@ public class KotlinCleanupInspection(): LocalInspectionTool(), CleanupLocalInspe
|
||||
Errors.USELESS_ELVIS,
|
||||
ErrorsJvm.POSITIONED_VALUE_ARGUMENT_FOR_JAVA_ANNOTATION,
|
||||
Errors.DEPRECATION,
|
||||
Errors.DEPRECATION_ERROR,
|
||||
Errors.NON_CONST_VAL_USED_IN_CONSTANT_EXPRESSION,
|
||||
Errors.OPERATOR_MODIFIER_REQUIRED,
|
||||
Errors.DEPRECATED_UNARY_PLUS_MINUS,
|
||||
|
||||
@@ -315,6 +315,7 @@ public class QuickFixRegistrar : QuickFixContributor {
|
||||
ReplaceObsoleteLabelSyntaxFix.createWholeProjectFixFactory())
|
||||
|
||||
DEPRECATION.registerFactory(DeprecatedSymbolUsageFix, DeprecatedSymbolUsageInWholeProjectFix)
|
||||
DEPRECATION_ERROR.registerFactory(DeprecatedSymbolUsageFix, DeprecatedSymbolUsageInWholeProjectFix)
|
||||
|
||||
POSITIONED_VALUE_ARGUMENT_FOR_JAVA_ANNOTATION.registerFactory(ReplaceJavaAnnotationPositionedArgumentsFix)
|
||||
|
||||
|
||||
+2
-1
@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticFactory
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.idea.core.OptionalParametersHelper
|
||||
import org.jetbrains.kotlin.idea.quickfix.KotlinQuickFixAction
|
||||
@@ -100,7 +101,7 @@ public abstract class DeprecatedSymbolUsageFixBase(
|
||||
else
|
||||
null) ?: return null
|
||||
|
||||
val descriptor = Errors.DEPRECATION.cast(deprecatedDiagnostic).a
|
||||
val descriptor = DiagnosticFactory.cast(deprecatedDiagnostic, Errors.DEPRECATION, Errors.DEPRECATION_ERROR).a
|
||||
val replacement = DeprecatedSymbolUsageFixBase.fetchReplaceWithPattern(descriptor, nameExpression.project) ?: return null
|
||||
return Data(nameExpression, replacement, descriptor)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
// "Replace with 'b()'" "true"
|
||||
@Deprecated("b!", ReplaceWith("b()"), DeprecationLevel.ERROR)
|
||||
fun a() {}
|
||||
|
||||
fun b() {}
|
||||
|
||||
fun usage() {
|
||||
<caret>a()
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// "Replace with 'b()'" "true"
|
||||
@Deprecated("b!", ReplaceWith("b()"), DeprecationLevel.ERROR)
|
||||
fun a() {}
|
||||
|
||||
fun b() {}
|
||||
|
||||
fun usage() {
|
||||
<caret>b()
|
||||
}
|
||||
@@ -3163,6 +3163,12 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("deprecationLevel.kt")
|
||||
public void testDeprecationLevel() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/deprecatedSymbolUsage/deprecationLevel.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("doNotShortenUserReferences.kt")
|
||||
public void testDoNotShortenUserReferences() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/deprecatedSymbolUsage/doNotShortenUserReferences.kt");
|
||||
|
||||
Reference in New Issue
Block a user