IntelliJ plugin development - add whitespace manually
Hi,
I'm working on a plugin which generates code. I would like to add an annotation to a generated class. I use PsiElementFactory to create the annotation and then I call
psiClass.addBefore(annotation, psiClass.firstChild)
The command succeed, however, the code looks like this:
@MyAnnotation public SomeClass{
}
So the annotation is on the same line as the class declaration. And calling
codeStyleManager.reformat(psiClass)
doesn't change this (code style is set properly).
So the question is how can I do that? How can I add a line break after the annotation or before the class?
I also generate methods where I also would like to add additional line break between lines of code. For example:
public void run() {
method1()
method2()
}
Thanks for help in advance.
Martin
Please sign in to leave a comment.
Okay, I found out the annotation part.
I've just needed to call
on the psiClass.
However, I'm still interested how I can add whitespace (especially line break) where I find it necessary.
I think you want to look at PsiParserFacade.
```