private void assertWriteAccess() {
    if (myAssertThreading) {
      Application application = ApplicationManager.getApplication();
      if (application != null) {
        application.assertWriteAccessAllowed();
        VirtualFile file = FileDocumentManager.getInstance().getFile(this);
        if (file != null && file.isInLocalFileSystem()) {
          ((TransactionGuardImpl)TransactionGuard.getInstance()).assertWriteActionAllowed();
        }
      }
    }

    if (myIsReadOnly) {
      throw new ReadOnlyModificationException(this, CoreBundle.message("attempt.to.modify.read.only.document.error.message"));
    }

    for (DocumentWriteAccessGuard guard : DocumentWriteAccessGuard.EP_NAME.getExtensionList()) {
      DocumentWriteAccessGuard.Result result = guard.isWritable(this);
      if (!result.isSuccess()) {
        throw new ReadOnlyModificationException(
          this, String.format("%s: guardClass=%s, failureReason=%s",
                              CoreBundle.message("attempt.to.modify.read.only.document.error.message"),
                              guard.getClass().getName(), result.getFailureReason()));
      }
    }
  }
private void assertWriteAccess()