CommentInfo (@NotNull PsiDocComment docComment, @NotNull PsiElement owner) { String commentHeader = null; String commentFooter = null; StringBuilder sb = new StringBuilder(); boolean first = true; PsiElement e = docComment; while (true) { if (e instanceof PsiDocComment) { PsiComment cm = (PsiComment)e; String text = cm.getText(); if (text.startsWith("//")) { if (!first) sb.append('\n'); sb.append(text.substring(2).trim()); } else if (text.startsWith("/*")) { int commentHeaderEndOffset = CharArrayUtil.shiftForward(text, 1, "*"); int commentFooterStartOffset = CharArrayUtil.shiftBackward(text, text.length() - 2, "*"); if (commentHeaderEndOffset <= commentFooterStartOffset) { commentHeader = text.substring(0, commentHeaderEndOffset); commentFooter = text.substring(commentFooterStartOffset + 1); text = text.substring(commentHeaderEndOffset, commentFooterStartOffset + 1); } else { commentHeader = text.substring(0, commentHeaderEndOffset); text = ""; commentFooter = ""; } sb.append(text); } } else if (!(e instanceof PsiWhiteSpace || e instanceof PsiComment)) { break; } first = false; e = e.getNextSibling(); } return new CommentInfo(docComment, owner, commentHeader, sb.toString(), commentFooter); }