void (@NotNull XmlTag tag) { XmlTag newTag = XmlElementFactory.getInstance(tag.getProject()).createTagFromText('<' + tag.getName() + "></" + tag.getName() + '>'); ASTNode node = tag.getNode(); if (!(node instanceof CompositeElement compositeElement)) return; final LeafElement emptyTagEnd = (LeafElement)XmlChildRole.EMPTY_TAG_END_FINDER.findChild(compositeElement); if (emptyTagEnd == null) return; if (XmlTokenType.WHITESPACES.contains(emptyTagEnd.getTreePrev().getElementType())) { compositeElement.removeChild(emptyTagEnd.getTreePrev()); } compositeElement.removeChild(emptyTagEnd); PsiElement[] children = newTag.getChildren(); compositeElement.addChildren(children[2].getNode(), null, null); }