Delete JvmClassName.byClass, refactor JvmAnnotationNames

Store constant class names as instances of FqName instead of JvmClassName. This
is done to minimize usages of the method 'JvmClassName.getFqName()', since it's
wrong and shouldn't be used
This commit is contained in:
Alexander Udalov
2013-09-26 22:19:35 +04:00
parent 6aab9fe04e
commit 45bc7c2926
17 changed files with 93 additions and 89 deletions
@@ -17,25 +17,32 @@
package org.jetbrains.jet.lang.resolve.java.kotlinSignature;
import com.intellij.openapi.util.text.StringUtil;
import jet.runtime.typeinfo.KotlinSignature;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.resolve.java.JvmAnnotationNames;
import org.jetbrains.jet.lang.resolve.java.resolver.JavaAnnotationResolver;
import org.jetbrains.jet.lang.resolve.java.structure.JavaAnnotation;
import org.jetbrains.jet.lang.resolve.java.structure.JavaAnnotationArgument;
import org.jetbrains.jet.lang.resolve.java.structure.JavaLiteralAnnotationArgument;
import org.jetbrains.jet.lang.resolve.java.structure.JavaMember;
import org.jetbrains.jet.lang.resolve.name.FqName;
import org.jetbrains.jet.lang.resolve.name.Name;
import static org.jetbrains.jet.lang.resolve.java.resolver.DescriptorResolverUtils.fqNameByClass;
public class SignaturesUtil {
public static final FqName KOTLIN_SIGNATURE = fqNameByClass(KotlinSignature.class);
public static final Name KOTLIN_SIGNATURE_VALUE_FIELD_NAME = Name.identifier("value");
private SignaturesUtil() {
}
@Nullable
public static String getKotlinSignature(@NotNull JavaAnnotationResolver annotationResolver, @NotNull JavaMember member) {
JavaAnnotation annotation = annotationResolver.findAnnotationWithExternal(member, JvmAnnotationNames.KOTLIN_SIGNATURE);
JavaAnnotation annotation = annotationResolver.findAnnotationWithExternal(member, KOTLIN_SIGNATURE);
if (annotation != null) {
JavaAnnotationArgument argument = annotation.findArgument(JvmAnnotationNames.KOTLIN_SIGNATURE_VALUE_FIELD_NAME);
JavaAnnotationArgument argument = annotation.findArgument(KOTLIN_SIGNATURE_VALUE_FIELD_NAME);
if (argument instanceof JavaLiteralAnnotationArgument) {
Object value = ((JavaLiteralAnnotationArgument) argument).getValue();
if (value instanceof String) {
@@ -18,11 +18,9 @@ package org.jetbrains.jet.lang.resolve.java.resolver;
import com.intellij.codeInsight.ExternalAnnotationsManager;
import com.intellij.psi.PsiAnnotation;
import com.intellij.psi.PsiModifierList;
import com.intellij.psi.PsiModifierListOwner;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.resolve.java.JvmClassName;
import org.jetbrains.jet.lang.resolve.java.structure.JavaAnnotation;
import org.jetbrains.jet.lang.resolve.java.structure.JavaAnnotationOwner;
import org.jetbrains.jet.lang.resolve.java.structure.impl.JavaAnnotationImpl;
@@ -55,10 +53,4 @@ public class PsiBasedExternalAnnotationResolver implements ExternalAnnotationRes
public static PsiAnnotation findExternalAnnotation(@NotNull PsiModifierListOwner owner, @NotNull FqName fqName) {
return ExternalAnnotationsManager.getInstance(owner.getProject()).findExternalAnnotation(owner, fqName.asString());
}
@Nullable
public static PsiAnnotation findOwnAnnotation(@NotNull PsiModifierListOwner owner, @NotNull JvmClassName name) {
PsiModifierList list = owner.getModifierList();
return list == null ? null : list.findAnnotation(name.getFqName().asString());
}
}