ITextRegion lastRegion = regions.get(regions.size() - 1);
// format children and end tag if not empty element tag
if (lastRegion.getType() != DOMRegionContext.XML_EMPTY_TAG_CLOSE) {
NodeList childNodes = newNode.getChildNodes();
if (childNodes == null || childNodes.getLength() == 0 || (childNodes.getLength() == 1 && (childNodes.item(0)).getNodeType() == Node.TEXT_NODE && ((childNodes.item(0)).getNodeValue().trim().length() == 0))) {
IDOMModel structuredModel = newNode.getModel();
IStructuredDocument structuredDocument = structuredModel.getStructuredDocument();
int startTagStartOffset = newNode.getStartOffset();
int offset = endTagStructuredDocumentRegion.getStart();
int length = endTagStructuredDocumentRegion.getLength();
structuredDocument.replaceText(structuredDocument, offset, length, ""); //$NON-NLS-1$
newNode = (IDOMNode) structuredModel.getIndexedRegion(startTagStartOffset); // save
offset = startTagStructuredDocumentRegion.getStart() + lastRegion.getStart();
structuredDocument.replaceText(structuredDocument, offset, 0, "/"); //$NON-NLS-1$
newNode = (IDOMNode) structuredModel.getIndexedRegion(startTagStartOffset); // save
}
}
}
}