@Override
  @RequiresReadLock
  public final @Nullable Document getDocument(@NotNull VirtualFile file) {
    DocumentEx document = (DocumentEx)getCachedDocument(file);
    if (document != null) {
      return document;
    }

    if (!file.isValid() || file.isDirectory() || isBinaryWithoutDecompiler(file)) {
      return null;
    }

    boolean tooLarge = FileUtilRt.isTooLarge(file.getLength());
    if (file.getFileType().isBinary() && tooLarge) {
      return null;
    }

    CharSequence text = loadText(file, tooLarge);
    synchronized (lock) {
      document = (DocumentEx)getCachedDocument(file);
      // double-checking
      if (document != null) {
        return document;
      }

      document = createDocument(text, file);
      document.setModificationStamp(file.getModificationStamp());
      setDocumentTooLarge(document, tooLarge);
      FileType fileType = file.getFileType();
      document.setReadOnly(tooLarge || !file.isWritable() || fileType.isBinary());

      if (isTrackable(file)) {
        document.addDocumentListener(getDocumentListener());
      }

      if (file instanceof LightVirtualFile) {
        registerDocument(document, file, false);
      }
      else {
        document.putUserData(FILE_KEY, file);
        cacheDocument(file, document);
      }
    }

    fireFileBindingChanged(document, null, file);
    fileContentLoaded(file, document);

    return document;
  }
@Override
  @RequiresReadLock
  public final @Nullable Document getDocument(@NotNull VirtualFile file)