Allow deprecated fix for TYPEALIAS_EXPANSION_DEPRECATION

This commit is contained in:
Nikolay Krasko
2017-07-27 20:31:07 +03:00
parent 53373b66b9
commit 24865ba26a
4 changed files with 14 additions and 3 deletions
@@ -394,6 +394,8 @@ class QuickFixRegistrar : QuickFixContributor {
DEPRECATION.registerFactory(DeprecatedSymbolUsageFix, DeprecatedSymbolUsageInWholeProjectFix, MigrateExternalExtensionFix)
DEPRECATION_ERROR.registerFactory(DeprecatedSymbolUsageFix, DeprecatedSymbolUsageInWholeProjectFix, MigrateExternalExtensionFix)
TYPEALIAS_EXPANSION_DEPRECATION.registerFactory(DeprecatedSymbolUsageFix, DeprecatedSymbolUsageInWholeProjectFix, MigrateExternalExtensionFix)
TYPEALIAS_EXPANSION_DEPRECATION_ERROR.registerFactory(DeprecatedSymbolUsageFix, DeprecatedSymbolUsageInWholeProjectFix, MigrateExternalExtensionFix)
PROTECTED_CALL_FROM_PUBLIC_INLINE.registerFactory(ReplaceProtectedToPublishedApiCallFix)
POSITIONED_VALUE_ARGUMENT_FOR_JAVA_ANNOTATION.registerFactory(ReplaceJavaAnnotationPositionedArgumentsFix)
@@ -116,7 +116,16 @@ abstract class DeprecatedSymbolUsageFixBase(
else -> null
} ?: return null
val descriptor = DiagnosticFactory.cast(deprecatedDiagnostic, Errors.DEPRECATION, Errors.DEPRECATION_ERROR).a
val descriptor = when (deprecatedDiagnostic.factory) {
Errors.DEPRECATION -> DiagnosticFactory.cast(deprecatedDiagnostic, Errors.DEPRECATION).a
Errors.DEPRECATION_ERROR -> DiagnosticFactory.cast(deprecatedDiagnostic, Errors.DEPRECATION_ERROR).a
Errors.TYPEALIAS_EXPANSION_DEPRECATION ->
DiagnosticFactory.cast(deprecatedDiagnostic, Errors.TYPEALIAS_EXPANSION_DEPRECATION).b
Errors.TYPEALIAS_EXPANSION_DEPRECATION_ERROR ->
DiagnosticFactory.cast(deprecatedDiagnostic, Errors.TYPEALIAS_EXPANSION_DEPRECATION_ERROR).b
else -> throw IllegalStateException("Bad QuickFixRegistrar configuration")
}
val replacement = DeprecatedSymbolUsageFixBase.fetchReplaceWithPattern(descriptor, nameExpression.project) ?: return null
return Data(nameExpression, replacement, descriptor)
}
@@ -1,7 +1,7 @@
// "Replace with 'NewClass(12)'" "true"
@Deprecated("Use NewClass", replaceWith = ReplaceWith("NewClass"))
class OldClass @Deprecated("Use NewClass(12)", replaceWith = ReplaceWith("NewClass(12)")) constructor()
class OldClass @Deprecated("Use NewClass(12)", level = DeprecationLevel.ERROR, replaceWith = ReplaceWith("NewClass(12)")) constructor()
@Deprecated("Use New", replaceWith = ReplaceWith("New"))
typealias Old = OldClass
@@ -1,7 +1,7 @@
// "Replace with 'NewClass(12)'" "true"
@Deprecated("Use NewClass", replaceWith = ReplaceWith("NewClass"))
class OldClass @Deprecated("Use NewClass(12)", replaceWith = ReplaceWith("NewClass(12)")) constructor()
class OldClass @Deprecated("Use NewClass(12)", level = DeprecationLevel.ERROR, replaceWith = ReplaceWith("NewClass(12)")) constructor()
@Deprecated("Use New", replaceWith = ReplaceWith("New"))
typealias Old = OldClass