Iterator<PsiFile> (PsiDirectory psiDirectory) { List<VirtualFile> files = myFileTree.getFilesUnderDirectory(psiDirectory.getVirtualFile()); List<PsiFile> psiFileList = new ArrayList<>(files.size()); PsiManager psiManager = PsiManager.getInstance(myProject); for (VirtualFile file : files) { final Module module = ModuleUtilCore.findModuleForPsiElement(psiDirectory); if (module != null) { final boolean isInContent = ModuleRootManager.getInstance(module).getFileIndex().isInContent(file); if (!isInContent) continue; } if (file.isValid()) { PsiFile psiFile = psiManager.findFile(file); if (psiFile != null) { psiFileList.add(psiFile); } } } return psiFileList.iterator(); }