boolean (@NotNull Collection<? extends PsiElement> elements) { if (elements.isEmpty()) return true; Set<VirtualFile> files = new HashSet<>(); Project project = null; for (PsiElement element : elements) { if (element == null) continue; PsiFile file = element.getContainingFile(); if (file == null || !file.isPhysical()) continue; project = file.getProject(); VirtualFile virtualFile = file.getVirtualFile(); if (virtualFile == null) continue; files.add(virtualFile); } if (!files.isEmpty()) { ReadonlyStatusHandler.OperationStatus status = ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(files); return !status.hasReadonlyFiles(); } return true; }