@NotNull private List<AnnotationData> doCollect( @NotNull PsiModifierListOwner listOwner, boolean onlyWritable) { final List<PsiFile> files = findExternalAnnotationsFiles(listOwner); if (files == null) { return NO_DATA; } SmartList<AnnotationData> result = new SmartList<AnnotationData>(); String externalName = getExternalName(listOwner, false); if (externalName == null) return NO_DATA; for (PsiFile file : files) { if (!file.isValid()) continue; if (onlyWritable && !file.isWritable()) continue; MostlySingularMultiMap<String, AnnotationData> fileData = getDataFromFile(file); ContainerUtil.addAll(result, fileData.get(externalName)); } if (result.isEmpty()) { return NO_DATA; } result.trimToSize(); return result; }
private static AnnotationData findByFQN( @NotNull List<AnnotationData> map, @NotNull final String annotationFQN) { return ContainerUtil.find( map, new Condition<AnnotationData>() { @Override public boolean value(AnnotationData data) { return data.annotationClassFqName.equals(annotationFQN); } }); }
@Override @Nullable public PsiAnnotation[] findExternalAnnotations(@NotNull final PsiModifierListOwner listOwner) { final List<AnnotationData> result = collectExternalAnnotations(listOwner); return result.isEmpty() ? null : ContainerUtil.map2Array( result, PsiAnnotation.EMPTY_ARRAY, new Function<AnnotationData, PsiAnnotation>() { @Override public PsiAnnotation fun(AnnotationData data) { return data.getAnnotation(BaseExternalAnnotationsManager.this); } }); }