String (Project project, PsiFile file, Editor editor, String text, RawText rawText) { if (!(file instanceof PsiJavaFile)) { return text; } JavaCodeStyleSettings settings = CodeStyle.getCustomSettings(file, JavaCodeStyleSettings.class); if (!settings.JD_LEADING_ASTERISKS_ARE_ENABLED) return text; int offset = editor.getSelectionModel().getSelectionStart(); if (DocumentUtil.isAtLineEnd(offset, editor.getDocument()) && text.startsWith("\n")) return text; PsiElement element = file.findElementAt(offset); PsiDocComment docComment = PsiTreeUtil.getParentOfType(element, PsiDocComment.class, false); if (docComment == null) return text; Document document = editor.getDocument(); int lineStartOffset = DocumentUtil.getLineStartOffset(offset, document); CharSequence chars = document.getImmutableCharSequence(); int firstNonWsLineOffset = CharArrayUtil.shiftForward(chars, lineStartOffset, " \t"); if (firstNonWsLineOffset >= offset || chars.charAt(firstNonWsLineOffset) != '*') return text; String lineStartReplacement = "\n" + chars.subSequence(lineStartOffset, firstNonWsLineOffset + 1) + " "; return StringUtil.trimTrailing(text, '\n').replace("\n", lineStartReplacement); }