@Override
  public void update(@NotNull AnActionEvent event) {
    Presentation presentation = event.getPresentation();
    DataContext dataContext = event.getDataContext();

    PsiFile psiFile = CommonDataKeys.PSI_FILE.getData(dataContext);
    if (psiFile != null) {
      presentation.setEnabled(psiFile.getContainingDirectory() != null);
      presentation.setVisible(true);
    }
    else {
      // psiFile is null => for the major of case it is NOT an editor context => no parsing => no freeze
      PsiElement psiElement = CommonDataKeys.PSI_ELEMENT.getData(dataContext);
      if (psiElement instanceof PsiDirectory) {
        presentation.setEnabledAndVisible(true);
      }
    }
  }
@Override
  public void update(@NotNull AnActionEvent event)