boolean (Project project, PsiElement elementToDelete) { if (elementToDelete instanceof PsiDirectory) { VirtualFile virtualFile = ((PsiDirectory)elementToDelete).getVirtualFile(); if (virtualFile.isInLocalFileSystem() && !virtualFile.is(VFileProperty.SYMLINK)) { List<VirtualFile> readOnlyFiles = new ArrayList<>(); CommonRefactoringUtil.collectReadOnlyFiles(virtualFile, readOnlyFiles); if (!readOnlyFiles.isEmpty()) { String message = IdeBundle.message("prompt.directory.contains.read.only.files", virtualFile.getPresentableUrl()); int _result = Messages.showYesNoDialog(project, message, IdeBundle.message("title.delete"), Messages.getQuestionIcon()); if (_result != Messages.YES) return false; boolean success = true; for (VirtualFile file : readOnlyFiles) { success = clearReadOnlyFlag(file, project); if (!success) break; } if (!success) return false; } } } else if (!elementToDelete.isWritable() && !(elementToDelete instanceof PsiFileSystemItem && PsiUtilBase.isSymLink((PsiFileSystemItem)elementToDelete))) { final PsiFile file = elementToDelete.getContainingFile(); if (file != null) { final VirtualFile virtualFile = file.getVirtualFile(); if (virtualFile.isInLocalFileSystem()) { int _result = MessagesEx.fileIsReadOnly(project, virtualFile) .setTitle(IdeBundle.message("title.delete")) .appendMessage(" " + IdeBundle.message("prompt.delete.it.anyway")) .askYesNo(); if (_result != Messages.YES) return false; boolean success = clearReadOnlyFlag(virtualFile, project); if (!success) return false; } } } return true; }