Generator<VirtualFile> () { GlobalSearchScope projectScope = GlobalSearchScope.projectScope(myProject); List<VirtualFile> allFiles = new ArrayList<>(FilenameIndex.getAllFilesByExt(myProject, "java", projectScope)); if (allFiles.isEmpty()) { throw new IllegalStateException("No java files in project???"); } ContainerUtil.sort(allFiles, Comparator.comparing(VirtualFile::getPath)); return Generator.sampledFrom(allFiles); }