public static void checkWritable(@NotNull PsiElement element) throws IncorrectOperationException {
    if (!element.isWritable()) {
      if (element instanceof PsiDirectory) {
        String url = ((PsiDirectory)element).getVirtualFile().getPresentableUrl();
        throw new IncorrectOperationException(CoreBundle.message("cannot.modify.a.read.only.directory", url));
      }
      else {
        PsiFile file = element.getContainingFile();
        if (file == null) {
          throw new IncorrectOperationException();
        }
        VirtualFile virtualFile = file.getVirtualFile();
        if (virtualFile == null) {
          throw new IncorrectOperationException();
        }
        throw new IncorrectOperationException(CoreBundle.message("cannot.modify.a.read.only.file", virtualFile.getPresentableUrl()));
      }
    }
  }
public static void checkWritable(@NotNull PsiElement element)