private static void registerDocument(@NotNull Document document, @NotNull VirtualFile virtualFile, boolean fireBindingChangedEvent) {
    if (!(virtualFile instanceof LightVirtualFile) &&
        !(virtualFile.getFileSystem() instanceof NonPhysicalFileSystem)) {
      throw new IllegalArgumentException(
        "Hard-coding file<->document association is permitted for non-physical files only (see FileViewProvider.isPhysical())" +
        " to avoid memory leaks. virtualFile=" + virtualFile);
    }
    VirtualFile oldFile;
    synchronized (lock) {
      oldFile = document.getUserData(FILE_KEY);
      document.putUserData(FILE_KEY, virtualFile);
      virtualFile.putUserData(HARD_REF_TO_DOCUMENT_KEY, document);
    }

    if (fireBindingChangedEvent) {
      fireFileBindingChanged(document, oldFile, virtualFile);
    }
  }
private static void registerDocument(@NotNull Document document, @NotNull VirtualFile virtualFile, boolean fireBindingChangedEvent)