void () { final XmlTag tag = XmlElementFactory.getInstance(getProject()).createTagFromText("<foo>bar</foo>"); ApplicationManager.getApplication().runWriteAction(() -> { tag.add(XmlElementFactory.getInstance(getProject()).createTagFromText("<bar/>")); }); }