TreeElement (ASTNode anchor, TreeElement child, boolean before) { if (anchor == null) { ASTNode tagNode = myTag.getNode(); ASTNode startTagEnd = XmlChildRole.START_TAG_END_FINDER.findChild(tagNode); if (startTagEnd == null) startTagEnd = XmlChildRole.EMPTY_TAG_END_FINDER.findChild(tagNode); if (startTagEnd == null) { anchor = tagNode.getLastChildNode(); while (anchor instanceof PsiWhiteSpace) { anchor = anchor.getTreePrev(); } if (anchor instanceof PsiErrorElement) { final LeafElement token = Factory .createSingleLeafElement(XmlTokenType.XML_EMPTY_ELEMENT_END, "/>", 0, 2, SharedImplUtil.findCharTableByTree(anchor), myTag.getManager()); tagNode.replaceChild(anchor, token); startTagEnd = token; } } if (startTagEnd == null) { anchor = XmlChildRole.START_TAG_NAME_FINDER.findChild(tagNode); return addInternalSuper(child, child, anchor, Boolean.FALSE); } return addInternalSuper(child, child, startTagEnd, Boolean.TRUE); } return genericInsert(child, anchor, before); }