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?