void (@NotNull Project project, @NotNull PsiFile file, @NotNull Set<String> importedClasses) { RestoreReferencesDialog dialog = new RestoreReferencesDialog(project, ArrayUtil.toObjectArray(importedClasses), false); dialog.setTitle(JavaBundle.message("dialog.import.on.paste.title3")); dialog.setExplanation(JavaBundle.message("dialog.paste.on.import.text3")); if (dialog.showAndGet()) { Object[] selectedElements = dialog.getSelectedElements(); if (selectedElements.length > 0) { WriteCommandAction.runWriteCommandAction(project, "", null, () -> removeImports(file, Arrays.stream(selectedElements).map(o -> (String)o).collect(Collectors.toSet()))); } } }