List<VirtualFile> (@NotNull VirtualFile dir, @NotNull final ProgressIndicator progressIndicator) { if (!dir.isDirectory()) { return ContainerUtil.emptyList(); } final FileTypeManager typeManager = FileTypeManager.getInstance(); final ArrayList<VirtualFile> foundDirectories = new ArrayList<>(); try { VfsUtilCore.visitChildrenRecursively(dir, new VirtualFileVisitor<Void>() { @NotNull @Override public Result visitFileEx(@NotNull VirtualFile file) { progressIndicator.checkCanceled(); if (file.isDirectory()) { if (typeManager.isFileIgnored(file) || StringUtil.startsWithIgnoreCase(file.getName(), "testData")) { return SKIP_CHILDREN; } } else { FileType type = typeManager.getFileTypeByFileName(file.getNameSequence()); if (JavaFileType.INSTANCE == type) { VirtualFile root = suggestRootForJavaFile(file); if (root != null) { foundDirectories.add(root); return skipTo(root); } } } return CONTINUE; } }); } catch (ProcessCanceledException ignore) { } return foundDirectories; }