Iterator<PsiFile> (Module module) { if (module.isDisposed()) return Collections.emptyIterator(); ArrayList<PsiFile> psiFileList = new ArrayList<>(); final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex(); final VirtualFile[] contentRoots = ModuleRootManager.getInstance(module).getContentRoots(); for (VirtualFile virtualFile : contentRoots) { List<VirtualFile> files = myFileTree.getFiles(virtualFile); PsiManager psiManager = PsiManager.getInstance(myProject); for (VirtualFile file : files) { if (fileIndex.getModuleForFile(file) != module) continue; if (file.isValid()) { PsiFile psiFile = psiManager.findFile(file); if (psiFile != null) { psiFileList.add(psiFile); } } } } return psiFileList.iterator(); }