Don't perform additional lookups for DeprecatedSinceKotlin annotation

There is no need to check it as `DeprecatedSinceKotlin` can be used
 only along with `Deprecated` annotation
This commit is contained in:
Mikhail Zarechenskiy
2020-06-17 18:59:01 +03:00
parent 158013ef3a
commit 0f2c96c64d
5 changed files with 2 additions and 6 deletions
@@ -370,7 +370,7 @@ internal fun KtModifierListOwner.isDeprecated(support: KtUltraLightSupport? = nu
val fqName = toQualifiedName(typeElement) ?: continue
if (fqName == deprecatedFqName || fqName == KotlinBuiltIns.FQ_NAMES.deprecatedSinceKotlin) return true
if (fqName == deprecatedFqName) return true
if (fqName.asString() == deprecatedName) return true
}
@@ -178,8 +178,7 @@ public class KtPsiUtil {
List<KtAnnotationEntry> annotationEntries = modifierList.getAnnotationEntries();
for (KtAnnotationEntry annotation : annotationEntries) {
Name shortName = annotation.getShortName();
if (KotlinBuiltIns.FQ_NAMES.deprecated.shortName().equals(shortName) ||
KotlinBuiltIns.FQ_NAMES.deprecatedSinceKotlin.shortName().equals(shortName)) {
if (KotlinBuiltIns.FQ_NAMES.deprecated.shortName().equals(shortName)) {
return true;
}
}
@@ -1117,7 +1117,6 @@ public abstract class KotlinBuiltIns {
return classFqNameEquals(descriptor, FQ_NAMES.cloneable);
}
// TODO: support DeprecatedSinceKotlin
public static boolean isDeprecated(@NotNull DeclarationDescriptor declarationDescriptor) {
if (declarationDescriptor.getOriginal().getAnnotations().hasAnnotation(FQ_NAMES.deprecated)) return true;
@@ -103,7 +103,6 @@ class DeprecatedCallableAddReplaceWithInspection : AbstractApplicabilityBasedIns
private fun KtCallableDeclaration.deprecatedAnnotationWithNoReplaceWith(): KtAnnotationEntry? {
for (entry in annotationEntries) {
// TODO: support DeprecatedSinceKotlin here
if (entry.shortName != DEPRECATED_NAME) continue
val bindingContext = entry.analyze()
val resolvedCall = entry.calleeExpression.getResolvedCall(bindingContext) ?: continue
@@ -79,7 +79,6 @@ abstract class DeprecatedSymbolUsageFixBase(
contextElement: KtSimpleNameExpression?,
replaceInWholeProject: Boolean
): ReplaceWith? {
// TODO: support DeprecatedSinceKotlin
val annotation = descriptor.annotations.findAnnotation(KotlinBuiltIns.FQ_NAMES.deprecated) ?: return null
val replaceWithValue =
annotation.argumentValue(Deprecated::replaceWith.name)?.safeAs<AnnotationValue>()?.value ?: return null