void () { final XmlFile file = (XmlFile)PsiFileFactory.getInstance(getProject()).createFileFromText("test.xml", "<a>\n <a/>\n</a>"); final XmlTag tagB = file.getDocument().getRootTag(); ApplicationManager.getApplication().runWriteAction(() -> tagB.getSubTags()[0].delete()); assertEquals("<a>\n </a>", tagB.getText()); }