private void doExecute(@NotNull Editor originalEditor, char charTyped, @NotNull DataContext dataContext) {
    final Project project = CommonDataKeys.PROJECT.getData(dataContext);
    final PsiFile originalFile;

    if (project == null || (originalFile = PsiUtilBase.getPsiFileInEditor(originalEditor, project)) == null) {
      if (myOriginalHandler != null){
        myOriginalHandler.execute(originalEditor, charTyped, dataContext);
      }
      return;
    }

    if (!EditorModificationUtil.checkModificationAllowed(originalEditor)) return;

    final PsiDocumentManager psiDocumentManager = PsiDocumentManager.getInstance(project);
    final Document originalDocument = originalEditor.getDocument();
    for (TypedHandlerDelegate delegate : TypedHandlerDelegate.EP_NAME.getExtensionList()) {
      delegate.newTypingStarted(charTyped, originalEditor, dataContext);
    }
    originalEditor.getCaretModel().runForEachCaret(caret -> {
      if (psiDocumentManager.isDocumentBlockedByPsi(originalDocument)) {
        psiDocumentManager.doPostponedOperationsAndUnblockDocument(originalDocument); // to clean up after previous caret processing
      }

      Editor editor = injectedEditorIfCharTypedIsSignificant(charTyped, originalEditor, originalFile);
      PsiFile file = editor == originalEditor ? originalFile : Objects.requireNonNull(psiDocumentManager.getPsiFile(editor.getDocument()));

      try {
        if (caret == originalEditor.getCaretModel().getPrimaryCaret()) {
          setTypedEvent(editor, charTyped, TypedEvent.TypedHandlerPhase.CHECK_AUTO_POPUP);
          boolean handled = callDelegates(TypedHandlerDelegate::checkAutoPopup, charTyped, project, editor, file);
          if (!handled) {
            setTypedEvent(editor, charTyped, TypedEvent.TypedHandlerPhase.AUTO_POPUP);
            autoPopupCompletion(editor, charTyped, project, file);
            autoPopupParameterInfo(editor, charTyped, project, file);
          }
        }
        if (editor instanceof EditorWindow && !((EditorWindow)editor).isValid()) {
          // delegate must have invalidated injected editor by calling commitDocument() or similar
          editor = injectedEditorIfCharTypedIsSignificant(charTyped, originalEditor, originalFile);
          file = editor == originalEditor ? originalFile : Objects.requireNonNull(psiDocumentManager.getPsiFile(editor.getDocument()));
        }
        if (!editor.isInsertMode()) {
          type(originalEditor, project, charTyped);
          return;
        }

        setTypedEvent(editor, charTyped, TypedEvent.TypedHandlerPhase.BEFORE_SELECTION_REMOVED);
        if (callDelegates(TypedHandlerDelegate::beforeSelectionRemoved, charTyped, project, editor, file)) {
          return;
        }

        EditorModificationUtilEx.deleteSelectedText(editor);

        FileType fileType = getFileType(file, editor);

        setTypedEvent(editor, charTyped, TypedEvent.TypedHandlerPhase.BEFORE_CHAR_TYPED);
        if (editor != originalEditor) {
          TypingEventsLogger.logTypedInInjected(project, originalFile, file);
        }
        TypedDelegateFunc func = (delegate, c1, p1, e1, f1) -> delegate.beforeCharTyped(c1, p1, e1, f1, fileType);
        if (callDelegates(func, charTyped, project, editor, file)) {
          return;
        }

        if (')' == charTyped || ']' == charTyped || '}' == charTyped) {
          if (FileTypes.PLAIN_TEXT != fileType) {
            if (handleRParen(editor, fileType, charTyped)) return;
          }
        }
        else if ('"' == charTyped || '\'' == charTyped || '`' == charTyped/* || '/' == charTyped*/) {
          if (handleQuote(project, editor, charTyped, file)) return;
        }

        long modificationStampBeforeTyping = editor.getDocument().getModificationStamp();
        type(originalEditor, project, charTyped);
        AutoHardWrapHandler.getInstance().wrapLineIfNecessary(originalEditor, dataContext, modificationStampBeforeTyping);

        if (editor.isDisposed()) { // can be that injected editor disappear
          return;
        }

        if (('(' == charTyped || '[' == charTyped || '{' == charTyped) &&
            CodeInsightSettings.getInstance().AUTOINSERT_PAIR_BRACKET &&
            fileType != FileTypes.PLAIN_TEXT) {
          handleAfterLParen(project, editor, fileType, file, charTyped);
        }
        else if ('}' == charTyped) {
          indentClosingBrace(project, editor);
        }
        else if (')' == charTyped) {
          indentClosingParenth(project, editor);
        }

        setTypedEvent(editor, charTyped, TypedEvent.TypedHandlerPhase.CHAR_TYPED);
        if (callDelegates(TypedHandlerDelegate::charTyped, charTyped, project, editor, file)) {
          return;
        }

        if ('{' == charTyped) {
          indentOpenedBrace(project, editor);
        }
        else if ('(' == charTyped) {
          indentOpenedParenth(project, editor);
        }
      }
      finally {
        editor.putUserData(CompletionPhase.AUTO_POPUP_TYPED_EVENT, null);
      }
    });
  }
private void doExecute(@NotNull Editor originalEditor, char charTyped, @NotNull DataContext dataContext)