void () { XmlFile file = (XmlFile)PsiFileFactory.getInstance(getProject()).createFileFromText("dummy.xml", XmlFileType.INSTANCE, "<fooBarGoo>1</fooBarGoo>", 0, true); final XmlTag tag = file.getDocument().getRootTag(); final Document document = file.getViewProvider().getDocument(); ApplicationManager.getApplication().runWriteAction(() -> { tag.setName("xxx"); assertEquals("<xxx>1</xxx>", tag.getText()); assertEquals("<xxx>1</xxx>", document.getText()); }); }