boolean (DataContext dataContext, Set<? extends JpsModuleSourceRootType<?>> sourceRootTypes, Predicate<? super PsiDirectory> checkPackageExists) { final Project project = CommonDataKeys.PROJECT.getData(dataContext); final IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext); if (project == null || view == null || view.getDirectories().length == 0) { return false; } if (sourceRootTypes == null) { return true; } ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(project).getFileIndex(); for (PsiDirectory dir : view.getDirectories()) { if (projectFileIndex.isUnderSourceRootOfType(dir.getVirtualFile(), sourceRootTypes) && checkPackageExists.test(dir)) { return true; } if (isInContentRoot(dir.getVirtualFile(), projectFileIndex)) { return true; } } return false; }