Collection<PsiFileSystemItem> (final @NotNull PsiFile file) { final VirtualFile virtualFile = file.getVirtualFile(); if (virtualFile == null) return emptyList(); final PsiDirectory parent = file.getParent(); final Module module = ModuleUtilCore.findModuleForPsiElement(parent == null ? file : parent); if (module == null) return emptyList(); Set<PsiFileSystemItem> result = new LinkedHashSet<>(); final Project project = file.getProject(); for (FileReferenceHelper helper : FileReferenceHelperRegistrar.getHelpers()) { if (helper.isMine(project, virtualFile)) { if (helper.isFallback() && !result.isEmpty()) { continue; } Collection<PsiFileSystemItem> roots = helper.getRoots(module, virtualFile); for (PsiFileSystemItem root : roots) { if (root == null) { LOG.error("Helper " + helper + " produced a null root for " + file); } else { result.add(root); } } } } return new ArrayList<>(result); }