@Override
  protected void processIntention(@NotNull PsiElement element, @NotNull Project project, Editor editor) throws IncorrectOperationException {
    final GrTypeDefinition psiClass = (GrTypeDefinition)element.getParent();
    final String name = psiClass.getName();

    final PsiFile file = psiClass.getContainingFile();
    final String fileExtension = FileUtilRt.getExtension(file.getName());
    final String newFileName = name + "." + fileExtension;
    final PsiDirectory dir = file.getParent();
    if (dir != null) {
      if (dir.findFile(newFileName) != null) {
        if (!ApplicationManager.getApplication().isUnitTestMode()) {
          final String message = GroovyBundle.message("file.exists", newFileName, dir.getName());
          CommonRefactoringUtil.showErrorHint(project, editor, message, getFamilyName(), null);
        }
        return;
      }
    }

    final GroovyFile newFile = (GroovyFile)GroovyTemplatesFactory.createFromTemplate(dir, name, newFileName, GroovyTemplates.GROOVY_CLASS,
                                                                                     true);
    WriteAction.run(() -> {
      GrTypeDefinition template = newFile.getTypeDefinitions()[0];
      PsiElement newClass = template.replace(psiClass);
      GrDocComment docComment = psiClass.getDocComment();
      if (newClass instanceof GrTypeDefinition && docComment != null) {
        GrDocComment newDoc = ((GrTypeDefinition)newClass).getDocComment();
        if (newDoc != null) {
          newDoc.replace(docComment);
        }
        else {
          PsiElement parent = newClass.getParent();
          parent.addBefore(docComment, psiClass);
          parent.getNode().addLeaf(GroovyTokenTypes.mNLS, "\n", psiClass.getNode());
        }
        docComment.delete();
      }
      psiClass.delete();
      IntentionUtils.positionCursor(project, newClass.getContainingFile(), newClass.getNavigationElement());
    });
  }
@Override
  protected void processIntention(@NotNull PsiElement element, @NotNull Project project, Editor editor)