Replacing of PsiFile

Hello,

I'm working on alternative formatter and often I need to replace some of PsiElements by new ones created from text.
I do it by replace() method of PsiElement.
But I have faced a problem in case of PsiFile. My plugin fails in SharedImplUtil.doReplace() by assert LOG.assertTrue(treeParent != null).

What do I do wrong?
With what name do I need create new PsiFile to replace old one? With the same?

Anton

2 comments

Replacing an entire PsiFile is not an operation that was considered meanigful when designing our PSI API. Why don't you modify the document text instead?

0

Please sign in to leave a comment.