delegate to comment for formatting

This commit is contained in:
Dennis Ushakov
2011-08-04 15:33:41 +04:00
parent ea14412825
commit 0ba5524440
2 changed files with 12 additions and 12 deletions
@@ -34,4 +34,15 @@ public abstract class Comment {
@Nullable
public abstract Date getDate();
public void appendTo(StringBuilder builder) {
builder.append("<hr>");
if (getAuthor() != null) {
builder.append("<b>Author:</b> ").append(getAuthor()).append("<br>");
}
if (getDate() != null) {
builder.append("<b>Date:</b> ").append(getDate()).append("<br>");
}
builder.append(getText()).append("<br>");
}
}
@@ -59,23 +59,12 @@ public class TaskDocumentationProvider extends AbstractDocumentationProvider imp
builder.append("<b>Description:</b><br>").append(task.getDescription());
}
for (Comment comment : task.getComments()) {
addComment(builder, comment);
comment.appendTo(builder);
}
builder.append("</html>");
return builder.toString();
}
private static void addComment(final StringBuilder builder, final Comment comment) {
builder.append("<hr>");
if (comment.getAuthor() != null) {
builder.append("<b>Author:</b> ").append(comment.getAuthor()).append("<br>");
}
if (comment.getDate() != null) {
builder.append("<b>Date:</b> ").append(comment.getDate()).append("<br>");
}
builder.append(comment.getText()).append("<br>");
}
@Override
public PsiElement getDocumentationElementForLookupItem(PsiManager psiManager, Object object, PsiElement element) {
return object instanceof Task ? new TaskPsiElement(psiManager, (Task)object): null;