Adding PsiComment at new String

I want to add comments before and after PsiStatement (psiElement in listed code)

So, to convert code:

to such code:


i write:

But executing previous code, i take such changes:

What i do wrong? Thank you in advance!

3 comments

Just an idea. Adding a newline char in the after text?

PsiComment psiCommentAfter = psiElementFactory.createCommentFromText("/n//After Comments", psiElement.getParent());

0

it don't work
IncorrectOperationExcepion: Incorrect comment

0

Ups the newline char should be \n

0

Please sign in to leave a comment.