@Override
  public Result preprocessEnter(@NotNull PsiFile file,
                                @NotNull Editor editor,
                                @NotNull Ref<Integer> caretOffset,
                                @NotNull Ref<Integer> caretAdvance,
                                @NotNull DataContext dataContext,
                                EditorActionHandler originalHandler)
  {
    if (!CodeInsightSettings.getInstance().SMART_INDENT_ON_ENTER) {
      return Result.Continue;
    }

    Document document = editor.getDocument();
    CharSequence text = document.getCharsSequence();
    int line = document.getLineNumber(caretOffset.get());
    int start = document.getLineStartOffset(line);
    int end = document.getLineEndOffset(line);

    CodeDocumentationUtil.CommentContext commentContext = CodeDocumentationUtil.tryParseCommentContext(file, text, caretOffset.get(), start);
    if (!commentContext.docAsterisk) {
      return Result.Continue;
    }

    Context context = parse(text, start, end, caretOffset.get());
    if (!context.shouldGenerateLine()) {
      return context.shouldIndent() ? Result.DefaultForceIndent : Result.Continue;
    }

    String indentInsideJavadoc = CodeDocumentationUtil.getIndentInsideJavadoc(document, caretOffset.get());

    boolean restoreCaret = false;
    if (caretOffset.get() != context.endTagStartOffset) {
      editor.getCaretModel().moveToOffset(context.endTagStartOffset);
      restoreCaret = true;
    }

    originalHandler.execute(editor, editor.getCaretModel().getCurrentCaret(), dataContext);
    Project project = editor.getProject();
    if (indentInsideJavadoc != null &&
        project != null &&
        CodeStyleManager.getInstance(project).getDocCommentSettings(file).isLeadingAsteriskEnabled()) {
      document.insertString(editor.getCaretModel().getOffset(), "*" + indentInsideJavadoc);
    }

    if (restoreCaret) {
      editor.getCaretModel().moveToOffset(caretOffset.get());
    }

    return Result.DefaultForceIndent;
  }
@Override
  public Result preprocessEnter(@NotNull PsiFile file,
                                @NotNull Editor editor,
                                @NotNull Ref<Integer> caretOffset,
                                @NotNull Ref<Integer> caretAdvance,
                                @NotNull DataContext dataContext,
                                EditorActionHandler originalHandler)