Replace CodegenUtils.isDeprecated to KotlinBuiltIns.isDeprecated

This commit is contained in:
Natalia.Ukhorskaya
2012-10-18 19:03:34 +04:00
parent 1c6b7ed1ae
commit 29ca8faa4e
5 changed files with 14 additions and 26 deletions
@@ -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;
@@ -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());
}
@@ -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;
@@ -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) {
@@ -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);
}
}