Move isDeprecated function to CodegenUtil

This commit is contained in:
Natalia.Ukhorskaya
2012-10-16 13:57:54 +04:00
parent 21900b7871
commit d55a0fcacb
2 changed files with 23 additions and 20 deletions
@@ -16,6 +16,7 @@
package org.jetbrains.jet.codegen;
import com.intellij.psi.CommonClassNames;
import com.intellij.psi.PsiElement;
import com.intellij.util.containers.Stack;
import org.jetbrains.annotations.NotNull;
@@ -35,6 +36,7 @@ import org.jetbrains.jet.lang.resolve.java.JvmClassName;
import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames;
import org.jetbrains.jet.lang.resolve.name.Name;
import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.lang.types.TypeUtils;
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
import java.util.*;
@@ -60,6 +62,18 @@ 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());
}