void (final ASTNode treePrev, final LeafElement whiteSpaceElement) { final CharTable charTable = SharedImplUtil.findCharTableByTree(treePrev); final ASTNode treeParent = treePrev.getTreeParent(); final boolean before; final XmlText xmlText; if(treePrev.getElementType() == XmlElementType.XML_TEXT) { xmlText = (XmlText)treePrev.getPsi(); before = true; } else if(treePrev.getTreePrev().getElementType() == XmlElementType.XML_TEXT){ xmlText = (XmlText)treePrev.getTreePrev().getPsi(); before = false; } else{ xmlText = (XmlText)Factory.createCompositeElement(XmlElementType.XML_TEXT, charTable, treeParent.getPsi().getManager()); CodeEditUtil.setNodeGenerated(xmlText.getNode(), true); treeParent.addChild(xmlText.getNode(), treePrev); before = true; } final ASTNode node = xmlText.getNode(); assert node != null; final TreeElement anchorInText = (TreeElement) (before ? node.getFirstChildNode() : node.getLastChildNode()); if (anchorInText == null) node.addChild(whiteSpaceElement); else if (anchorInText.getElementType() != XmlTokenType.XML_WHITE_SPACE) node.addChild(whiteSpaceElement, before ? anchorInText : null); else { final String text = before ? whiteSpaceElement.getText() + anchorInText.getText() : anchorInText.getText() + whiteSpaceElement.getText(); node.replaceChild(anchorInText, ASTFactory.whitespace(text)); } }