private static @Nullable VirtualFile getFileInWindow(@NotNull EditorWindow window) {
    VirtualFile file = window.getContextFile();
    return file != null && window.isFileOpen(file) ? file : null;
  }
private static @Nullable VirtualFile getFileInWindow(@NotNull EditorWindow window)