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...

0
Avatar
Permanently deleted user

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

0

I did not see any getElementFactory now when I am accessing the element

0

请先登录再写评论。