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!

0
Avatar
Permanently deleted user

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

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

0
Avatar
Permanently deleted user

it don't work
IncorrectOperationExcepion: Incorrect comment

0
Avatar
Permanently deleted user

Ups the newline char should be \n

0

请先登录再写评论。