void () { PsiFile file = myFixture.configureByText("a.xml", "<"); PsiAnchor anchor = PsiAnchor.create(assertInstanceOf(file.findElementAt(0), XmlToken.class)); WriteCommandAction.runWriteCommandAction(getProject(), () -> file.getViewProvider().getDocument().replaceString(0, 1, " ")); PsiDocumentManager.getInstance(getProject()).commitAllDocuments(); assertInstanceOf(file.findElementAt(0), PsiWhiteSpace.class); assertNull(anchor.retrieve()); }