Add comment programmatically && set the comment highlighted with different color
So far, I am able to add comment like this
PsiComment comment = JavaPsiFacade.getElementFactory(project).createCommentFromText("/*aa*/", null);
//Have to write the comment via writeCommand
WriteCommandAction.runWriteCommandAction(project, new Runnable() {
@Override
public void run() {
psiClass.addBefore(comment,method);
}
});
Now I want to do something fancy, I want to do something like comment.setBackgroundColor()....
What API should I use?
Please sign in to leave a comment.
There is no any API for setting a background for individual PSI elements. Colors are set only for groups of elements of a certain type, for example, block comments.