Drop Annotations.findAnyAnnotation, DescriptorUtils.getAnnotationByFqName

This commit is contained in:
Alexander Udalov
2018-08-14 17:26:09 +02:00
parent 9d1baaeb56
commit 7271995ff0
9 changed files with 18 additions and 50 deletions
@@ -58,10 +58,6 @@ interface Annotations : Iterable<AnnotationDescriptor> {
override fun toString() = "EMPTY"
}
fun findAnyAnnotation(annotations: Annotations, fqName: FqName): AnnotationWithTarget? {
return annotations.getAllAnnotations().firstOrNull { it.annotation.fqName == fqName }
}
fun findUseSiteTargetedAnnotation(annotations: Annotations, target: AnnotationUseSiteTarget, fqName: FqName): AnnotationDescriptor? {
return getUseSiteTargetedAnnotations(annotations, target).firstOrNull { it.fqName == fqName }
}
@@ -12,8 +12,6 @@ import org.jetbrains.kotlin.builtins.UnsignedTypes;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.descriptors.annotations.Annotated;
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor;
import org.jetbrains.kotlin.descriptors.annotations.AnnotationWithTarget;
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
import org.jetbrains.kotlin.incremental.components.LookupLocation;
import org.jetbrains.kotlin.incremental.components.NoLookupLocation;
import org.jetbrains.kotlin.name.FqName;
@@ -538,7 +536,7 @@ public class DescriptorUtils {
@Nullable
public static String getJvmName(@NotNull Annotated annotated) {
return getJvmName(getJvmNameAnnotation(annotated));
return getJvmName(findJvmNameAnnotation(annotated));
}
@Nullable
@@ -555,14 +553,8 @@ public class DescriptorUtils {
}
@Nullable
public static AnnotationDescriptor getAnnotationByFqName(@NotNull Annotations annotations, @NotNull FqName name) {
AnnotationWithTarget annotationWithTarget = Annotations.Companion.findAnyAnnotation(annotations, name);
return annotationWithTarget == null ? null : annotationWithTarget.getAnnotation();
}
@Nullable
public static AnnotationDescriptor getJvmNameAnnotation(@NotNull Annotated annotated) {
return getAnnotationByFqName(annotated.getAnnotations(), JVM_NAME);
public static AnnotationDescriptor findJvmNameAnnotation(@NotNull Annotated annotated) {
return annotated.getAnnotations().findAnnotation(JVM_NAME);
}
@NotNull