void (@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())); if (caret == originalEditor.getCaretModel().getPrimaryCaret()) { boolean handled = callDelegates(TypedHandlerDelegate::checkAutoPopup, charTyped, project, editor, file); if (!handled) { 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; } if (callDelegates(TypedHandlerDelegate::beforeSelectionRemoved, charTyped, project, editor, file)) { return; } EditorModificationUtilEx.deleteSelectedText(editor); FileType fileType = getFileType(file, editor); 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); } if (callDelegates(TypedHandlerDelegate::charTyped, charTyped, project, editor, file)) { return; } if ('{' == charTyped) { indentOpenedBrace(project, editor); } else if ('(' == charTyped) { indentOpenedParenth(project, editor); } }); }