void (@NotNull Editor editor, @NotNull Caret caret, DataContext dataContext) { Project project = editor.getProject(); if (project != null && EditorSettingsExternalizable.getInstance().isSmartHome()) { Document document = editor.getDocument(); CharSequence text = document.getImmutableCharSequence(); int lineStartOffset = document.getLineStartOffset(caret.getLogicalPosition().line); int nonWsStartOffset = CharArrayUtil.shiftForward(text, lineStartOffset, WHITESPACE); if (CharArrayUtil.regionMatches(text, nonWsStartOffset, "/**") || CharArrayUtil.regionMatches(text, nonWsStartOffset, "*")) { PsiDocumentManager psiDocumentManager = PsiDocumentManager.getInstance(project); PsiFile file = psiDocumentManager.getPsiFile(document); if (file != null && isJavaFile(file)) { psiDocumentManager.commitDocument(document); PsiElement startElement = file.findElementAt(nonWsStartOffset); if (startElement == null || startElement.getNode() == null) { return; } IElementType type = startElement.getNode().getElementType(); if (type == JavaDocTokenType.DOC_COMMENT_START || type == JavaDocTokenType.DOC_COMMENT_LEADING_ASTERISKS) { int targetOffset = CharArrayUtil.shiftForward(text, startElement.getTextRange().getEndOffset(), WHITESPACE); if (caret.getOffset() == targetOffset) targetOffset = lineStartOffset; int selectionStartOffset = caret.getLeadSelectionOffset(); caret.moveToOffset(targetOffset); if (myWithSelection) { caret.setSelection(selectionStartOffset, caret.getVisualPosition(), caret.getOffset()); } else { caret.removeSelection(); } EditorModificationUtilEx.scrollToCaret(editor); return; } } } } myOriginalHandler.execute(editor, caret, dataContext); }