private static void perform(AnActionEvent e, boolean selected) {
    Project project = e.getRequiredData(CommonDataKeys.PROJECT);
    VirtualFile selectedFile = e.getRequiredData(CommonDataKeys.VIRTUAL_FILE);

    if (!selected) {
      Editor editor = Objects.requireNonNull(VcsAnnotateUtil.getEditorFor(selectedFile, e.getDataContext()));
      AnnotateToggleAction.closeVcsAnnotations(editor);
    }
    else {
      Editor editor = e.getData(CommonDataKeys.EDITOR);
      if (editor != null && !Objects.equals(editor.getVirtualFile(), selectedFile)) {
        editor = null;
      }

      if (editor == null) {
        editor = FileEditorManager.getInstance(project).openTextEditor(new OpenFileDescriptor(project, selectedFile), false);
        if (editor == null) {
          Messages.showErrorDialog(project,
                                   VcsBundle.message("dialog.message.can.t.create.text.editor.for", selectedFile.getPresentableUrl()),
                                   VcsBundle.message("message.title.annotate"));
          return;
        }
      }

      doAnnotate(editor, e, project);
    }
  }
private static void perform(AnActionEvent e, boolean selected)