List<PsiFile> (@NotNull PsiModifierListOwner listOwner) { if (listOwner instanceof PsiPackage) { String packageName = ((PsiPackage)listOwner).getQualifiedName(); Function<PsiPackage, List<VirtualFile>> roots = pack -> Arrays.stream(pack.getDirectories()) .flatMap(dir -> getExternalAnnotationsRoots(dir.getVirtualFile()).stream()) .distinct() .collect(Collectors.toList()); return findExternalAnnotationsFiles(packageName, (PsiPackage)listOwner, roots); } final PsiFile containingFile = PsiUtil.preferCompiledElement(listOwner).getContainingFile(); if (!(containingFile instanceof PsiClassOwner)) return null; final VirtualFile virtualFile = containingFile.getVirtualFile(); if (virtualFile == null || !virtualFile.isValid()) return null; return findExternalAnnotationsFiles(((PsiClassOwner)containingFile).getPackageName(), virtualFile, f -> getExternalAnnotationsRoots(f)); }