From 29ca8faa4e09cbeb706f63843d79ba0c54782129 Mon Sep 17 00:00:00 2001 From: "Natalia.Ukhorskaya" Date: Thu, 18 Oct 2012 19:03:34 +0400 Subject: [PATCH] Replace CodegenUtils.isDeprecated to KotlinBuiltIns.isDeprecated --- .../src/org/jetbrains/jet/codegen/AsmUtil.java | 5 ++--- .../org/jetbrains/jet/codegen/CodegenUtil.java | 12 ------------ .../jetbrains/jet/codegen/FunctionCodegen.java | 3 ++- .../jet/codegen/ImplementationBodyCodegen.java | 2 +- .../DeprecatedAnnotationVisitor.java | 18 +++++++++--------- 5 files changed, 14 insertions(+), 26 deletions(-) diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/AsmUtil.java b/compiler/backend/src/org/jetbrains/jet/codegen/AsmUtil.java index 15fbba580b8..64637e39441 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/AsmUtil.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/AsmUtil.java @@ -45,7 +45,6 @@ import java.util.Map; import java.util.Set; import static org.jetbrains.asm4.Opcodes.*; -import static org.jetbrains.jet.codegen.CodegenUtil.isDeprecated; import static org.jetbrains.jet.codegen.CodegenUtil.isInterface; import static org.jetbrains.jet.lang.resolve.DescriptorUtils.isClassObject; import static org.jetbrains.jet.lang.resolve.java.AsmTypeConstants.JAVA_STRING_TYPE; @@ -155,11 +154,11 @@ public class AsmUtil { public static int getDeprecatedAccessFlag(@NotNull MemberDescriptor descriptor) { if (descriptor instanceof PropertyAccessorDescriptor) { - return isDeprecated(descriptor) + return KotlinBuiltIns.getInstance().isDeprecated(descriptor) ? ACC_DEPRECATED : getDeprecatedAccessFlag(((PropertyAccessorDescriptor) descriptor).getCorrespondingProperty()); } - else if (isDeprecated(descriptor)) { + else if (KotlinBuiltIns.getInstance().isDeprecated(descriptor)) { return ACC_DEPRECATED; } return 0; diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/CodegenUtil.java b/compiler/backend/src/org/jetbrains/jet/codegen/CodegenUtil.java index 11ac4f2fe84..12df7864a8a 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/CodegenUtil.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/CodegenUtil.java @@ -62,18 +62,6 @@ public class CodegenUtil { return false; } - public static boolean isDeprecated(DeclarationDescriptor descriptor) { - for (AnnotationDescriptor annotation : descriptor.getAnnotations()) { - ClassDescriptor classDescriptor = TypeUtils.getClassDescriptor(annotation.getType()); - if (classDescriptor != null) { - if (DescriptorUtils.getFQName(classDescriptor).getFqName().equals(CommonClassNames.JAVA_LANG_DEPRECATED)) { - return true; - } - } - } - return false; - } - public static boolean isInterface(JetType type) { return isInterface(type.getConstructor().getDeclarationDescriptor()); } diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/FunctionCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/FunctionCodegen.java index d856572d8a0..e19521fa9b3 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/FunctionCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/FunctionCodegen.java @@ -47,6 +47,7 @@ import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames; import org.jetbrains.jet.lang.resolve.java.kt.DescriptorKindUtils; import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor; +import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns; import java.util.*; @@ -392,7 +393,7 @@ public class FunctionCodegen extends GenerationStateAware { if (isAbstract) flags |= ACC_ABSTRACT; - if (CodegenUtil.isDeprecated(functionDescriptor)) { + if (KotlinBuiltIns.getInstance().isDeprecated(functionDescriptor)) { flags |= ACC_DEPRECATED; } return flags; diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java index a1a57b8076b..1d7e09689b2 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java @@ -148,7 +148,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { if (isAnnotation) { access |= ACC_ANNOTATION; } - if (CodegenUtil.isDeprecated(descriptor)) { + if (KotlinBuiltIns.getInstance().isDeprecated(descriptor)) { access |= ACC_DEPRECATED; } if (isEnum) { diff --git a/idea/src/org/jetbrains/jet/plugin/highlighter/DeprecatedAnnotationVisitor.java b/idea/src/org/jetbrains/jet/plugin/highlighter/DeprecatedAnnotationVisitor.java index 9d9b0b4f348..6e3c4079de1 100644 --- a/idea/src/org/jetbrains/jet/plugin/highlighter/DeprecatedAnnotationVisitor.java +++ b/idea/src/org/jetbrains/jet/plugin/highlighter/DeprecatedAnnotationVisitor.java @@ -33,12 +33,12 @@ import org.jetbrains.jet.lang.resolve.DescriptorUtils; import org.jetbrains.jet.lang.resolve.calls.ResolvedCall; import org.jetbrains.jet.lang.resolve.calls.VariableAsFunctionResolvedCall; import org.jetbrains.jet.lang.types.TypeUtils; +import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns; import org.jetbrains.jet.lexer.JetTokens; import org.jetbrains.jet.resolve.DescriptorRenderer; import java.util.List; -import static org.jetbrains.jet.codegen.CodegenUtil.isDeprecated; public class DeprecatedAnnotationVisitor extends AfterAnalysisHighlightingVisitor { @@ -62,7 +62,7 @@ public class DeprecatedAnnotationVisitor extends AfterAnalysisHighlightingVisito if (resolvedCall != null && resolvedCall instanceof VariableAsFunctionResolvedCall) { // Deprecated for invoke() JetCallExpression parent = PsiTreeUtil.getParentOfType(expression, JetCallExpression.class); - if (parent != null && isDeprecated(resolvedCall.getResultingDescriptor())) { + if (parent != null && KotlinBuiltIns.getInstance().isDeprecated(resolvedCall.getResultingDescriptor())) { reportAnnotation(parent, resolvedCall.getResultingDescriptor(), true); } } @@ -95,7 +95,7 @@ public class DeprecatedAnnotationVisitor extends AfterAnalysisHighlightingVisito private void checkFunctionDescriptor(JetExpression expression, DeclarationDescriptor target) { // Deprecated for Function - if (isDeprecated(target)) { + if (KotlinBuiltIns.getInstance().isDeprecated(target)) { reportAnnotation(expression, target, expression instanceof JetArrayAccessExpression); } } @@ -104,7 +104,7 @@ public class DeprecatedAnnotationVisitor extends AfterAnalysisHighlightingVisito // Deprecated for Class and for Constructor DeclarationDescriptor containingDeclaration = target.getContainingDeclaration(); if (containingDeclaration != null) { - if (isDeprecated(containingDeclaration) || isDeprecated(target)) { + if (KotlinBuiltIns.getInstance().isDeprecated(containingDeclaration) || KotlinBuiltIns.getInstance().isDeprecated(target)) { reportAnnotation(expression, containingDeclaration); } } @@ -112,13 +112,13 @@ public class DeprecatedAnnotationVisitor extends AfterAnalysisHighlightingVisito private void checkClassDescriptor(@NotNull JetExpression expression, @NotNull ClassDescriptor target) { // Deprecated for Class, for ClassObject (if reference isn't in UserType or in ModifierList (trait)) - if (isDeprecated(target)) { + if (KotlinBuiltIns.getInstance().isDeprecated(target)) { reportAnnotation(expression, target); } else if (PsiTreeUtil.getParentOfType(expression, JetUserType.class) == null && PsiTreeUtil.getParentOfType(expression, JetModifierList.class) == null) { ClassDescriptor classObjectDescriptor = target.getClassObjectDescriptor(); - if (classObjectDescriptor != null && isDeprecated(classObjectDescriptor)) { + if (classObjectDescriptor != null && KotlinBuiltIns.getInstance().isDeprecated(classObjectDescriptor)) { reportAnnotation(expression, classObjectDescriptor); } } @@ -129,7 +129,7 @@ public class DeprecatedAnnotationVisitor extends AfterAnalysisHighlightingVisito @NotNull PropertyDescriptor propertyDescriptor ) { // Deprecated for Property - if (isDeprecated(propertyDescriptor)) { + if (KotlinBuiltIns.getInstance().isDeprecated(propertyDescriptor)) { reportAnnotation(expression, propertyDescriptor, propertyDescriptor.isVar()); return; } @@ -192,7 +192,7 @@ public class DeprecatedAnnotationVisitor extends AfterAnalysisHighlightingVisito @NotNull PropertyAccessorDescriptor accessor, @NotNull JetExpression expression, boolean isVar ) { - if (isDeprecated(accessor)) { + if (KotlinBuiltIns.getInstance().isDeprecated(accessor)) { reportAnnotation(expression, accessor, isVar); } } @@ -200,7 +200,7 @@ public class DeprecatedAnnotationVisitor extends AfterAnalysisHighlightingVisito private void checkDeprecatedForOperations(@NotNull JetReferenceExpression expression) { DeclarationDescriptor target = bindingContext.get(BindingContext.REFERENCE_TARGET, expression); if (target != null) { - if (isDeprecated(target)) { + if (KotlinBuiltIns.getInstance().isDeprecated(target)) { reportAnnotation(expression, target, true); } }