}
};
}
};
pegdownOptions.applyTo(options);
PegdownDoclet doclet = new PegdownDoclet(options, null);
StringBuilder buf = new StringBuilder();
StringBuilder tagBlock = new StringBuilder();
boolean start = true;
//List<String> inlineTags = new ArrayList<>();
//List<String> tagBlockInlineTags = new ArrayList<>();
for ( PsiElement elem : docComment.getChildren() ) {
if ( elem instanceof PsiDocToken ) {
IElementType tokenType = ((PsiDocToken)elem).getTokenType();
if ( tokenType == JavaDocTokenType.DOC_COMMENT_START || tokenType == JavaDocTokenType.DOC_COMMENT_END ) {
continue;
}
}
if ( start && elem instanceof PsiWhiteSpace ) {
continue;
}
else if ( elem instanceof PsiInlineDocTag ) {
start = false;
if ( tagBlock.length() == 0 ) {
//inlineTags.add(elem.getText());
buf.append(elem.getText());
}
else {
//tagBlockInlineTags.add(elem.getText());
tagBlock.append(elem.getText());
}
}
else if ( elem instanceof PsiDocTag ) {
PsiDocTag docTag = (PsiDocTag)elem;
switch ( docTag.getName() ) {
case "see":
tagBlock.append('\n');
renderSeeTag(doclet, tagBlock, docTag);
break;
case "param":
case "throws":
case "exception":
renderSimpleTag(doclet, tagBlock, docTag, true);
break;
case "return":
renderSimpleTag(doclet, tagBlock, docTag, false);
break;
case "todo":
renderTodoTag(doclet, tagBlock, docTag);
break;
default:
tagBlock.append('\n').append(stripLead(elem.getText()));
break;
}
}
else {
start = false;
if ( tagBlock.length() == 0 ) {
buf.append(elem.getText());
}
else {
tagBlock.append(elem.getText());
}
}
}
String markdown = stripLead(buf.toString());
Plugin.print("Markdown source", markdown);
String docCommentText = "/**\n" + escapeAsterisks(doclet.toHtml(markdown, false))
+ "\n" + escapeAsterisks(tagBlock.toString()) + "\n*/";
Plugin.print("Processed DocComment", docCommentText);
docComment = JavaPsiFacade.getInstance(project).getElementFactory().createDocCommentFromText(
docCommentText);
return docComment;