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...
请先登录再写评论。
Whitespaces are inserted automatically by PSI engine according to your code style.
I did not see any getElementFactory now when I am accessing the element