use of org.jetbrains.kotlin.psi.KtAnnotationEntry in project kotlin by JetBrains.
the class AnnotationsUtils method getContainingFileAnnotations.
@NotNull
public static List<AnnotationDescriptor> getContainingFileAnnotations(@NotNull BindingContext bindingContext, @NotNull DeclarationDescriptor descriptor) {
PackageFragmentDescriptor containingPackage = DescriptorUtils.getParentOfType(descriptor, PackageFragmentDescriptor.class, false);
if (containingPackage instanceof KotlinJavascriptPackageFragment) {
return ((KotlinJavascriptPackageFragment) containingPackage).getContainingFileAnnotations(descriptor);
}
KtFile kotlinFile = getFile(descriptor);
if (kotlinFile != null) {
List<AnnotationDescriptor> annotations = new ArrayList<AnnotationDescriptor>();
for (KtAnnotationEntry psiAnnotation : kotlinFile.getAnnotationEntries()) {
AnnotationDescriptor annotation = bindingContext.get(BindingContext.ANNOTATION, psiAnnotation);
if (annotation != null) {
annotations.add(annotation);
}
}
return annotations;
}
return Collections.emptyList();
}
Aggregations