void (@NotNull Project project, @NotNull PsiFile file, @Nullable Editor editor, @NotNull PsiElement startElement, @NotNull PsiElement endElement) { if (isAvailable(project, null, file)) { if (myDirectories.size() == 1) { apply(myStartElement.getProject(), myDirectories.get(0), editor); } else { List<TargetDirectory> directories = ContainerUtil.filter(myDirectories, d -> d.getDirectory() != null); if (directories.isEmpty()) { // there are no valid PsiDirectory items return; } if (editor == null || ApplicationManager.getApplication().isUnitTestMode()) { // run on first item of sorted list in batch mode apply(myStartElement.getProject(), directories.get(0), editor); } else { showOptionsPopup(project, editor, directories); } } } }