RootsSelection (@NotNull AnActionEvent e) { VirtualFile[] files = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY); Module module = getModule(e, files); if (module == null) return RootsSelection.EMPTY; RootsSelection selection = new RootsSelection(module); final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(module.getProject()).getFileIndex(); for (VirtualFile file : files) { if (!file.isDirectory()) { return RootsSelection.EMPTY; } ExcludeFolder excludeFolder = ProjectRootsUtil.findExcludeFolder(module, file); if (excludeFolder != null) { selection.mySelectedExcludeRoots.add(excludeFolder); continue; } SourceFolder folder = ProjectRootsUtil.getModuleSourceRoot(file, module.getProject()); if (folder != null && folder.getContentEntry().getRootModel().getModule().equals(module)) { selection.mySelectedRoots.add(folder); } else { selection.mySelectedDirectories.add(file); if (fileIndex.isInSourceContent(file)) { selection.myHaveSelectedFilesUnderSourceRoots = true; } } } return selection; }