@Override
  public void invoke(@NotNull Project project, Editor editor, PsiFile file) {
    PsiDocumentManager.getInstance(project).commitAllDocuments();
    PsiJavaCodeReferenceElement element = getRefElement();
    if (element == null || !FileModificationService.getInstance().preparePsiElementForWrite(element)) {
      return;
    }

    String superClassName = getSuperClassName(element);
    PsiClass aClass = CreateFromUsageUtils.createClass(element, myKind, superClassName);
    if (aClass == null) {
      return;
    }

    ApplicationManager.getApplication().runWriteAction(() -> {
      PsiJavaCodeReferenceElement refElement = element;
      try {
        refElement = (PsiJavaCodeReferenceElement)refElement.bindToElement(aClass);
      }
      catch (IncorrectOperationException e) {
        LOG.error(e);
      }

      IdeDocumentHistory.getInstance(project).includeCurrentPlaceAsChangePlace();

      PsiDeconstructionPattern pattern = getDeconstructionPattern(element);
      if (pattern != null) {
        CreateInnerClassFromUsageFix.setupRecordFromDeconstructionPattern(aClass, pattern, getText());
      }
      else {
        Navigatable descriptor = PsiNavigationSupport.getInstance()
          .createNavigatable(refElement.getProject(), aClass.getContainingFile().getVirtualFile(), aClass.getTextOffset());
        descriptor.navigate(true);
      }
    });
  }
@Override
  public void invoke(@NotNull Project project, Editor editor, PsiFile file)