Adding PsiElements to a PsiFile

I'm trying to add a comment at the start of a file.
Easy enough :

PsiElementFactory factory = file.getManager().getElementFactory();
PsiComment comment = factory.createCommentFromText(msg, file);
file.addBefore(comment, file.getFirstChild());

How do I ensure that there is white space between the comment and what was the first line of the file - there is no PsiElementFactory.createWhiteSpace...

1 comment
Comment actions Permalink

Whitespaces are inserted automatically by PSI engine according to your code style.


Please sign in to leave a comment.